|
| 1 | +import * as React from 'react'; |
| 2 | +import { storiesOf } from '@storybook/react'; |
| 3 | + |
| 4 | +import { |
| 5 | + Table, |
| 6 | + Header, |
| 7 | + HeaderRow, |
| 8 | + Body, |
| 9 | + Row, |
| 10 | + HeaderCell, |
| 11 | + Cell, |
| 12 | +} from '@table-library/react-table-library/table'; |
| 13 | +import { useTheme } from '@table-library/react-table-library/theme'; |
| 14 | + |
| 15 | +import { nodes } from '../data'; |
| 16 | + |
| 17 | +storiesOf('Misc/Actions', module) |
| 18 | + .addParameters({ component: Table }) |
| 19 | + .add('base', () => { |
| 20 | + const data = { nodes }; |
| 21 | + |
| 22 | + const theme = useTheme({ |
| 23 | + BaseCell: ` |
| 24 | + &:nth-of-type(1), &:nth-of-type(3), &:nth-of-type(4), &:nth-of-type(5) { |
| 25 | + min-width: 10%; |
| 26 | + width: 10%; |
| 27 | + } |
| 28 | +
|
| 29 | + &:nth-of-type(2) { |
| 30 | + min-width: 50px; |
| 31 | + width: 50px; |
| 32 | +
|
| 33 | + div { |
| 34 | + width: 100%; |
| 35 | + } |
| 36 | + } |
| 37 | +
|
| 38 | + &:nth-of-type(6) { |
| 39 | + flex: 1; |
| 40 | + } |
| 41 | + `, |
| 42 | + }); |
| 43 | + |
| 44 | + return ( |
| 45 | + <Table data={data} theme={theme}> |
| 46 | + {(tableList) => ( |
| 47 | + <> |
| 48 | + <Header> |
| 49 | + <HeaderRow> |
| 50 | + <HeaderCell>Task</HeaderCell> |
| 51 | + <HeaderCell stiff /> |
| 52 | + <HeaderCell>Deadline</HeaderCell> |
| 53 | + <HeaderCell>Type</HeaderCell> |
| 54 | + <HeaderCell>Complete</HeaderCell> |
| 55 | + <HeaderCell>Tasks</HeaderCell> |
| 56 | + </HeaderRow> |
| 57 | + </Header> |
| 58 | + |
| 59 | + <Body> |
| 60 | + {tableList.map((item) => ( |
| 61 | + <Row key={item.id} item={item}> |
| 62 | + <Cell>{item.name}</Cell> |
| 63 | + <Cell stiff> |
| 64 | + <div |
| 65 | + style={{ |
| 66 | + display: 'flex', |
| 67 | + justifyContent: 'center', |
| 68 | + alignItems: 'center', |
| 69 | + }} |
| 70 | + > |
| 71 | + <button>A</button> |
| 72 | + </div> |
| 73 | + </Cell> |
| 74 | + <Cell> |
| 75 | + {item.deadline.toLocaleDateString('en-US', { |
| 76 | + year: 'numeric', |
| 77 | + month: '2-digit', |
| 78 | + day: '2-digit', |
| 79 | + })} |
| 80 | + </Cell> |
| 81 | + <Cell> |
| 82 | + <div |
| 83 | + style={{ |
| 84 | + display: 'flex', |
| 85 | + justifyContent: 'space-between', |
| 86 | + alignItems: 'center', |
| 87 | + }} |
| 88 | + > |
| 89 | + <span>{item.type}</span> |
| 90 | + <button>B</button> |
| 91 | + </div> |
| 92 | + </Cell> |
| 93 | + <Cell>{item.isComplete.toString()}</Cell> |
| 94 | + <Cell> |
| 95 | + <div |
| 96 | + style={{ |
| 97 | + display: 'flex', |
| 98 | + justifyContent: 'space-between', |
| 99 | + alignItems: 'center', |
| 100 | + }} |
| 101 | + > |
| 102 | + <span>{item.nodes?.length}</span> |
| 103 | + <button>C</button> |
| 104 | + </div> |
| 105 | + </Cell> |
| 106 | + </Row> |
| 107 | + ))} |
| 108 | + </Body> |
| 109 | + </> |
| 110 | + )} |
| 111 | + </Table> |
| 112 | + ); |
| 113 | + }); |
0 commit comments