import { ComponentStory, ComponentMeta } from '@storybook/react'; import { Table } from './Table'; import { Fragment } from 'react'; import TableRow from '@mui/material/TableRow'; import { TableCell } from '@mui/material'; import css from './Table.module.scss'; import { HeaderProps } from './HeaderCell/HeaderCell'; export default { title: 'Components/Table', component: Table, parameters: { docs: { iframeHeight: '400px' } } } as ComponentMeta; // Set up dummy data and columns const dummyData = [ { name: 'first row', description: 'this is the first row' }, { name: 'second row', description: 'this is the second row' }, { name: 'third row', description: 'this is the third row' } ]; const columns = [ { title: 'Name', key: 'name' }, { title: 'Description', key: 'description' } ]; const headerMapping: Map<'name' | 'description', string> = new Map(); headerMapping.set('name', 'name'); headerMapping.set('description', 'description'); const tableHeaders: HeaderProps[] = []; for (let i = 0; i < columns.length; i++) { tableHeaders.push({ label: Array.from(headerMapping.keys())[i] }); } const Template: ComponentStory = (args) => ; export const DefaultTable = Template.bind({}); DefaultTable.args = { headers: tableHeaders, headermapping: headerMapping, rowcount: dummyData.length, labels: { labelPaginationOf: 'of', labelRowsPerPage: 'Rows per page', searchplaceholderlabel: 'Search', tooltiplabel: 'Sort' }, tableqas: { header: 'table-header', headerRow: 'table-header-row', pagination: 'table-pagination', table: 'table', toolbar: 'table-toolbar', headerCell: 'table-header-cell', tableBody: 'table-body' }, tablecss: { tableToolbar: [css.projectTableToolbar], tablePagination: [css.projectTablePagination], table: [css.projectTable] }, tablebodycontent: ( {dummyData.map((row: any, rIndex: number) => { return ( {row.name} {row.description} ); })} ) };