@ceed/cds 1.34.1 → 1.36.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordions/Accordions.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +5 -5
- package/dist/components/Autocomplete/Autocomplete.d.ts +2 -2
- package/dist/components/Avatar/Avatar.d.ts +7 -17
- package/dist/components/Box/Box.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +6 -5
- package/dist/components/Button/Button.d.ts +3 -2
- package/dist/components/Calendar/Calendar.d.ts +1 -0
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/Chip/Chip.d.ts +1 -0
- package/dist/components/Container/Container.d.ts +6 -1
- package/dist/components/CurrencyInput/CurrencyInput.d.ts +1 -1
- package/dist/components/DialogActions/DialogActions.d.ts +1 -0
- package/dist/components/DialogContent/DialogContent.d.ts +1 -0
- package/dist/components/DialogFrame/DialogFrame.d.ts +1 -1
- package/dist/components/DialogTitle/DialogTitle.d.ts +1 -0
- package/dist/components/Divider/Divider.d.ts +1 -0
- package/dist/components/Drawer/Drawer.d.ts +1 -0
- package/dist/components/Dropdown/Dropdown.d.ts +28 -1
- package/dist/components/FilterableCheckboxGroup/FilterableCheckboxGroup.d.ts +1 -1
- package/dist/components/FormControl/FormControl.d.ts +1 -0
- package/dist/components/FormHelperText/FormHelperText.d.ts +1 -0
- package/dist/components/FormLabel/FormLabel.d.ts +1 -0
- package/dist/components/Grid/Grid.d.ts +1 -0
- package/dist/components/IconButton/IconButton.d.ts +3 -2
- package/dist/components/IconMenuButton/IconMenuButton.d.ts +7 -6
- package/dist/components/InfoSign/InfoSign.d.ts +3 -2
- package/dist/components/Input/Input.d.ts +8 -22
- package/dist/components/InsetDrawer/InsetDrawer.d.ts +1 -0
- package/dist/components/Markdown/Markdown.d.ts +9 -24
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/MenuButton/MenuButton.d.ts +10 -8
- package/dist/components/Modal/Modal.d.ts +4 -2
- package/dist/components/NavigationGroup/NavigationGroup.d.ts +3 -2
- package/dist/components/NavigationItem/NavigationItem.d.ts +3 -2
- package/dist/components/Navigator/Navigator.d.ts +5 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/Radio/Radio.d.ts +1 -0
- package/dist/components/RadioList/RadioList.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +12 -10
- package/dist/components/Sheet/Sheet.d.ts +1 -0
- package/dist/components/Stack/Stack.d.ts +1 -0
- package/dist/components/Stepper/Stepper.d.ts +2 -1
- package/dist/components/Switch/Switch.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +7 -5
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -20
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +15 -0
- package/dist/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/components/Typography/Typography.d.ts +1 -0
- package/dist/components/Uploader/Uploader.d.ts +18 -17
- package/dist/components/data-display/Avatar.md +60 -72
- package/dist/components/data-display/Badge.md +197 -181
- package/dist/components/data-display/Chip.md +164 -142
- package/dist/components/data-display/DataTable.md +843 -338
- package/dist/components/data-display/InfoSign.md +1 -3
- package/dist/components/data-display/Markdown.md +93 -125
- package/dist/components/data-display/Table.md +1453 -1007
- package/dist/components/data-display/Typography.md +113 -116
- package/dist/components/feedback/Alert.md +80 -86
- package/dist/components/feedback/CircularProgress.md +32 -36
- package/dist/components/feedback/Dialog.md +25 -17
- package/dist/components/feedback/Modal.md +296 -264
- package/dist/components/feedback/Skeleton.md +125 -89
- package/dist/components/index.d.ts +62 -2
- package/dist/components/inputs/Autocomplete.md +191 -95
- package/dist/components/inputs/Button.md +83 -83
- package/dist/components/inputs/ButtonGroup.md +195 -185
- package/dist/components/inputs/Calendar.md +25 -28
- package/dist/components/inputs/Checkbox.md +11 -29
- package/dist/components/inputs/CurrencyInput.md +4 -4
- package/dist/components/inputs/DatePicker.md +229 -110
- package/dist/components/inputs/DateRangePicker.md +248 -137
- package/dist/components/inputs/FilterableCheckboxGroup.md +115 -55
- package/dist/components/inputs/FormControl.md +75 -69
- package/dist/components/inputs/IconButton.md +229 -205
- package/dist/components/inputs/Input.md +131 -98
- package/dist/components/inputs/MonthPicker.md +186 -84
- package/dist/components/inputs/MonthRangePicker.md +73 -49
- package/dist/components/inputs/PercentageInput.md +15 -31
- package/dist/components/inputs/RadioButton.md +320 -256
- package/dist/components/inputs/RadioList.md +66 -50
- package/dist/components/inputs/RadioTileGroup.md +287 -170
- package/dist/components/inputs/SearchBar.md +82 -60
- package/dist/components/inputs/Select.md +106 -95
- package/dist/components/inputs/Slider.md +153 -102
- package/dist/components/inputs/Switch.md +193 -138
- package/dist/components/inputs/Textarea.md +15 -20
- package/dist/components/inputs/Uploader/Uploader.md +68 -39
- package/dist/components/layout/Box.md +841 -662
- package/dist/components/layout/Container.md +3 -11
- package/dist/components/layout/Grid.md +480 -394
- package/dist/components/layout/Stack.md +739 -566
- package/dist/components/navigation/Breadcrumbs.md +4 -4
- package/dist/components/navigation/Drawer.md +34 -25
- package/dist/components/navigation/Dropdown.md +745 -408
- package/dist/components/navigation/IconMenuButton.md +14 -6
- package/dist/components/navigation/InsetDrawer.md +8 -13
- package/dist/components/navigation/Link.md +1 -2
- package/dist/components/navigation/Menu.md +623 -502
- package/dist/components/navigation/MenuButton.md +18 -10
- package/dist/components/navigation/NavigationGroup.md +19 -50
- package/dist/components/navigation/NavigationItem.md +6 -6
- package/dist/components/navigation/Navigator.md +26 -28
- package/dist/components/navigation/Pagination.md +86 -75
- package/dist/components/navigation/Stepper.md +2 -12
- package/dist/components/navigation/Tabs.md +48 -36
- package/dist/components/surfaces/Accordions.md +89 -172
- package/dist/components/surfaces/Card.md +1094 -709
- package/dist/components/surfaces/Divider.md +562 -412
- package/dist/components/surfaces/Sheet.md +700 -518
- package/dist/guides/ThemeProvider.md +8 -8
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +4 -4
- package/dist/index.cjs +1082 -1036
- package/dist/index.d.ts +2 -1
- package/dist/index.js +749 -695
- package/framer/index.js +1 -1
- package/package.json +34 -36
|
@@ -26,9 +26,7 @@ function MyComponent() {
|
|
|
26
26
|
return (
|
|
27
27
|
<label>
|
|
28
28
|
Complex Setting
|
|
29
|
-
<InfoSign
|
|
30
|
-
message="This setting affects overall system performance. Consult an administrator before making changes."
|
|
31
|
-
/>
|
|
29
|
+
<InfoSign message="This setting affects overall system performance. Consult an administrator before making changes." />
|
|
32
30
|
</label>
|
|
33
31
|
);
|
|
34
32
|
}
|
|
@@ -33,13 +33,7 @@ Markdown is a component that renders markdown-formatted text as styled React com
|
|
|
33
33
|
import { Markdown } from '@ceed/cds';
|
|
34
34
|
|
|
35
35
|
function ArticleContent({ content }) {
|
|
36
|
-
return
|
|
37
|
-
<Markdown
|
|
38
|
-
content={content}
|
|
39
|
-
defaultLevel="body-md"
|
|
40
|
-
defaultLinkAction="_blank"
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
36
|
+
return <Markdown content={content} defaultLevel="body-md" defaultLinkAction="_blank" />;
|
|
43
37
|
}
|
|
44
38
|
```
|
|
45
39
|
|
|
@@ -61,14 +55,14 @@ Control the base typography level for the content.
|
|
|
61
55
|
|
|
62
56
|
```tsx
|
|
63
57
|
<Stack spacing={2}>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
</Stack>
|
|
58
|
+
<Markdown {...args} defaultLevel="title-lg" />
|
|
59
|
+
<Markdown {...args} defaultLevel="title-md" />
|
|
60
|
+
<Markdown {...args} defaultLevel="title-sm" />
|
|
61
|
+
<Markdown {...args} defaultLevel="body-lg" />
|
|
62
|
+
<Markdown {...args} defaultLevel="body-md" />
|
|
63
|
+
<Markdown {...args} defaultLevel="body-sm" />
|
|
64
|
+
<Markdown {...args} defaultLevel="body-xs" />
|
|
65
|
+
</Stack>
|
|
72
66
|
```
|
|
73
67
|
|
|
74
68
|
### Text Alignment
|
|
@@ -88,12 +82,12 @@ Apply different color themes to the markdown content.
|
|
|
88
82
|
|
|
89
83
|
```tsx
|
|
90
84
|
<div>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
</div>
|
|
85
|
+
<Markdown {...args} color="primary" />
|
|
86
|
+
<Markdown {...args} color="danger" />
|
|
87
|
+
<Markdown {...args} color="neutral" />
|
|
88
|
+
<Markdown {...args} color="success" />
|
|
89
|
+
<Markdown {...args} color="warning" />
|
|
90
|
+
</div>
|
|
97
91
|
```
|
|
98
92
|
|
|
99
93
|
### Text Color
|
|
@@ -102,10 +96,10 @@ Use specific text colors from the theme palette.
|
|
|
102
96
|
|
|
103
97
|
```tsx
|
|
104
98
|
<Stack>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</Stack>
|
|
99
|
+
<Markdown {...args} textColor="common.black" />
|
|
100
|
+
<Markdown {...args} textColor="danger.400" />
|
|
101
|
+
<Markdown {...args} textColor="primary.500" />
|
|
102
|
+
</Stack>
|
|
109
103
|
```
|
|
110
104
|
|
|
111
105
|
### Accent Color
|
|
@@ -114,9 +108,9 @@ Highlight text with custom accent color using `||text||` syntax.
|
|
|
114
108
|
|
|
115
109
|
```tsx
|
|
116
110
|
<Stack spacing={2}>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
</Stack>
|
|
111
|
+
<Markdown {...args} />
|
|
112
|
+
<Markdown {...args} fontWeight={600} />
|
|
113
|
+
</Stack>
|
|
120
114
|
```
|
|
121
115
|
|
|
122
116
|
### Bold Font Weight
|
|
@@ -125,18 +119,18 @@ Customize the weight of bold text.
|
|
|
125
119
|
|
|
126
120
|
```tsx
|
|
127
121
|
<Stack spacing={2}>
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
<Typography fontWeight="normal">Normal:</Typography>
|
|
123
|
+
<Markdown {...args} />
|
|
130
124
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
</Stack>
|
|
125
|
+
<Typography fontWeight="sm">SM:</Typography>
|
|
126
|
+
<Markdown {...args} boldFontWeight="sm" />
|
|
127
|
+
<Typography fontWeight="md">MD:</Typography>
|
|
128
|
+
<Markdown {...args} boldFontWeight="md" />
|
|
129
|
+
<Typography fontWeight="lg">LG:</Typography>
|
|
130
|
+
<Markdown {...args} boldFontWeight="lg" />
|
|
131
|
+
<Typography fontWeight="xl">XL:</Typography>
|
|
132
|
+
<Markdown {...args} boldFontWeight="xl" />
|
|
133
|
+
</Stack>
|
|
140
134
|
```
|
|
141
135
|
|
|
142
136
|
### Strikethrough
|
|
@@ -212,28 +206,41 @@ Full demonstration of all GFM features.
|
|
|
212
206
|
Override the built-in anchor renderer via `markdownOptions.components.a` to detect external links by origin comparison, open them in a new tab, and prepend an `OpenInNew` icon so users can tell external links apart at a glance. Internal links keep `defaultLinkAction` behavior and render without the icon.
|
|
213
207
|
|
|
214
208
|
```tsx
|
|
215
|
-
<Markdown
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
209
|
+
<Markdown
|
|
210
|
+
{...args}
|
|
211
|
+
markdownOptions={{
|
|
212
|
+
components: {
|
|
213
|
+
a: ({ href, children }) => {
|
|
214
|
+
const isExternal = (() => {
|
|
215
|
+
if (!href || typeof window === "undefined") return false;
|
|
216
|
+
try {
|
|
217
|
+
return new URL(href, window.location.href).origin !== window.location.origin;
|
|
218
|
+
} catch {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
})();
|
|
222
|
+
return (
|
|
223
|
+
<Link
|
|
224
|
+
href={href}
|
|
225
|
+
target={isExternal ? "_blank" : "_self"}
|
|
226
|
+
rel={isExternal ? "noopener noreferrer" : undefined}
|
|
227
|
+
startDecorator={
|
|
228
|
+
isExternal ? (
|
|
229
|
+
<OpenInNew
|
|
230
|
+
sx={{
|
|
231
|
+
fontSize: "1em"
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
234
|
+
) : undefined
|
|
235
|
+
}
|
|
236
|
+
>
|
|
237
|
+
{children}
|
|
238
|
+
</Link>
|
|
239
|
+
);
|
|
227
240
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}} /> : undefined}>
|
|
232
|
-
{children}
|
|
233
|
-
</Link>;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}} />
|
|
241
|
+
}
|
|
242
|
+
}}
|
|
243
|
+
/>
|
|
237
244
|
```
|
|
238
245
|
|
|
239
246
|
```tsx
|
|
@@ -266,7 +273,7 @@ import { Markdown, Link } from '@ceed/cds';
|
|
|
266
273
|
},
|
|
267
274
|
},
|
|
268
275
|
}}
|
|
269
|
-
|
|
276
|
+
/>;
|
|
270
277
|
```
|
|
271
278
|
|
|
272
279
|
## When to Use
|
|
@@ -309,11 +316,7 @@ function ArticlePage({ article }) {
|
|
|
309
316
|
</Typography>
|
|
310
317
|
</Stack>
|
|
311
318
|
<Divider sx={{ mb: 3 }} />
|
|
312
|
-
<Markdown
|
|
313
|
-
content={article.body}
|
|
314
|
-
defaultLevel="body-md"
|
|
315
|
-
defaultLinkAction="_blank"
|
|
316
|
-
/>
|
|
319
|
+
<Markdown content={article.body} defaultLevel="body-md" defaultLinkAction="_blank" />
|
|
317
320
|
</Box>
|
|
318
321
|
);
|
|
319
322
|
}
|
|
@@ -335,10 +338,7 @@ function Comment({ comment }) {
|
|
|
335
338
|
</Typography>
|
|
336
339
|
</Box>
|
|
337
340
|
</Stack>
|
|
338
|
-
<Markdown
|
|
339
|
-
content={comment.body}
|
|
340
|
-
defaultLevel="body-sm"
|
|
341
|
-
/>
|
|
341
|
+
<Markdown content={comment.body} defaultLevel="body-sm" />
|
|
342
342
|
</CardContent>
|
|
343
343
|
</Card>
|
|
344
344
|
);
|
|
@@ -354,11 +354,7 @@ function ReleaseNotes({ version, notes }) {
|
|
|
354
354
|
<Typography level="h2" sx={{ mb: 2 }}>
|
|
355
355
|
Version {version}
|
|
356
356
|
</Typography>
|
|
357
|
-
<Markdown
|
|
358
|
-
content={notes}
|
|
359
|
-
defaultLevel="body-md"
|
|
360
|
-
accentColor="success.500"
|
|
361
|
-
/>
|
|
357
|
+
<Markdown content={notes} defaultLevel="body-md" accentColor="success.500" />
|
|
362
358
|
</Box>
|
|
363
359
|
);
|
|
364
360
|
}
|
|
@@ -392,11 +388,7 @@ function HelpArticle({ title, content }) {
|
|
|
392
388
|
<Typography level="h1" sx={{ mb: 3 }}>
|
|
393
389
|
{title}
|
|
394
390
|
</Typography>
|
|
395
|
-
<Markdown
|
|
396
|
-
content={content}
|
|
397
|
-
defaultLevel="body-md"
|
|
398
|
-
defaultLinkAction="_blank"
|
|
399
|
-
/>
|
|
391
|
+
<Markdown content={content} defaultLevel="body-md" defaultLinkAction="_blank" />
|
|
400
392
|
</Container>
|
|
401
393
|
);
|
|
402
394
|
}
|
|
@@ -441,10 +433,7 @@ function TaskDetails({ task }) {
|
|
|
441
433
|
<Typography level="title-lg" sx={{ mb: 2 }}>
|
|
442
434
|
{task.title}
|
|
443
435
|
</Typography>
|
|
444
|
-
<Markdown
|
|
445
|
-
content={task.description}
|
|
446
|
-
defaultLevel="body-sm"
|
|
447
|
-
/>
|
|
436
|
+
<Markdown content={task.description} defaultLevel="body-sm" />
|
|
448
437
|
</CardContent>
|
|
449
438
|
</Card>
|
|
450
439
|
);
|
|
@@ -473,10 +462,7 @@ Make sure to follow the ||coding standards|| and add proper error handling.
|
|
|
473
462
|
```tsx
|
|
474
463
|
function NotificationDetail({ notification }) {
|
|
475
464
|
return (
|
|
476
|
-
<Alert
|
|
477
|
-
color={notification.type}
|
|
478
|
-
sx={{ mb: 2 }}
|
|
479
|
-
>
|
|
465
|
+
<Alert color={notification.type} sx={{ mb: 2 }}>
|
|
480
466
|
<Markdown
|
|
481
467
|
content={notification.message}
|
|
482
468
|
defaultLevel="body-sm"
|
|
@@ -504,11 +490,7 @@ function EmailPreview({ subject, body }) {
|
|
|
504
490
|
{subject}
|
|
505
491
|
</Typography>
|
|
506
492
|
<Divider sx={{ mb: 2 }} />
|
|
507
|
-
<Markdown
|
|
508
|
-
content={body}
|
|
509
|
-
defaultLevel="body-md"
|
|
510
|
-
defaultLinkAction="_blank"
|
|
511
|
-
/>
|
|
493
|
+
<Markdown content={body} defaultLevel="body-md" defaultLinkAction="_blank" />
|
|
512
494
|
</CardContent>
|
|
513
495
|
</Card>
|
|
514
496
|
);
|
|
@@ -525,10 +507,7 @@ function APIDocumentation({ endpoint }) {
|
|
|
525
507
|
<Chip color="primary" sx={{ mb: 2 }}>
|
|
526
508
|
{endpoint.method}
|
|
527
509
|
</Chip>
|
|
528
|
-
<Markdown
|
|
529
|
-
content={endpoint.description}
|
|
530
|
-
defaultLevel="body-md"
|
|
531
|
-
/>
|
|
510
|
+
<Markdown content={endpoint.description} defaultLevel="body-md" />
|
|
532
511
|
</Box>
|
|
533
512
|
);
|
|
534
513
|
}
|
|
@@ -584,7 +563,7 @@ curl -X POST https://api.example.com/users \\
|
|
|
584
563
|
## Text Formatting
|
|
585
564
|
|
|
586
565
|
**Bold text** using `**text**`
|
|
587
|
-
|
|
566
|
+
_Italic text_ using `*text*`
|
|
588
567
|
~Strikethrough~ using `~text~`
|
|
589
568
|
`Inline code` using backticks
|
|
590
569
|
||Accent color|| using `||text||`
|
|
@@ -592,7 +571,9 @@ curl -X POST https://api.example.com/users \\
|
|
|
592
571
|
## Headings
|
|
593
572
|
|
|
594
573
|
# Heading 1
|
|
574
|
+
|
|
595
575
|
## Heading 2
|
|
576
|
+
|
|
596
577
|
### Heading 3
|
|
597
578
|
|
|
598
579
|
## Links
|
|
@@ -603,16 +584,19 @@ https://auto-linked-url.com
|
|
|
603
584
|
## Lists
|
|
604
585
|
|
|
605
586
|
### Unordered
|
|
587
|
+
|
|
606
588
|
- Item 1
|
|
607
589
|
- Item 2
|
|
608
590
|
- Nested item
|
|
609
591
|
|
|
610
592
|
### Ordered
|
|
593
|
+
|
|
611
594
|
1. First
|
|
612
595
|
2. Second
|
|
613
596
|
3. Third
|
|
614
597
|
|
|
615
598
|
### Task List
|
|
599
|
+
|
|
616
600
|
- [x] Completed
|
|
617
601
|
- [ ] Pending
|
|
618
602
|
|
|
@@ -625,6 +609,7 @@ https://auto-linked-url.com
|
|
|
625
609
|
|
|
626
610
|
```javascript
|
|
627
611
|
const code = 'highlighted';
|
|
612
|
+
```
|
|
628
613
|
````
|
|
629
614
|
|
|
630
615
|
## Tables
|
|
@@ -709,10 +694,7 @@ Markdown renders semantic HTML elements with proper accessibility:
|
|
|
709
694
|
```tsx
|
|
710
695
|
// Links opening in new tabs should have proper attributes
|
|
711
696
|
// The component handles rel="noopener noreferrer" automatically
|
|
712
|
-
<Markdown
|
|
713
|
-
content="[External link](https://example.com)"
|
|
714
|
-
defaultLinkAction="_blank"
|
|
715
|
-
/>
|
|
697
|
+
<Markdown content="[External link](https://example.com)" defaultLinkAction="_blank" />
|
|
716
698
|
```
|
|
717
699
|
|
|
718
700
|
### Screen Reader Considerations
|
|
@@ -727,7 +709,7 @@ Markdown renders semantic HTML elements with proper accessibility:
|
|
|
727
709
|
// Ensure sufficient contrast with text colors
|
|
728
710
|
<Markdown
|
|
729
711
|
content="..."
|
|
730
|
-
textColor="neutral.800"
|
|
712
|
+
textColor="neutral.800" // Good contrast
|
|
731
713
|
/>
|
|
732
714
|
```
|
|
733
715
|
|
|
@@ -741,7 +723,7 @@ Markdown renders semantic HTML elements with proper accessibility:
|
|
|
741
723
|
// ✅ Good: Sanitize before rendering
|
|
742
724
|
import sanitize from 'sanitize-html';
|
|
743
725
|
|
|
744
|
-
<Markdown content={sanitize(userContent)}
|
|
726
|
+
<Markdown content={sanitize(userContent)} />;
|
|
745
727
|
```
|
|
746
728
|
|
|
747
729
|
2. **Match typography to context**: Use appropriate levels for the content type
|
|
@@ -756,20 +738,14 @@ import sanitize from 'sanitize-html';
|
|
|
756
738
|
|
|
757
739
|
```tsx
|
|
758
740
|
// ✅ Good: External links in new tab
|
|
759
|
-
<Markdown
|
|
760
|
-
content={externalContent}
|
|
761
|
-
defaultLinkAction="_blank"
|
|
762
|
-
/>
|
|
741
|
+
<Markdown content={externalContent} defaultLinkAction="_blank" />
|
|
763
742
|
```
|
|
764
743
|
|
|
765
744
|
4. **Use accent colors meaningfully**: Highlight important information
|
|
766
745
|
|
|
767
746
|
```tsx
|
|
768
747
|
// ✅ Good: Highlight key information
|
|
769
|
-
<Markdown
|
|
770
|
-
content="Your balance is ||$1,234.56||"
|
|
771
|
-
accentColor="success.500"
|
|
772
|
-
/>
|
|
748
|
+
<Markdown content="Your balance is ||$1,234.56||" accentColor="success.500" />
|
|
773
749
|
```
|
|
774
750
|
|
|
775
751
|
### ❌ Don't
|
|
@@ -824,9 +800,7 @@ import sanitize from 'sanitize-html';
|
|
|
824
800
|
For frequently re-rendering parents, memoize the Markdown component:
|
|
825
801
|
|
|
826
802
|
```tsx
|
|
827
|
-
const MemoizedMarkdown = memo(({ content, ...props }) =>
|
|
828
|
-
<Markdown content={content} {...props} />
|
|
829
|
-
));
|
|
803
|
+
const MemoizedMarkdown = memo(({ content, ...props }) => <Markdown content={content} {...props} />);
|
|
830
804
|
|
|
831
805
|
function ParentComponent({ content }) {
|
|
832
806
|
return (
|
|
@@ -854,7 +828,7 @@ function LazyMarkdown({ content }) {
|
|
|
854
828
|
observer.disconnect();
|
|
855
829
|
}
|
|
856
830
|
},
|
|
857
|
-
{ threshold: 0.1 }
|
|
831
|
+
{ threshold: 0.1 },
|
|
858
832
|
);
|
|
859
833
|
|
|
860
834
|
if (ref.current) {
|
|
@@ -865,13 +839,7 @@ function LazyMarkdown({ content }) {
|
|
|
865
839
|
}, []);
|
|
866
840
|
|
|
867
841
|
return (
|
|
868
|
-
<Box ref={ref}>
|
|
869
|
-
{isVisible ? (
|
|
870
|
-
<Markdown content={content} />
|
|
871
|
-
) : (
|
|
872
|
-
<Skeleton variant="rectangular" height={200} />
|
|
873
|
-
)}
|
|
874
|
-
</Box>
|
|
842
|
+
<Box ref={ref}>{isVisible ? <Markdown content={content} /> : <Skeleton variant="rectangular" height={200} />}</Box>
|
|
875
843
|
);
|
|
876
844
|
}
|
|
877
845
|
```
|
|
@@ -901,11 +869,11 @@ Keep content stable when possible:
|
|
|
901
869
|
|
|
902
870
|
```tsx
|
|
903
871
|
// ❌ Bad: Creating new string on each render
|
|
904
|
-
<Markdown content={`Hello, ${name}!`}
|
|
872
|
+
<Markdown content={`Hello, ${name}!`} />;
|
|
905
873
|
|
|
906
874
|
// ✅ Good: Memoize dynamic content
|
|
907
875
|
const content = useMemo(() => `Hello, ${name}!`, [name]);
|
|
908
|
-
<Markdown content={content}
|
|
876
|
+
<Markdown content={content} />;
|
|
909
877
|
```
|
|
910
878
|
|
|
911
879
|
Markdown provides a powerful way to render formatted text content in your application. Use it for documentation, user-generated content, and any scenario requiring rich text display. Always sanitize untrusted content, match typography levels to your context, and consider performance for large documents.
|