-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba1a9b6
commit 7e20426
Showing
14 changed files
with
185 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { CSSObject, SerializedStyles } from '@emotion/react'; | ||
import { css } from '@emotion/react'; | ||
|
||
import type { TBodyProps } from './TBody'; | ||
|
||
export const tBodyContainer = | ||
({ hasStickyHeader, sx }: Pick<TBodyProps, 'hasStickyHeader'> & { sx?: CSSObject }) => | ||
(): SerializedStyles => { | ||
return css` | ||
${hasStickyHeader && | ||
` | ||
display: block; | ||
overflow-y: auto; | ||
tr { | ||
display: flex; | ||
} | ||
`} | ||
${sx}; | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
import type { CSSObject } from '@emotion/react'; | ||
import React from 'react'; | ||
import isEqual from 'react-fast-compare'; | ||
|
||
const TBody: React.FCC = ({ children }) => { | ||
return <tbody>{children}</tbody>; | ||
import { tBodyContainer } from './TBody.style'; | ||
import type { TableProps } from 'components/Table/types'; | ||
|
||
export type TBodyProps = Pick<TableProps<any>, 'hasStickyHeader'> & { | ||
children?: React.ReactNode; | ||
/** Style overrides */ | ||
sx?: CSSObject; | ||
}; | ||
|
||
const TBody = React.forwardRef<HTMLTableSectionElement, TBodyProps>( | ||
({ hasStickyHeader, sx, children }, ref) => { | ||
return ( | ||
<tbody ref={ref} css={tBodyContainer({ hasStickyHeader, sx })}> | ||
{children} | ||
</tbody> | ||
); | ||
} | ||
); | ||
|
||
TBody.displayName = 'TBody'; | ||
|
||
export default React.memo(TBody, isEqual); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { css, type SerializedStyles } from '@emotion/react'; | ||
import type { Theme } from 'theme'; | ||
|
||
import type { THeadProps } from './THead'; | ||
|
||
export const tHeadContainer = | ||
({ | ||
hasStickyHeader, | ||
hasScrollbar, | ||
sx, | ||
}: Pick<THeadProps, 'hasStickyHeader' | 'sx'> & { hasScrollbar?: boolean }) => | ||
(theme: Theme): SerializedStyles => { | ||
return css` | ||
box-shadow: 0 1px 0 0 ${theme.tokens.colors.get('borderColor.decorative.default')}; | ||
${hasStickyHeader && | ||
` | ||
display: block; | ||
width: calc(100%); | ||
padding-right: ${hasScrollbar ? '8px' : '0px'}; | ||
box-sizing: border-box; | ||
tr { | ||
display: flex; | ||
} | ||
`} | ||
${hasScrollbar && | ||
` | ||
box-shadow: ${theme.tokens.boxShadow.get('2')}, 0 1px 0 0 ${theme.tokens.colors.get( | ||
'borderColor.decorative.default' | ||
)} ; | ||
`} | ||
${sx}; | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
import type { CSSObject } from '@emotion/react'; | ||
import React from 'react'; | ||
import isEqual from 'react-fast-compare'; | ||
|
||
const THead: React.FCC = ({ children }) => { | ||
return <thead>{children}</thead>; | ||
import { tHeadContainer } from './THead.style'; | ||
import type { TableProps } from 'components/Table/types'; | ||
|
||
export type THeadProps = Pick<TableProps<any>, 'hasStickyHeader'> & { | ||
/** Whether the tbody has a scrollbar. When true, a padding-right is added to the thead in order for the element to align with the tbody correctly */ | ||
hasScrollbar?: boolean; | ||
/** Style overrides */ | ||
sx?: CSSObject; | ||
}; | ||
|
||
const THead: React.FCC<THeadProps> = ({ hasStickyHeader, hasScrollbar, sx, children }) => { | ||
return <thead css={tHeadContainer({ hasStickyHeader, hasScrollbar, sx })}>{children}</thead>; | ||
}; | ||
|
||
export default React.memo(THead, isEqual); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { css, type SerializedStyles } from '@emotion/react'; | ||
|
||
import type { TRProps } from './TR'; | ||
|
||
export const trContainer = | ||
({ sx }: Pick<TRProps, 'sx'>) => | ||
(): SerializedStyles => { | ||
return css` | ||
${sx}; | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import type { CSSObject } from '@emotion/react'; | ||
import React from 'react'; | ||
import isEqual from 'react-fast-compare'; | ||
|
||
const TR: React.FCC = ({ children }) => { | ||
return <tr>{children}</tr>; | ||
import { trContainer } from './TR.style'; | ||
|
||
export type TRProps = { | ||
/** Style overrides */ | ||
sx?: CSSObject; | ||
}; | ||
|
||
const TR: React.FCC<TRProps> = ({ sx, children }) => { | ||
return <tr css={trContainer({ sx })}>{children}</tr>; | ||
}; | ||
|
||
export default React.memo(TR, isEqual); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters