diff --git a/.storybook/main.js b/.storybook/main.js index 3210ecc50..bbbd0804f 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -29,7 +29,8 @@ const config = { storyStoreV7: false }, docs: { - autodocs: "tag" + autodocs: "tag", + defaultName: 'Documentation', }, webpackFinal: async (config) => { return { diff --git a/client/src/components/ActionMenu/tests/ActionMenu-story.js b/client/src/components/ActionMenu/tests/ActionMenu-story.js index 90e50e186..23f9ff8a9 100644 --- a/client/src/components/ActionMenu/tests/ActionMenu-story.js +++ b/client/src/components/ActionMenu/tests/ActionMenu-story.js @@ -4,6 +4,22 @@ import { DropdownItem } from 'reactstrap'; export default { title: 'Admin/ActionMenu', + component: ActionMenu, + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: 'ActionMenu Component description.' + }, + canvas: { + sourceState: 'shown', + }, + controls: { + sort: 'alpha', + } + } + }, + argTypes: {} }; export const Single = () => ( diff --git a/client/src/components/Badge/tests/Badge-story.js b/client/src/components/Badge/tests/Badge-story.js index cee0e317d..394766c10 100644 --- a/client/src/components/Badge/tests/Badge-story.js +++ b/client/src/components/Badge/tests/Badge-story.js @@ -3,30 +3,60 @@ import { jsxDecorator } from 'storybook-addon-jsx'; import Badge, { statuses } from 'components/Badge/Badge'; export default { - title: 'Admin/Badges', + title: 'Admin/Badges/Badge', component: Badge, decorators: [ - jsxDecorator, - (Story) =>
+ jsxDecorator ], + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: 'Badge component for displaying a message in a Bootstrap "badge" style.' + }, + canvas: { + sourceState: 'shown', + }, + } + }, argTypes: { + message: { + description: 'The string to display in the badge.', + control: 'text', + }, status: { + description: "The status for the badge, takes bootstrap's values.", control: 'select', - options: statuses + options: statuses, + table: { + type: { summary: 'success, warning, danger, info, default' }, + defaultValue: { summary: 'default' }, + } }, inverted: { - control: 'boolean' + description: 'If the colours should be inverted.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + }, }, className: { + description: 'Any extra classes to apply for the badge.', control: 'inline-radio', options: { 'Empty class name': '', 'badge-pill class name': 'badge-pill' - } + }, + table: { + type: { summary: 'string' }, + defaultValue: { summary: 'badge-pill' }, + }, } } }; +/** Test message */ export const _Badge = { args: { message: 'Hello World!', diff --git a/client/src/components/Breadcrumb/tests/Breadcrumb-story.js b/client/src/components/Breadcrumb/tests/Breadcrumb-story.js index 8e36e4fab..b19d93482 100644 --- a/client/src/components/Breadcrumb/tests/Breadcrumb-story.js +++ b/client/src/components/Breadcrumb/tests/Breadcrumb-story.js @@ -63,25 +63,68 @@ export default { decorators: [ jsxDecorator ], + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: 'The breadcrumbs for the current section of the CMS.' + }, + canvas: { + sourceState: 'shown', + }, + controls: { + sort: 'alpha', + } + } + }, argTypes: { - levels: { + href: { + table: { + type: { summary: 'string' }, + } + }, + text: { + table: { + type: { summary: 'string' }, + } + }, + crumbs: { + description: 'An array of objects, each object should have a `text` and `href` key.', + table: { + type: { summary: 'array' }, + } + }, + level: { control: 'select', - options: levels + options: levels, + table: { + type: { summary: 'string' }, + }, }, - icons: { + icon: { + description: 'The font icon font name.', control: 'select', - options: icons + options: icons, + table: { + type: { summary: 'string' }, + }, + }, + icons: { + description: 'Array of icons', + table: { + type: { summary: 'array' }, + }, }, }, args: { - levels: 'First', - icons: '' + level: 'First', + icon: '' } }; export const _Breadcrumb = (args) => { // eslint-disable-next-line no-shadow - const { levels, icons } = args; - return (); + const { level, icon } = args; + return (); }; diff --git a/client/src/components/Button/tests/BackButton-story.js b/client/src/components/Button/tests/BackButton-story.js new file mode 100644 index 000000000..64064f0e0 --- /dev/null +++ b/client/src/components/Button/tests/BackButton-story.js @@ -0,0 +1,80 @@ +import React from 'react'; +import { jsxDecorator } from 'storybook-addon-jsx'; +import { action } from '@storybook/addon-actions'; +import BackButton from '../BackButton'; + +const colors = [ + 'primary', + 'secondary', + 'success', + 'info', + 'warning', + 'danger', + 'link', +]; +const sizes = ['sm', 'md', 'lg']; +const icons = [ + '', + 'search', + 'sync', + 'plus-circled', + 'cancel-circled', + 'check-mark', + 'edit', +]; + +const onClick = (event) => { + event.preventDefault(); + return action('onClick')(event); +}; +onClick.toString = () => 'onClick'; + +export default { + title: 'Admin/Buttons/BackButton', + component: BackButton, + decorators: [ + jsxDecorator + ], + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: 'Generic Button component to allow users to return to a preview view. It displays a `<` icon and has an appropriate `aria-label.' + }, + canvas: { + sourceState: 'shown', + }, + controls: { + sort: 'alpha', + } + } + }, + argTypes: { + children: { + description: "If present, any nested content inside the button will apply to the `aria-label` attribute. Otherwise, the localised string 'Back' will be used.", + control: 'text', + table: { + type: { summary: 'string' }, + }, + }, + className: { + control: 'text', + table: { + type: { summary: 'string' }, + } + }, + onClick: { + action: 'clicked', + table: { + type: { summary: 'function' }, + } + } + } +}; + +export const _BackButton = (args) => ; +_BackButton.args = { + onClick, + className: '', + children: 'Back' +}; diff --git a/client/src/components/Button/tests/Button-story.js b/client/src/components/Button/tests/Button-story.js index 9738d2ef2..c6d71b489 100644 --- a/client/src/components/Button/tests/Button-story.js +++ b/client/src/components/Button/tests/Button-story.js @@ -2,7 +2,6 @@ import React from 'react'; import { jsxDecorator } from 'storybook-addon-jsx'; import { action } from '@storybook/addon-actions'; import Button from '../Button'; -import BackButton from '../BackButton'; const colors = [ 'primary', @@ -31,69 +30,126 @@ const onClick = (event) => { onClick.toString = () => 'onClick'; export default { - title: 'Admin/Button', + title: 'Admin/Buttons/Button', component: Button, decorators: [ - jsxDecorator, - (Story) =>
+ jsxDecorator ], + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: `The Button wraps a regular [Reactstrap Button](https://reactstrap.github.io/components/buttons/) + component with a few Silverstripe-specific convenience props. All the regular Reactstrap props are also available.` + }, + canvas: { + sourceState: 'shown', + }, + controls: { + sort: 'alpha', + } + } + }, + argTypes: { color: { + description: 'Predefined style to apply to the button: `success`, `warning`, `danger`, `info`, `default`.', control: 'select', - options: colors + options: colors, + table: { + type: { summary: 'string' }, + defaultValue: { summary: 'default' }, + } }, size: { + description: 'Make the button smaller or larger. Acceptable values include `sm`, `md` and `lg`.', control: 'select', - options: sizes + options: sizes, + table: { + type: { summary: 'string' }, + defaultValue: { summary: 'md' }, + } }, icon: { + description: 'A valid icon name to display in the button.', control: 'select', options: icons }, outline: { - control: 'boolean' + description: 'Render the button border with a transparent background.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + } }, block: { - control: 'boolean' + description: 'Display the button as a block taking the full width of its container.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + } }, active: { - control: 'boolean' + description: 'Render the button in an active state. Useful for toggle buttons.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + } }, disabled: { - control: 'boolean' + description: 'Prevent the user from interacting with the button.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + } }, noText: { - control: 'boolean' + description: 'Hide the button text and display it as an `aria-label` instead. This should be use in conjunction with `icon` otherise your button will be empty.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + } }, className: { - control: 'text' + control: 'text', + table: { + type: { summary: 'string' }, + defaultValue: { summary: '' }, + } }, children: { - control: 'text' + control: 'text', + table: { + type: { summary: 'string' }, + defaultValue: { summary: '' }, + } }, - onClick: { action: 'clicked' } + onClick: { + action: 'clicked', + table: { + type: { summary: 'function' }, + } + } } }; -export const _Button = { - args: { - color: 'primary', - size: 'md', - icon: '', - outline: false, - block: false, - active: false, - disabled: false, - noText: false, - onClick, - className: '', - children: 'click me' - } -}; - -export const _BackButton = (args) => (); -_BackButton.args = { +export const _Button = (args) =>