-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from creative-commoners/pulls/3/storybook-docs
ENH Storybook documentation
- Loading branch information
Showing
1 changed file
with
101 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,110 @@ | ||
import React from 'react'; | ||
import TagField from 'components/TagField'; | ||
import { Title, Subtitle, Description, Primary, Controls, Stories } from '@storybook/blocks'; | ||
|
||
export default { | ||
title: 'TagField/TagField', | ||
const options = [ | ||
{ Title: 'One', Value: 1 }, | ||
{ Title: 'Two', Value: 2 }, | ||
{ Title: 'Three', Value: 3 }, | ||
{ Title: 'Four', Value: 4 }, | ||
{ Title: 'Five', Value: 5 }, | ||
]; | ||
|
||
decorators: [ | ||
(storyFn) => ( | ||
<div style={{ width: '250px' }} className="ss-tag-field"> | ||
{storyFn()} | ||
</div> | ||
), | ||
], | ||
export default { | ||
title: 'TagField/TagField', | ||
component: TagField, | ||
decorators: [], | ||
tags: ['autodocs'], | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: 'The Tag Field component.' | ||
}, | ||
canvas: { | ||
sourceState: 'shown', | ||
}, | ||
} | ||
}, | ||
argTypes: { | ||
name: { | ||
control: 'text', | ||
table: { | ||
type: { summary: 'string' }, | ||
defaultValue: { summary: null }, | ||
}, | ||
}, | ||
options: { | ||
description: 'List of tags options', | ||
control: 'select', | ||
table: { | ||
type: { summary: 'string' }, | ||
}, | ||
}, | ||
labelKey: { | ||
control: 'text', | ||
table: { | ||
type: { summary: 'string' }, | ||
defaultValue: { summary: 'Title' }, | ||
}, | ||
}, | ||
valueKey: { | ||
control: 'text', | ||
table: { | ||
type: { summary: 'string' }, | ||
defaultValue: { summary: 'Value' }, | ||
}, | ||
}, | ||
lazyLoad: { | ||
control: 'boolean', | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
}, | ||
creatable: { | ||
control: 'boolean', | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
}, | ||
multi: { | ||
control: 'boolean', | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
}, | ||
disabled: { | ||
control: 'boolean', | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
}, | ||
optionUrl: { | ||
control: 'text', | ||
table: { | ||
type: { summary: 'string' }, | ||
defaultValue: { summary: null }, | ||
}, | ||
}, | ||
}, | ||
args: { | ||
name: 'Test', | ||
options | ||
} | ||
}; | ||
|
||
export const SimpleExample = () => ( | ||
<TagField | ||
name="test" | ||
options={[ | ||
{ Title: 'One', Value: 1 }, | ||
{ Title: 'Two', Value: 2 }, | ||
{ Title: 'Three', Value: 3 }, | ||
{ Title: 'Four', Value: 4 }, | ||
{ Title: 'Five', Value: 5 }, | ||
]} | ||
/> | ||
export const SimpleExample = (args) => ( | ||
<TagField | ||
{...args} | ||
/> | ||
); | ||
|
||
export const MultipleSelection = () => ( | ||
<TagField | ||
name="test" | ||
multi | ||
options={[ | ||
{ Title: 'One', Value: 1 }, | ||
{ Title: 'Two', Value: 2 }, | ||
{ Title: 'Three', Value: 3 }, | ||
{ Title: 'Four', Value: 4 }, | ||
{ Title: 'Five', Value: 5 }, | ||
]} | ||
/> | ||
export const MultipleSelection = (args) => ( | ||
<TagField | ||
{...args} | ||
multi | ||
/> | ||
); |