Skip to content

Commit

Permalink
feat: nullable cell option (#754)
Browse files Browse the repository at this point in the history
* feat: nullable cell option

* fix: format
  • Loading branch information
AtsushiM committed May 8, 2020
1 parent 0bf27be commit b16624d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Table/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type Props = {
colSpan?: number
rowSpan?: number
highlighted?: boolean
nullable?: boolean
children?: ReactNode
className?: string
onClick?: () => void
Expand All @@ -22,10 +23,13 @@ export const Cell: FC<Props> = ({
colSpan,
rowSpan,
highlighted = false,
nullable = false,
}) => {
const theme = useTheme()
const { group } = useContext(TableGroupContext)
const classNames = `${className} ${highlighted ? 'highlighted' : ''}`
const classNames = [className, highlighted && 'highlighted', nullable && 'nullable']
.filter((c) => !!c)
.join(' ')
const props = {
children,
onClick,
Expand Down Expand Up @@ -73,6 +77,14 @@ const Th = styled.th<{ themes: Theme; onClick?: () => void }>`
}}
`
const Td = styled.td<{ themes: Theme }>`
&.nullable {
&:empty {
&::after {
content: '-----';
}
}
}
${({ themes }) => {
const { size, palette, frame } = themes
Expand Down
5 changes: 5 additions & 0 deletions src/components/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ storiesOf('Table', module)
line
</Cell>
</Row>
<Row>
<Cell nullable={true}></Cell>
<Cell nullable={true}>not null</Cell>
<Cell nullable={false}></Cell>
</Row>
</Body>
</Table>
</Base>
Expand Down

0 comments on commit b16624d

Please sign in to comment.