Skip to content

Commit d78f32a

Browse files
authored
feat(ui): style Markdown better (#1468)
1 parent bc31d9c commit d78f32a

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

apps/agentstack-ui/src/components/MarkdownContent/MarkdownContent.module.scss

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,31 @@
55

66
.root {
77
@include type-style(body-01);
8-
white-space: pre-wrap;
9-
overflow-wrap: anywhere;
108

119
> * + * {
1210
margin-block-start: rem(20px);
1311
}
1412

15-
p {
13+
p,
14+
ol,
15+
ul,
16+
blockquote {
1617
font-size: inherit;
1718
line-height: inherit;
1819
letter-spacing: inherit;
1920
}
2021

22+
ul,
23+
ol {
24+
padding-inline-start: $spacing-06;
25+
}
26+
2127
ul {
2228
list-style: disc;
23-
padding-inline-start: $spacing-06;
2429
}
2530

2631
ol {
2732
list-style: decimal;
28-
padding-inline-start: $spacing-06;
2933
}
3034

3135
ol ul {
@@ -47,13 +51,24 @@
4751
}
4852
}
4953

54+
h1 {
55+
@include type-style(heading-04);
56+
margin-block-end: 0;
57+
}
58+
5059
h2 {
5160
@include type-style(heading-03);
61+
font-weight: 600;
62+
}
63+
64+
h3 {
65+
font-size: rem(18px);
66+
line-height: math.div(24, 18);
67+
font-weight: 600;
5268
}
5369

54-
h3,
5570
h4 {
56-
@include type-style(heading-01);
71+
@include type-style(heading-02);
5772
}
5873

5974
h5,
@@ -73,4 +88,15 @@
7388
pre {
7489
white-space: pre-wrap;
7590
}
91+
92+
blockquote {
93+
padding-block: $spacing-03;
94+
padding-inline-start: $spacing-05;
95+
border-inline-start: $spacing-01 solid $border-subtle-00;
96+
color: $text-secondary;
97+
}
98+
99+
a {
100+
overflow-wrap: anywhere;
101+
}
76102
}

apps/agentstack-ui/src/components/MarkdownContent/components/Table.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
.table {
1313
@include type-style(body-01);
14+
table-layout: fixed;
15+
inline-size: 100%;
1416
&,
1517
th,
1618
td {
@@ -23,4 +25,7 @@
2325
th {
2426
font-weight: bold;
2527
}
28+
thead th {
29+
vertical-align: middle;
30+
}
2631
}

apps/agentstack-ui/src/modules/runs/chat/ChatAgentMessage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { rem } from '@carbon/layout';
7+
import type { RefObject } from 'react';
78
import { useCallback, useEffect, useRef } from 'react';
89

910
import { Spinner } from '#components/Spinner/Spinner.tsx';
@@ -26,7 +27,7 @@ import classes from './ChatAgentMessage.module.scss';
2627
interface Props {
2728
message: UIAgentMessage;
2829
isLast?: boolean;
29-
containerScrollableRef?: React.RefObject<HTMLDivElement>;
30+
containerScrollableRef?: RefObject<HTMLDivElement | null>;
3031
onShow?: () => void;
3132
}
3233

apps/agentstack-ui/src/modules/runs/chat/ChatMessagesView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { ArrowDown } from '@carbon/icons-react';
77
import { IconButton, InlineLoading } from '@carbon/react';
88
import { useRouter } from 'next/navigation';
9-
import type { RefObject } from 'react';
109

1110
import { Container } from '#components/layouts/Container.tsx';
1211
import { useIsScrolled } from '#hooks/useIsScrolled.ts';
@@ -64,7 +63,7 @@ export function ChatMessagesView() {
6463
message={message}
6564
onShow={isLast ? scrollToBottom : undefined}
6665
isLast={isLast}
67-
containerScrollableRef={scrollElementRef as RefObject<HTMLDivElement>}
66+
containerScrollableRef={scrollElementRef}
6867
/>
6968
)}
7069

0 commit comments

Comments
 (0)