diff --git a/packages/braid-design-system/src/lib/components/Table/Table.snippets.tsx b/packages/braid-design-system/src/lib/components/Table/Table.snippets.tsx index 387a99543bf..378ad3b6c97 100644 --- a/packages/braid-design-system/src/lib/components/Table/Table.snippets.tsx +++ b/packages/braid-design-system/src/lib/components/Table/Table.snippets.tsx @@ -11,29 +11,32 @@ import { Badge, ButtonIcon, MenuRenderer, + MenuItem, IconOverflow, + Stack, } from '../../playroom/components'; import source from '@braid-design-system/source.macro'; -import { MenuItem } from '../MenuItem/MenuItem'; -import { Stack } from '../Stack/Stack'; -import { stripTypeAnyFromCode } from './stripTypeAnyFromCode'; -const state = new Map(); - -function setDefaultState(name: string, data: unknown) { - state.set(name, data); -} - -function getState(name: string) { - return state.get(name); -} export const snippets: Snippets = [ { name: 'Basic', - code: stripTypeAnyFromCode( - source( - <> - {setDefaultState('basicRowData', [ + code: source( + + + + + Lorem + + + Ipsum + + + Dolor + + + + + {[ { column1: 'Sit', column2: 'Amet', @@ -49,47 +52,48 @@ export const snippets: Snippets = [ column2: 'Interdum', column3: 'Viverra', }, - ])} -
- - - - Lorem - - - Ipsum - - - Dolor - - - - - {getState('basicRowData').map((row: any) => ( - - - {row.column1} - - - {row.column2} - - - {row.column3} - - - ))} - -
- , - ), + ].map((row) => ( + + + {row.column1} + + + {row.column2} + + + {row.column3} + + + ))} + + , ), }, { name: 'With status and actions columns', - code: stripTypeAnyFromCode( - source( - <> - {setDefaultState('statusAndActionsData', [ + code: source( + + + + + Status + + + Data + + + Data + + + Data + + + Actions + + + + + {[ { status: 'Lorem', column1: 'Sit', @@ -108,75 +112,64 @@ export const snippets: Snippets = [ column2: 'Interdum', column3: 'Viverra', }, - ])} -
- - - - Status - - - Data - - - Data - - - Data - - - Actions - - - - - {getState('statusAndActionsData').map((row: any) => ( - - - {row.status} - - - {row.column1} - - - {row.column2} - - - {row.column3} - - - ( - } - label="Options" - size="small" - variant="transparent" - id={`options-${row.column1}`} - {...triggerProps} - /> - )} - > - {}}>Button - {}}>Button - - - - ))} - -
- , - ), + ].map((row) => ( + + + {row.status} + + + {row.column1} + + + {row.column2} + + + {row.column3} + + + ( + } + label="Options" + size="small" + variant="transparent" + id={`options-${row.column1}`} + {...triggerProps} + /> + )} + > + {}}>Button + {}}>Button + + + + ))} + + , ), }, { name: 'With multi-line cell data and actions', - code: stripTypeAnyFromCode( - source( - <> - {setDefaultState('multiLineDataCell', [ + code: source( + + + + + Data + + + Data + + + Actions + + + + + {[ { line1: 'Sit', line2: 'Amet', @@ -192,58 +185,40 @@ export const snippets: Snippets = [ line2: 'Interdum', column2: 'Viverra', }, - ])} -
- - - - Data - - - Data - - - Actions - - - - - {getState('multiLineDataCell').map((row: any) => ( - - - - {row.line1} - {row.line2} - - - - {row.column2} - - - ( - } - label="Options" - size="small" - variant="transparent" - id={`options-${row.line1}`} - {...triggerProps} - /> - )} - > - {}}>Button - {}}>Button - - - - ))} - -
- , - ), + ].map((row) => ( + + + + {row.line1} + {row.line2} + + + + {row.column2} + + + ( + } + label="Options" + size="small" + variant="transparent" + id={`options-${row.line1}`} + {...triggerProps} + /> + )} + > + {}}>Button + {}}>Button + + + + ))} + + , ), }, ]; diff --git a/packages/braid-design-system/src/lib/playroom/snippets.ts b/packages/braid-design-system/src/lib/playroom/snippets.ts index c1a4012c071..8e1a1802dad 100644 --- a/packages/braid-design-system/src/lib/playroom/snippets.ts +++ b/packages/braid-design-system/src/lib/playroom/snippets.ts @@ -35,6 +35,7 @@ import { snippets as Spread } from './snippets/Spread'; import { snippets as Stack } from './snippets/Stack'; import { snippets as Stepper } from './snippets/Stepper'; import { snippets as Strong } from './snippets/Strong'; +import { snippets as Table } from './snippets/Table'; import { snippets as Tabs } from './snippets/Tabs'; import { snippets as Tag } from './snippets/Tag'; import { snippets as Text } from './snippets/Text'; @@ -84,6 +85,7 @@ export default Object.entries({ Stack, Stepper, Strong, + Table, Tabs, Tag, Text,