Skip to content

Commit fd47036

Browse files
refactor: consolidate table components into a single Table component and update PropsTable accordingly
1 parent ddcff65 commit fd47036

File tree

9 files changed

+62
-72
lines changed

9 files changed

+62
-72
lines changed

apps/landing/src/components/PropsTable.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import Markdown from 'react-markdown'
44
import { _components } from '@/mdx-components'
55

66
import { CustomCodeBlock } from './mdx/components/CustomCodeBlock'
7-
import { TableBody } from './TableBody'
8-
import { TableCell } from './TableCell'
9-
import { TableHead } from './TableHead'
10-
import { TableHeaderCell } from './TableHeaderCell'
11-
import { TableRoot } from './TableRoot'
12-
import { TableRow } from './TableRow'
7+
import {
8+
Table,
9+
TableBody,
10+
TableCell,
11+
TableHead,
12+
TableHeaderCell,
13+
TableRow,
14+
} from './mdx/components/Table'
1315

1416
interface ComponentProp {
1517
property: string
@@ -39,7 +41,7 @@ export const PropsTable = async (props: PropTableProps) => {
3941
const { componentProps } = props
4042

4143
return (
42-
<TableRoot border={0}>
44+
<Table border={0}>
4345
<TableHead>
4446
<TableRow>
4547
<TableHeaderCell>Prop</TableHeaderCell>
@@ -83,6 +85,6 @@ export const PropsTable = async (props: PropTableProps) => {
8385
),
8486
)}
8587
</TableBody>
86-
</TableRoot>
88+
</Table>
8789
)
8890
}

apps/landing/src/components/TableBody.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

apps/landing/src/components/TableCell.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

apps/landing/src/components/TableHead.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

apps/landing/src/components/TableHeaderCell.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/landing/src/components/TableRoot.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/landing/src/components/TableRow.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

apps/landing/src/components/mdx/components/CustomCodeBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function CustomCodeBlock({ children }: { children: string }) {
44
return (
55
<Box
66
as="code"
7-
bg="var(--containerBackground)"
7+
bg="$containerBackground"
88
borderRadius="0.25rem"
99
color="var(--text)"
1010
padding="0.25rem"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Box } from '@devup-ui/react'
2+
import { type ComponentProps } from 'react'
3+
4+
export const Table = ({ ...props }: ComponentProps<'table'>) => {
5+
return (
6+
<Box borderRadius="0.5rem" overflow="hidden">
7+
<Box {...props} as="table" borderCollapse="collapse" borderSpacing={0} />
8+
</Box>
9+
)
10+
}
11+
12+
export const TableBody = ({ ...props }: ComponentProps<'tbody'>) => {
13+
return <Box {...props} as="tbody" />
14+
}
15+
16+
export const TableCell = ({ ...props }: ComponentProps<'th'>) => {
17+
return <Box {...props} as="td" padding="0.5rem 1rem" />
18+
}
19+
20+
export const TableHead = ({ ...props }: ComponentProps<'thead'>) => {
21+
return (
22+
<Box
23+
{...props}
24+
as="thead"
25+
selectors={{
26+
'& tr': {
27+
bg: '$cardBg',
28+
},
29+
}}
30+
/>
31+
)
32+
}
33+
34+
export const TableHeaderCell = ({ ...props }: ComponentProps<'th'>) => {
35+
return <Box {...props} as="th" padding="0.5rem 1rem" textAlign="left" />
36+
}
37+
38+
export const TableRow = ({ ...props }: ComponentProps<'tr'>) => {
39+
return (
40+
<Box
41+
{...props}
42+
as="tr"
43+
borderBottom="1px solid var(--border, #E4E4E4)"
44+
selectors={{
45+
'& + &:last-of-type': {
46+
borderBottom: 'none',
47+
},
48+
}}
49+
/>
50+
)
51+
}

0 commit comments

Comments
 (0)