|
| 1 | +/* |
| 2 | +
|
| 3 | + MIT License |
| 4 | +
|
| 5 | + Copyright (c) 2021 Looker Data Sciences, Inc. |
| 6 | +
|
| 7 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + of this software and associated documentation files (the "Software"), to deal |
| 9 | + in the Software without restriction, including without limitation the rights |
| 10 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + copies of the Software, and to permit persons to whom the Software is |
| 12 | + furnished to do so, subject to the following conditions: |
| 13 | +
|
| 14 | + The above copyright notice and this permission notice shall be included in all |
| 15 | + copies or substantial portions of the Software. |
| 16 | +
|
| 17 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | + SOFTWARE. |
| 24 | +
|
| 25 | + */ |
| 26 | + |
| 27 | +import { Story } from '@storybook/react/types-6-0' |
| 28 | +import React from 'react' |
| 29 | +import { AvatarIcon } from '../../Avatar' |
| 30 | +import { DataTable, DataTableProps, DataTableCell, DataTableItem } from '..' |
| 31 | + |
| 32 | +const data = [ |
| 33 | + { |
| 34 | + description: 'User', |
| 35 | + id: '1', |
| 36 | + indicator: <AvatarIcon color="key" icon="User" />, |
| 37 | + name: 'Gorgonzola', |
| 38 | + }, |
| 39 | + { |
| 40 | + description: 'User', |
| 41 | + id: '2', |
| 42 | + indicator: <AvatarIcon color="key" icon="User" />, |
| 43 | + name: 'Cheddar', |
| 44 | + }, |
| 45 | + { |
| 46 | + description: 'User', |
| 47 | + id: '3', |
| 48 | + indicator: <AvatarIcon color="key" icon="User" />, |
| 49 | + name: `Blue`, |
| 50 | + }, |
| 51 | +] |
| 52 | + |
| 53 | +const columns = [ |
| 54 | + { |
| 55 | + id: 'id', |
| 56 | + title: 'ID', |
| 57 | + }, |
| 58 | + { |
| 59 | + id: 'name', |
| 60 | + title: 'Name', |
| 61 | + }, |
| 62 | +] |
| 63 | + |
| 64 | +const items = data.map(({ description, id, indicator, name }) => ( |
| 65 | + <DataTableItem key={id} id={id}> |
| 66 | + <DataTableCell>{id}</DataTableCell> |
| 67 | + <DataTableCell indicator={indicator} description={description}> |
| 68 | + {name} |
| 69 | + </DataTableCell> |
| 70 | + </DataTableItem> |
| 71 | +)) |
| 72 | + |
| 73 | +const Template: Story<DataTableProps> = ({ ...args }) => { |
| 74 | + return <DataTable {...args} /> |
| 75 | +} |
| 76 | + |
| 77 | +export const Indicator = Template.bind({}) |
| 78 | +Indicator.args = { |
| 79 | + children: items, |
| 80 | + columns: columns, |
| 81 | +} |
0 commit comments