Skip to content

Commit 7413df3

Browse files
committed
Use mdx table
1 parent 80581a1 commit 7413df3

File tree

5 files changed

+83
-78
lines changed

5 files changed

+83
-78
lines changed

apps/landing/src/app/(detail)/components/MdxCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export default async function MdxCard({
4848
border: '1px solid $border',
4949
bg: '$containerBackground',
5050
maxWidth: '100%',
51-
minWidth: '300px',
5251
flexShrink: 0,
5352
cursor: 'default',
5453
marginBottom: '20px',
Lines changed: 10 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,13 @@
1-
import { Td, Th, Tr, Table } from '../Table'
2-
3-
41
###### API
52
`Button` props extends the button HTML attributes.
6-
<div style={{ overflow: 'auto', width: '100%' }}>
7-
<Table style={{width: '100%'}}>
8-
<thead>
9-
<Tr>
10-
<Th>Property</Th>
11-
<Th>Description</Th>
12-
<Th>Type</Th>
13-
<Th>Default</Th>
14-
</Tr>
15-
</thead>
16-
<tbody>
17-
<Tr>
18-
<Td>variant</Td>
19-
<Td>The variant of the button</Td>
20-
<Td>`'primary' | 'default'`</Td>
21-
<Td>`'default'`</Td>
22-
</Tr>
23-
<Tr>
24-
<Td>colors</Td>
25-
<Td>The color variables of the button, i.e. `var(--primary)`</Td>
26-
<Td>
27-
```
28-
{
29-
primary?: string
30-
error?: string
31-
text?: string
32-
border?: string
33-
inputBackground?: string
34-
primaryFocus?: string
35-
}
36-
```
37-
</Td>
38-
<Td>`undefined`</Td>
39-
</Tr>
40-
<Tr>
41-
<Td>danger</Td>
42-
<Td>Signals that it should be used with caution. It is often used in a delete button or to show the error status.</Td>
43-
<Td>`boolean`</Td>
44-
<Td>`false`</Td>
45-
</Tr>
46-
<Tr>
47-
<Td>size</Td>
48-
<Td>The size of the button</Td>
49-
<Td>`'sm' | 'md' | 'lg'`</Td>
50-
<Td>`'md'`</Td>
51-
</Tr>
52-
<Tr>
53-
<Td>icon</Td>
54-
<Td>Icon of the button passed in as a form of ReactNode</Td>
55-
<Td>`React.ReactNode`</Td>
56-
<Td>`undefined`</Td>
57-
</Tr>
58-
<Tr>
59-
<Td>ellipsis</Td>
60-
<Td>
61-
Whether the button text should be truncated with an ellipsis. The
62-
button should have a width to be able to truncate the text.
63-
</Td>
64-
<Td>`boolean`</Td>
65-
<Td>`false`</Td>
66-
</Tr>
67-
</tbody>
68-
</Table>
69-
</div>
703

71-
## aa
72-
73-
| Property | Description | Type | Default | Version |
74-
| --- | --- | --- | --- | --- |
75-
| autoInsertSpace | We add a space between two Chinese characters by default, which removed by setting `autoInsertSpace` to `false`. | boolean | `true` | 5.17.0 |
4+
<div style={{ width: '100%', overflow: 'auto'}}>
5+
| Property | Description | Type | Default |
6+
| --- | --- | --- | --- |
7+
| **variant** | The variant of the button | `'primary' \| 'default'` | `'default'` |
8+
| **colors** | The color variables of the button, i.e. `var(--primary)` | ```{<br> primary?: string<br> error?: string<br> text?: string<br> border?: string<br> inputBackground?: string<br> primaryFocus?: string<br>}``` | `undefined` |
9+
| **danger** | Signals that it should be used with caution. It is often used in a delete button or to show the error status. | `boolean` | `false` |
10+
| **size** | The size of the button | `'sm' \| 'md' \| 'lg'` | `'md'` |
11+
| **icon** | Icon of the button passed in as a form of ReactNode | `React.ReactNode` | `undefined` |
12+
| **ellipsis** | Whether the button text should be truncated with an ellipsis. The button should have a width to be able to truncate the text. | `boolean` | `false` |
13+
</div>

apps/landing/src/app/(detail)/components/button/Examples.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { Colors } from './demo/Colors'
1111
###### Examples
1212

1313
<div style={{ display: 'flex', gap: '16px', flexWrap: 'wrap' }}>
14-
<section style={{ flex: '1', maxWidth: 'calc(50% - 8px)' }}>
14+
<section style={{ flex: '1', minWidth: '300px', width: 'calc(50% - 8px)' }}>
1515
<MdxCard src="button/demo/Variants.tsx" demo={<Variants />} />
1616
<MdxCard src="button/demo/Danger.tsx" demo={<Danger />} />
1717
<MdxCard src="button/demo/Disabled.tsx" demo={<Disabled />} />
1818
</section>
19-
<section style={{ flex: '1', maxWidth: 'calc(50% - 8px)' }}>
19+
<section style={{ flex: '1', minWidth: '300px', width: 'calc(50% - 8px)' }}>
2020
<MdxCard src="button/demo/Icon.tsx" demo={<Icon />} />
2121
<MdxCard src="button/demo/Colors.tsx" demo={<Colors />} />
2222
</section>

apps/landing/src/app/(detail)/components/button/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function CustomPre({ children }: { children: React.ReactNode }) {
4848
)
4949
}
5050

51-
function CustomCode({ children }: { children: React.ReactNode }) {
51+
function CustomCode({ children }: { children: string }) {
5252
return (
53-
<Box as="code" color="$primary">
54-
{children}
53+
<Box as="code" color="$primary" whiteSpace="pre-wrap">
54+
{children.replaceAll('<br>', '\n')}
5555
</Box>
5656
)
5757
}

apps/landing/src/mdx-components.tsx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,74 @@ export const _components = {
4949
pre({ children }: { children: React.ReactNode }) {
5050
return <Box as="pre">{children}</Box>
5151
},
52+
table({ children }: { children: React.ReactNode }) {
53+
return (
54+
<Box
55+
as="table"
56+
border="none"
57+
maxW="100%"
58+
minW="600px"
59+
selectors={{
60+
'& thead, & tbody': {
61+
border: 'none',
62+
},
63+
}}
64+
typography="bodyBold"
65+
>
66+
{children}
67+
</Box>
68+
)
69+
},
70+
thead({ children }: { children: React.ReactNode }) {
71+
return (
72+
<Text
73+
as="thead"
74+
bg="$cardBg"
75+
border="none"
76+
color="$captionBold"
77+
m="0"
78+
textAlign="left"
79+
typography="bodyReg"
80+
>
81+
{children}
82+
</Text>
83+
)
84+
},
85+
th({ children }: { children: React.ReactNode }) {
86+
return (
87+
<Text as="th" border="none" color="$captionBold" m="0">
88+
{children}
89+
</Text>
90+
)
91+
},
92+
tr({ children }: { children: React.ReactNode }) {
93+
return (
94+
<Text
95+
as="tr"
96+
borderBottom="1px solid $border"
97+
borderTop="1px solid $border"
98+
color="$text"
99+
m="0"
100+
typography="body"
101+
>
102+
{children}
103+
</Text>
104+
)
105+
},
106+
td({ children }: { children: React.ReactNode }) {
107+
return (
108+
<Text
109+
as="td"
110+
border="none"
111+
color="$text"
112+
m="0"
113+
typography="body"
114+
whiteSpace="pre-wrap"
115+
>
116+
{children}
117+
</Text>
118+
)
119+
},
52120
}
53121

54122
export function useMDXComponents(components: MDXComponents): MDXComponents {

0 commit comments

Comments
 (0)