diff --git a/packages/sage-react/lib/Table/Table.story.jsx b/packages/sage-react/lib/Table/Table.story.jsx deleted file mode 100644 index befe35def6..0000000000 --- a/packages/sage-react/lib/Table/Table.story.jsx +++ /dev/null @@ -1,112 +0,0 @@ -import React from 'react'; -import { Panel } from '../Panel'; -import { Table } from './Table'; -import { dataCollection } from './sample-data/contacts'; -import { domains } from './sample-data/domains'; -import { selectArgs } from '../story-support/helpers'; -import { SageClassnames } from '../configs'; - -export default { - title: 'Sage/Table', - component: Table, - // displays description on Docs tab - parameters: { - docs: { - description: { - component: 'Basic table component.' - }, - }, - }, - argTypes: { - ...selectArgs({ - captionSide: Table.CAPTION_SIDE - }) - }, - args: { - headers: { - first: { - label: 'Header override' - } - }, - hasDataBeyondCurrentRows: false, - rows: dataCollection, - schema: { - id: false, - first: { - label: 'First name', - }, - email: false, - phone: { - label: 'Phone' - } - }, - showSelectAll: true, - selectAllConfigs: { - id: 'select-all', - name: 'select-all', - label: 'Select all items', - }, - // onSelectRowHook: (data) => { - // // Work with returned data set as needed. - // console.log(data); - // } - } -}; -const Template = (args) => ; - -export const Default = Template.bind({}); -Default.decorators = [ - (Story) => ( - <> - - {Story()} - -
-

NOTE: Wiring the select all checkbox requires the following:

- -
- - ) -]; - -export const TableWithRichContent = Template.bind({}); -TableWithRichContent.args = { - rows: domains, - schema: { - domain: { - label: 'Domain', - dataType: Table.DATA_TYPES.STRING, - }, - status: { - label: 'Status', - dataType: Table.DATA_TYPES.LABEL, - }, - options: { - label: '', - dataType: Table.DATA_TYPES.HTML, - }, - } -}; - -TableWithRichContent.decorators = [ - (Story) => ( - <> - - {Story()} - - - ) -]; diff --git a/packages/sage-react/lib/Table/Table.story.mdx b/packages/sage-react/lib/Table/Table.story.mdx new file mode 100644 index 0000000000..a5e90dcce3 --- /dev/null +++ b/packages/sage-react/lib/Table/Table.story.mdx @@ -0,0 +1,362 @@ +import { ArgsTable, Canvas, Meta, Source, Story } from '@storybook/addon-docs'; +import { selectArgs } from '../story-support/helpers'; + +import { dataCollection } from './sample-data/contacts'; +import { domains } from './sample-data/domains'; + +import { Table } from './Table'; + + + +# Table +Tables are a fundamental tool in web development and design, serving as a structured way to present tabular data. + +## Usage Guidelines + +### When to use +- Data that needs to be rendered in tabular format. +- Need to provide sorting, filtering, and/or pagination. + +### When not to use +- If your data does NOT need to be rendered with data columns. + +## Accessibility +Table component is built accessibly with native HTML in mind. + +## Properties + + + +## Variants +### Default + +export const DefaultTemplate = (args) =>
; + + +`}> + + { DefaultTemplate.bind({}) } + + + +### With Headers + + +`}> + + { DefaultTemplate.bind({}) } + + + +### Headers and Schemas +Should you provide both properties `headers` and `schemas` there are few things you will need to take into +consideration. + +1. `headers` can be passed an object. +2. The keys in `headers` should align with the key names in the `schema` +3. The headers will override the label specified in `schema`. + +Here is a table outlining the properties: + +|Property Name|Description| +|-----|-------| +|attributes|Additional HTML attributes you want to add.| +|className|The CSS Classname to be applied to the Table Header.| +|dataType|The Sage DataType for the Table Header.| +|label|The text content of the Table Header.| +|style|Additional styles to be applied.| + +Given the header and schema information, let's look at some examples. + +#### Header override + + + { DefaultTemplate.bind({}) } + + + +#### Schema Order +The order of the Schema determines the placement of the columns. + +With the given schema below, the order of the columns will be `Email, First, Phone`. `ID` will be ignored +since it is set to `false`. + + + +Data used can be in any order as the schema will determine the order. + + + +`}> + + { DefaultTemplate.bind({}) } + + + + +### With Rich Content +With the schema set and DataType specified to HTML, it will render the markup in the column. + + console.log('do something!')} + icon={SageTokens.ICONS.PEN} + iconOnly={true} + > + Edit + + ), + }, + { + domain: 'courses.daydreamsurfshop.com', + status: { + value: { + value: 'Connected', + color: Label.COLORS.SUCCESS, + }, + }, + options: ( + + ), + }, + ]} + schema={{ + domain: { + label: 'Domain', + dataType: Table.DATA_TYPES.STRING, + }, + status: { + label: 'Status', + dataType: Table.DATA_TYPES.LABEL, + }, + options: { + label: '', + dataType: Table.DATA_TYPES.HTML, + }, + } + }} /> +`}> + + { DefaultTemplate.bind({}) } + + +