|
1 | | -import { Box, Divider, Flex, Image, Stack, Table, Text } from '@chakra-ui/react' |
| 1 | +import { |
| 2 | + Box, |
| 3 | + Divider, |
| 4 | + Flex, |
| 5 | + Image, |
| 6 | + Stack, |
| 7 | + Table, |
| 8 | + Tbody, |
| 9 | + Td, |
| 10 | + Th, |
| 11 | + Thead, |
| 12 | + Tr, |
| 13 | + Text, |
| 14 | + useColorModeValue, |
| 15 | +} from '@chakra-ui/react' |
2 | 16 | import { Code, HeadingWithAnchor, Link } from '@/components' |
3 | | -// TODO: Debug tables |
| 17 | + |
| 18 | +const MDTable = ({ children }: any) => { |
| 19 | + const borderColor = useColorModeValue('purple.300', '#3D35A0') |
| 20 | + const headerBg = useColorModeValue('gray.50', '#1a1560') |
| 21 | + const tableBg = useColorModeValue('white', 'transparent') |
| 22 | + return ( |
| 23 | + <Box |
| 24 | + overflowX="auto" |
| 25 | + mb={{ base: 4, md: 6 }} |
| 26 | + borderWidth="1px" |
| 27 | + borderColor={borderColor} |
| 28 | + borderRadius="md" |
| 29 | + bg={tableBg} |
| 30 | + sx={{ |
| 31 | + '& table': { borderCollapse: 'collapse', width: '100%' }, |
| 32 | + '& th, & td': { |
| 33 | + border: '1px solid', |
| 34 | + borderColor, |
| 35 | + }, |
| 36 | + '& th': { bg: headerBg }, |
| 37 | + }} |
| 38 | + > |
| 39 | + <Table variant="simple" size="sm"> |
| 40 | + {children} |
| 41 | + </Table> |
| 42 | + </Box> |
| 43 | + ) |
| 44 | +} |
4 | 45 |
|
5 | 46 | export const MDStyles = { |
6 | 47 | p: ({ children }: any) => ( |
@@ -94,4 +135,10 @@ export const MDStyles = { |
94 | 135 | hr: ({ children }: any) => { |
95 | 136 | return <Divider my={6}>{children}</Divider> |
96 | 137 | }, |
| 138 | + table: ({ children }: any) => <MDTable>{children}</MDTable>, |
| 139 | + thead: ({ children }: any) => <Thead>{children}</Thead>, |
| 140 | + tbody: ({ children }: any) => <Tbody>{children}</Tbody>, |
| 141 | + tr: ({ children }: any) => <Tr>{children}</Tr>, |
| 142 | + th: ({ children }: any) => <Th>{children}</Th>, |
| 143 | + td: ({ children }: any) => <Td>{children}</Td>, |
97 | 144 | } |
0 commit comments