Unverified Commit 6af0e138 authored by Marcos Iglesias's avatar Marcos Iglesias Committed by GitHub

docs: Adding knobs to Table and SVG Icons (#698)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent 36aebd28
...@@ -4,7 +4,11 @@ import devWebpackConfig from '../webpack.dev'; ...@@ -4,7 +4,11 @@ import devWebpackConfig from '../webpack.dev';
module.exports = { module.exports = {
stories: ['../js/**/*.story.tsx'], stories: ['../js/**/*.story.tsx'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'], addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs'
],
webpackFinal: async (config) => { webpackFinal: async (config) => {
return merge(devWebpackConfig, config); return merge(devWebpackConfig, config);
}, },
......
...@@ -2,26 +2,40 @@ ...@@ -2,26 +2,40 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import React from 'react'; import React from 'react';
import { storiesOf } from '@storybook/react'; import { withKnobs, object } from '@storybook/addon-knobs';
import StorySection from '../StorySection'; import StorySection from '../StorySection';
import { AlertIcon, DownIcon, UpIcon, RightIcon } from '.'; import { AlertIcon, DownIcon, UpIcon, RightIcon } from '.';
const stories = storiesOf('Attributes/Iconography', module); export const SVGIcons = () => (
stories.add('SVG Icons', () => (
<> <>
<StorySection title="Alert"> <StorySection title="Alert">
<AlertIcon /> <AlertIcon stroke={object('Alert stroke', 'currentColor')} />
</StorySection> </StorySection>
<StorySection title="Down"> <StorySection title="Down">
<DownIcon /> <DownIcon
stroke={object('DownIcon stroke', 'currentColor')}
fill={object('DownIcon fill', '#9191A8')}
/>
</StorySection> </StorySection>
<StorySection title="Up"> <StorySection title="Up">
<UpIcon /> <UpIcon
stroke={object('UpIcon stroke', 'currentColor')}
fill={object('UpIcon fill', '#9191A8')}
/>
</StorySection> </StorySection>
<StorySection title="Right"> <StorySection title="Right">
<RightIcon /> <RightIcon
stroke={object('RightIcon stroke', 'currentColor')}
fill={object('RightIcon fill', '#9191A8')}
/>
</StorySection> </StorySection>
</> </>
)); );
SVGIcons.storyName = 'SVG Icons';
export default {
title: 'Attributes/Iconography',
component: AlertIcon,
decorators: [withKnobs],
};
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import React from 'react'; import React from 'react';
import { storiesOf } from '@storybook/react'; import { withKnobs, object } from '@storybook/addon-knobs';
import StorySection from '../StorySection'; import StorySection from '../StorySection';
import Table from '.'; import Table from '.';
...@@ -39,60 +39,80 @@ const expandRowComponent = (rowValue, index) => ( ...@@ -39,60 +39,80 @@ const expandRowComponent = (rowValue, index) => (
</strong> </strong>
); );
const stories = storiesOf('Components/Table', module); // const stories = storiesOf('Components/Table', module);
stories.add('Table States', () => ( export const TableStates = () => (
<> <>
<StorySection title="Basic Table"> <StorySection title="Basic Table">
<Table columns={columns} data={data} /> <Table
columns={object('basic table columns', columns)}
data={object('basic table data', data)}
/>
</StorySection> </StorySection>
<StorySection title="Empty Table"> <StorySection title="Empty Table">
<Table columns={columns} data={[]} /> <Table
columns={object('empty table columns', columns)}
data={object('empty table data', [])}
/>
</StorySection> </StorySection>
<StorySection title="Loading Table"> <StorySection title="Loading Table">
<Table columns={[]} data={[]} options={{ isLoading: true }} /> <Table
columns={[]}
data={[]}
options={object('options', { isLoading: true })}
/>
</StorySection> </StorySection>
</> </>
)); );
stories.add('Styled Table', () => ( export const StyledTable = () => (
<> <>
<StorySection title="with different column alignment"> <StorySection title="with different column alignment">
<Table columns={alignedColumns} data={alignedData} /> <Table
columns={object('aligned columns', alignedColumns)}
data={object('aligned columns data', alignedData)}
/>
</StorySection> </StorySection>
<StorySection title="with 50px row height"> <StorySection title="with 50px row height">
<Table columns={columns} data={data} options={{ rowHeight: 50 }} /> <Table
columns={columns}
data={data}
options={object('row height options', { rowHeight: 50 })}
/>
</StorySection> </StorySection>
<StorySection title="with different column widths"> <StorySection title="with different column widths">
<Table <Table
columns={differentWidthColumns} columns={object(
'different column widths columns',
differentWidthColumns
)}
data={data} data={data}
options={{ rowHeight: 50 }} options={{ rowHeight: 50 }}
/> />
</StorySection> </StorySection>
</> </>
)); );
stories.add('Customized Table', () => ( export const CustomizedTable = () => (
<> <>
<StorySection title="with custom column components"> <StorySection title="with custom column components">
<Table <Table
columns={customColumns} columns={object('custom component columns', customColumns)}
data={customColumnsData} data={object('custom component data', customColumnsData)}
options={{ rowHeight: 40 }} options={{ rowHeight: 40 }}
/> />
</StorySection> </StorySection>
<StorySection title="with multiple custom column components"> <StorySection title="with multiple custom column components">
<Table <Table
columns={multipleCustomColumns} columns={object('multiple component columns', multipleCustomColumns)}
data={multipleCustomComlumnsData} data={object('multiple component data', multipleCustomComlumnsData)}
options={{ rowHeight: 40 }} options={{ rowHeight: 40 }}
/> />
</StorySection> </StorySection>
<StorySection title="with Bootstrap dropdown as component"> <StorySection title="with Bootstrap dropdown as component">
<Table <Table
columns={columnsWithAction} columns={object('action columns', columnsWithAction)}
data={dataWithAction} data={object('action data', dataWithAction)}
options={{ rowHeight: 40 }} options={{ rowHeight: 40 }}
/> />
</StorySection> </StorySection>
...@@ -100,19 +120,24 @@ stories.add('Customized Table', () => ( ...@@ -100,19 +120,24 @@ stories.add('Customized Table', () => (
<Table <Table
columns={columns} columns={columns}
data={[]} data={[]}
options={{ emptyMessage: 'Custom Empty Message Here!' }} options={object('empty message options', {
emptyMessage: 'Custom Empty Message Here!',
})}
/> />
</StorySection> </StorySection>
</> </>
)); );
stories.add('Collapsible Table', () => ( export const CollapsibleTable = () => (
<> <>
<StorySection title="with Collapsed Rows"> <StorySection title="with Collapsed Rows">
<Table <Table
columns={columnsWithCollapsedRow} columns={object('collapsed rows columns', columnsWithCollapsedRow)}
data={dataWithCollapsedRow} data={object('collapsed rows data', dataWithCollapsedRow)}
options={{ rowHeight: 40, expandRow: expandRowComponent }} options={object('collapsed rows options', {
rowHeight: 40,
expandRow: expandRowComponent,
})}
/> />
</StorySection> </StorySection>
<StorySection <StorySection
...@@ -122,14 +147,14 @@ stories.add('Collapsible Table', () => ( ...@@ -122,14 +147,14 @@ stories.add('Collapsible Table', () => (
<Table <Table
columns={columnsWithCollapsedRow} columns={columnsWithCollapsedRow}
data={dataWithCollapsedRow} data={dataWithCollapsedRow}
options={{ options={object('onExpand options', {
rowHeight: 40, rowHeight: 40,
expandRow: expandRowComponent, expandRow: expandRowComponent,
onExpand: (rowValues, index) => { onExpand: (rowValues, index) => {
console.log('Expanded row values:', rowValues); console.log('Expanded row values:', rowValues);
console.log('Expanded row index:', index); console.log('Expanded row index:', index);
}, },
}} })}
/> />
</StorySection> </StorySection>
<StorySection <StorySection
...@@ -139,15 +164,21 @@ stories.add('Collapsible Table', () => ( ...@@ -139,15 +164,21 @@ stories.add('Collapsible Table', () => (
<Table <Table
columns={columnsWithCollapsedRow} columns={columnsWithCollapsedRow}
data={dataWithCollapsedRow} data={dataWithCollapsedRow}
options={{ options={object('onCollapse options', {
rowHeight: 40, rowHeight: 40,
expandRow: expandRowComponent, expandRow: expandRowComponent,
onCollapse: (rowValues, index) => { onCollapse: (rowValues, index) => {
console.log('Collapsed row values:', rowValues); console.log('Collapsed row values:', rowValues);
console.log('Collapsed row index:', index); console.log('Collapsed row index:', index);
}, },
}} })}
/> />
</StorySection> </StorySection>
</> </>
)); );
export default {
title: 'Components/Table',
component: Table,
decorators: [withKnobs],
};
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
"@types/react-redux": "^6.0.14", "@types/react-redux": "^6.0.14",
"@types/react-router": "^4.4.5", "@types/react-router": "^4.4.5",
"@types/react-tagsinput": "^3.19.7", "@types/react-tagsinput": "^3.19.7",
"@types/storybook__addon-knobs": "^5.2.1",
"@types/webpack": "^4.41.12", "@types/webpack": "^4.41.12",
"@typescript-eslint/eslint-plugin": "^3.9.0", "@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/eslint-plugin-tslint": "^3.1.0", "@typescript-eslint/eslint-plugin-tslint": "^3.1.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment