Skip to content

Commit 4fad9b0

Browse files
refactor: restructure table components into individual files for better modularity
1 parent 4eb792a commit 4fad9b0

File tree

8 files changed

+69
-59
lines changed

8 files changed

+69
-59
lines changed

apps/landing/src/components/PropsTable.tsx

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

66
import { CustomCodeBlock } from './mdx/components/CustomCodeBlock'
7-
import {
8-
TableBody,
9-
TableCell,
10-
TableHead,
11-
TableHeaderCell,
12-
TableRoot,
13-
TableRow,
14-
} from './Table'
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'
1513

1614
interface ComponentProp {
1715
property: string

apps/landing/src/components/Table.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
3+
4+
export const TableBody = ({ ...props }: ComponentPropsWithoutRef<'tbody'>) => {
5+
return <Box {...props} as="tbody" />
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
3+
4+
export const TableCell = ({ ...props }: ComponentPropsWithoutRef<'th'>) => {
5+
return <Box {...props} as="td" padding="0.5rem 1rem" />
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
3+
4+
export const TableHead = ({ ...props }: ComponentPropsWithoutRef<'thead'>) => {
5+
return (
6+
<Box
7+
{...props}
8+
as="thead"
9+
selectors={{
10+
'& tr': {
11+
bg: '$cardBg',
12+
},
13+
}}
14+
/>
15+
)
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
3+
4+
export const TableHeaderCell = ({
5+
...props
6+
}: ComponentPropsWithoutRef<'th'>) => {
7+
return <Box {...props} as="th" padding="0.5rem 1rem" textAlign="left" />
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
3+
4+
export const TableRoot = ({ ...props }: ComponentPropsWithoutRef<'table'>) => {
5+
return (
6+
<Box borderRadius="0.5rem" overflow="hidden">
7+
<Box {...props} as="table" borderCollapse="collapse" borderSpacing={0} />
8+
</Box>
9+
)
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
3+
4+
export const TableRow = ({ ...props }: ComponentPropsWithoutRef<'tr'>) => {
5+
return (
6+
<Box
7+
{...props}
8+
as="tr"
9+
borderBottom="1px solid var(--border, #E4E4E4)"
10+
selectors={{
11+
'& + &:last-of-type': {
12+
borderBottom: 'none',
13+
},
14+
}}
15+
/>
16+
)
17+
}

0 commit comments

Comments
 (0)