Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update default table style #114

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions libs/mibao-ui/src/lib/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
Tbody,
Tfoot,
Tr,
Th as RowTh,
Th,
Td,
TableCaption as RowTableCaption,
TableCaption,
TableHeadProps,
TableBodyProps,
TableProps,
Expand All @@ -18,13 +18,16 @@ import {
TableCaptionProps
} from '@chakra-ui/react'
import React from 'react'
import styled from '@emotion/styled'

export {
Table,
Tbody,
Tfoot,
Tr,
Th,
Td,
TableCaption,
TableHeadProps,
TableBodyProps,
TableProps,
Expand All @@ -34,26 +37,29 @@ export {
TableCaptionProps
}

const TheadStyled = styled(RowThead)`
${({ _variant }: { _variant: 'filled' | 'unstyled' }) => _variant === 'filled'
? `
position: relative;
&::before {
Vibes-INS marked this conversation as resolved.
Show resolved Hide resolved
content: ' ';
background-color: var(--chakra-colors-primary-100);
display: block;
width: 100%;
height: 100%;
position: absolute;
border-radius: 6px 6px 0 0;
z-index: -1;
}`
: undefined
}

`

export const Thead: React.FC<TableHeadProps & { variant: 'filled' | 'unstyled' }> = (props) => {
const variant = props.variant ?? 'unstyled'
return <RowThead
bg={variant === 'filled' ? 'var(--chakra-colors-primary-100)' : undefined}
return <TheadStyled
_variant={variant}
{...props}
>{props.children}</RowThead>
}

export const Th: React.FC<TableColumnHeaderProps> = (props) => {
return (
<RowTh
textTransform="none"
>{props.children}</RowTh>
)
}

export const TableCaption: React.FC<TableCaptionProps> = (props) => {
return (
<RowTableCaption
textTransform="none"
>{props.children}</RowTableCaption>
)
>{props.children}</TheadStyled>
}
28 changes: 28 additions & 0 deletions libs/mibao-ui/src/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,35 @@ export const mibaoTheme = extendTheme({
fallbacks: {
avatar: FALL_BACK_SRC,
nft: FALL_BACK_SRC
},
components: {
Table: {
baseStyle: {
th: {
textTransform: 'none'
}
},
sizes: {
sm: {
td: {
fontSize: '12px'
}
},
md: {
td: {
fontSize: '14px'
}
},
lg: {
td: {
fontSize: '14px'
}
}
}
}
}
})

console.log(mibaoTheme)
Vibes-INS marked this conversation as resolved.
Show resolved Hide resolved

export const MibaoProvider: React.FC<ChakraProviderProps> = (props) => <ChakraProvider theme={mibaoTheme} {...props}>{props.children}</ChakraProvider>