From 3f33d6a9f8d9286dda43364b5a03e96f8d33d4cb Mon Sep 17 00:00:00 2001 From: guidari Date: Wed, 4 Dec 2024 16:55:54 -0300 Subject: [PATCH 1/9] feat: converted all stories from Playground to Default --- .../components/Accordion/Accordion.stories.js | 143 +++--- .../AspectRatio/AspectRatio.stories.js | 35 +- .../Breadcrumb/Breadcrumb.stories.js | 43 +- .../components/Checkbox/Checkbox.stories.js | 262 +++++----- .../components/ComboBox/ComboBox.stories.js | 217 ++++---- .../ComboButton/ComboButton.stories.js | 106 ++-- .../ComposedModal/ComposedModal.stories.js | 125 ++--- .../ContainedList/ContainedList.stories.js | 49 +- .../ContentSwitcher/ContentSwitcher.mdx | 2 +- .../ContentSwitcher.stories.js | 71 +-- .../src/components/CopyButton/CopyButton.mdx | 2 +- .../CopyButton/CopyButton.stories.js | 6 +- .../stories/DataTable-ai-label.stories.js | 79 ++- .../stories/DataTable-basic.stories.js | 185 ++----- .../DataTable-batch-actions.stories.js | 124 +---- .../stories/DataTable-filtering.stories.js | 97 +--- .../stories/DataTable-selection.stories.js | 141 ++--- .../stories/DataTable-sorting.stories.js | 33 +- .../stories/DataTable-toolbar.stories.js | 115 ++--- .../DataTable-dynamic-content.stories.js | 183 +------ .../expansion/DataTable-expansion.stories.js | 83 +-- .../DataTableSkeleton.stories.js | 17 +- .../src/components/DatePicker/DatePicker.mdx | 2 +- .../DatePicker/DatePicker.stories.js | 318 +++++++----- .../components/Dropdown/Dropdown.stories.js | 99 ++-- .../FileUploader/FileUploader.stories.js | 26 +- .../FluidComboBox/FluidComboBox.stories.js | 202 ++++---- .../FluidDatePicker.stories.js | 233 ++++----- .../FluidDropdown/FluidDropdown.stories.js | 198 ++++--- .../FluidMultiSelect.stories.js | 215 ++++---- .../FluidNumberInput.stories.js | 74 +-- .../FluidSearch/FluidSearch.stories.js | 24 +- .../FluidSelect/FluidSelect.stories.js | 161 +++--- .../FluidTextArea/FluidTextArea.stories.js | 134 +++-- .../FluidPasswordInput.stories.js | 20 +- .../FluidTextInput/FluidTextInput.stories.js | 48 +- .../FluidTimePicker.stories.js | 101 +--- .../components/FormGroup/FormGroup.stories.js | 24 +- .../src/components/Grid/FlexGrid.stories.js | 6 +- .../react/src/components/Grid/Grid.stories.js | 97 ++-- .../IconButton/IconButton.stories.js | 16 +- .../src/components/Icons/Icons.stories.js | 32 +- .../InlineLoading/InlineLoading.stories.js | 14 +- .../src/components/Layer/Layer.stories.js | 22 +- .../react/src/components/Link/Link.stories.js | 19 +- .../src/components/Loading/Loading.stories.js | 10 +- .../react/src/components/Menu/Menu.stories.js | 6 +- .../MenuButton/MenuButton.stories.js | 106 ++-- .../src/components/Modal/Modal.stories.js | 481 +++++++----------- .../MultiSelect/MultiSelect.stories.js | 63 +-- .../stories/ActionableNotification.stories.js | 22 +- .../stories/InlineNotification.stories.js | 13 +- .../stories/ToastNotification.stories.js | 16 +- .../components/NumberInput/NumberInput.mdx | 2 +- .../NumberInput/NumberInput.stories.js | 159 +++--- .../components/OrderedList/OrderedList.mdx | 2 +- .../OrderedList/OrderedList.stories.js | 90 ++-- .../OverflowMenu/OverflowMenu.stories.js | 17 +- .../Pagination/Pagination.stories.js | 104 ++-- .../PaginationNav/PaginationNav.stories.js | 12 +- .../src/components/Popover/Popover.stories.js | 78 +-- .../ProgressBar/ProgressBar.stories.js | 15 +- .../ProgressIndicator.stories.js | 37 +- .../RadioButton/RadioButton.stories.js | 31 +- .../src/components/Search/Search.stories.js | 26 +- .../src/components/Select/Select.stories.js | 55 +- .../react/src/components/Slider/Slider.mdx | 4 +- .../src/components/Slider/Slider.stories.js | 271 +++++----- .../react/src/components/Tabs/Tabs.stories.js | 137 ++--- .../components/TextArea/TextArea.stories.js | 138 ++--- .../TextInput/PasswordInput.stories.js | 21 +- .../components/TextInput/TextInput.stories.js | 202 ++++---- .../TimePicker/TimePicker.stories.js | 55 +- .../src/components/Toggle/Toggle.stories.js | 36 +- .../components/Toggletip/Toggletip.stories.js | 61 +-- .../Tooltip/DefinitionTooltip.stories.js | 19 +- .../src/components/Tooltip/Tooltip.stories.js | 98 ++-- .../components/TreeView/Treeview.stories.js | 38 +- 78 files changed, 2636 insertions(+), 3992 deletions(-) diff --git a/packages/react/src/components/Accordion/Accordion.stories.js b/packages/react/src/components/Accordion/Accordion.stories.js index 85ac311d7976..822fbb5e948a 100644 --- a/packages/react/src/components/Accordion/Accordion.stories.js +++ b/packages/react/src/components/Accordion/Accordion.stories.js @@ -29,8 +29,35 @@ export default { }, }; -export const Default = () => ( - +const sharedArgTypes = { + align: { + options: ['start', 'end'], + control: { type: 'select' }, + }, + children: { + control: false, + }, + className: { + control: false, + }, + disabled: { + control: { + type: 'boolean', + }, + }, + isFlush: { + control: { + type: 'boolean', + }, + }, + size: { + options: ['sm', 'md', 'lg'], + control: { type: 'select' }, + }, +}; + +export const Default = (args) => ( +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod @@ -48,14 +75,14 @@ export const Default = () => (

-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim - veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea - commodo consequat. -

+
- + + Section 4 title (the title can be a node) + + }>

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim @@ -66,7 +93,14 @@ export const Default = () => ( ); -export const Controlled = () => { +Default.args = { + disabled: false, + isFlush: false, +}; + +Default.argTypes = { ...sharedArgTypes }; + +export const Controlled = (args) => { const [expandAll, setExpandAll] = React.useState(false); return ( <> @@ -89,7 +123,7 @@ export const Controlled = () => { - +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do @@ -127,8 +161,15 @@ export const Controlled = () => { ); }; -export const _WithLayer = () => ( - +Controlled.args = { + disabled: false, + isFlush: false, +}; + +Controlled.argTypes = { ...sharedArgTypes }; + +export const _WithLayer = (args) => ( +

@@ -166,6 +207,13 @@ export const _WithLayer = () => ( ); +WithLayer.args = { + disabled: false, + isFlush: false, +}; + +WithLayer.argTypes = { ...sharedArgTypes }; + export const Skeleton = (args) => ( ); @@ -174,75 +222,6 @@ Skeleton.decorators = [ (story) =>

{story()}
, ]; -export const Playground = (args) => ( - - -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim - veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea - commodo consequat. -

-
- -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim - veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea - commodo consequat. -

-
- - - - - Section 4 title (the title can be a node) - - }> -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim - veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea - commodo consequat. -

-
-
-); - -Playground.args = { - disabled: false, - isFlush: false, -}; - -Playground.argTypes = { - align: { - options: ['start', 'end'], - control: { type: 'select' }, - }, - children: { - control: false, - }, - className: { - control: false, - }, - disabled: { - control: { - type: 'boolean', - }, - }, - isFlush: { - control: { - type: 'boolean', - }, - }, - size: { - options: ['sm', 'md', 'lg'], - control: { type: 'select' }, - }, -}; - Skeleton.args = { isFlush: false, }; diff --git a/packages/react/src/components/AspectRatio/AspectRatio.stories.js b/packages/react/src/components/AspectRatio/AspectRatio.stories.js index 3b79039d16fd..05fec5396137 100644 --- a/packages/react/src/components/AspectRatio/AspectRatio.stories.js +++ b/packages/react/src/components/AspectRatio/AspectRatio.stories.js @@ -29,26 +29,7 @@ export default { }, }; -export const Default = () => { - return ( - - - Content - - - Content - - - Content - - - Content - - - ); -}; - -export const Playground = { +export const Default = { render: ({ ratio, ...args }) => { return ( @@ -69,21 +50,15 @@ export const Playground = { }, }; -Playground.argTypes = { +Default.argTypes = { as: { - table: { - disable: true, - }, + control: false, }, children: { - table: { - disable: true, - }, + control: false, }, className: { - table: { - disable: true, - }, + control: false, }, ratio: { control: { diff --git a/packages/react/src/components/Breadcrumb/Breadcrumb.stories.js b/packages/react/src/components/Breadcrumb/Breadcrumb.stories.js index d1605545a3f7..5bf74f259764 100644 --- a/packages/react/src/components/Breadcrumb/Breadcrumb.stories.js +++ b/packages/react/src/components/Breadcrumb/Breadcrumb.stories.js @@ -27,8 +27,16 @@ export default { }, }; -export const Default = () => ( - +const sharedArgTypes = { + children: { + table: { + disable: true, + }, + }, +}; + +export const Default = (args) => ( + Breadcrumb 1 @@ -38,8 +46,12 @@ export const Default = () => ( ); -export const BreadcrumbWithOverflowMenu = () => ( - +Default.argTypes = { + ...sharedArgTypes, +}; + +export const BreadcrumbWithOverflowMenu = (args) => ( + Breadcrumb 1 @@ -55,23 +67,8 @@ export const BreadcrumbWithOverflowMenu = () => ( ); -export const Skeleton = () => ; - -export const Playground = (args) => ( - - - Breadcrumb 1 - - Breadcrumb 2 - Breadcrumb 3 - Breadcrumb 4 - -); - -Playground.argTypes = { - children: { - table: { - disable: true, - }, - }, +BreadcrumbWithOverflowMenu.argTypes = { + ...sharedArgTypes, }; + +export const Skeleton = () => ; diff --git a/packages/react/src/components/Checkbox/Checkbox.stories.js b/packages/react/src/components/Checkbox/Checkbox.stories.js index 1c6da060394c..252cd3aae4fd 100644 --- a/packages/react/src/components/Checkbox/Checkbox.stories.js +++ b/packages/react/src/components/Checkbox/Checkbox.stories.js @@ -39,21 +39,139 @@ export default { }, }; -export const Default = () => { - return ( - - - - - ); +const sharedArgs = { + helperText: 'Helper text goes here', + invalid: false, + invalidText: 'Invalid message goes here', + readOnly: false, + warn: false, + warnText: 'Warning message goes here', +}; + +const sharedArgTypes = { + helperText: { + description: 'Provide text for the form group for additional help', + control: { + type: 'text', + }, + }, + invalid: { + description: 'Specify whether the form group is currently invalid', + control: { + type: 'boolean', + }, + }, + invalidText: { + description: + 'Provide the text that is displayed when the form group is in an invalid state', + control: { + type: 'text', + }, + }, + legendText: { + description: + 'Provide the text to be rendered inside of the fieldset ', + control: { + type: 'text', + }, + }, + readOnly: { + description: 'Specify whether the CheckboxGroup is read-only', + control: { + type: 'boolean', + }, + }, + warn: { + description: 'Specify whether the form group is currently in warning state', + control: { + type: 'boolean', + }, + }, + warnText: { + description: + 'Provide the text that is displayed when the form group is in warning state', + control: { + type: 'text', + }, + }, + checked: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + defaultChecked: { + table: { + disable: true, + }, + }, + hideLabel: { + table: { + disable: true, + }, + }, + id: { + table: { + disable: true, + }, + }, + indeterminate: { + table: { + disable: true, + }, + }, + labelText: { + table: { + disable: true, + }, + }, + onChange: { + table: { + disable: true, + }, + }, + title: { + table: { + disable: true, + }, + }, + orientation: { + description: 'Provide how checkbox should be displayed', + control: 'select', + options: ['horizontal', 'vertical'], + }, +}; + +export const Default = (args) => ( + + + + + +); + +Default.args = { + ...sharedArgs, }; -export const Horizontal = () => { +Default.argTypes = { ...sharedArgTypes }; + +export const Horizontal = (args) => { return ( + helperText="Helper text goes here" + {...args}> @@ -61,6 +179,10 @@ export const Horizontal = () => { ); }; +Horizontal.args = { ...sharedArgs }; + +Horizontal.argTypes = { ...sharedArgTypes }; + export const Single = () => { return ( <> @@ -122,15 +244,15 @@ const AILabelFunc = (kind) => ( ); -export const withAILabel = () => ( +export const withAILabel = (args) => (
- + - + ( - + (
); -export const Playground = (args) => ( - - - - - -); - -Playground.args = { - helperText: 'Helper text goes here', +withAILabel.args = { invalid: false, invalidText: 'Invalid message goes here', readOnly: false, @@ -182,100 +290,4 @@ Playground.args = { warnText: 'Warning message goes here', }; -Playground.argTypes = { - helperText: { - description: 'Provide text for the form group for additional help', - control: { - type: 'text', - }, - }, - invalid: { - description: 'Specify whether the form group is currently invalid', - control: { - type: 'boolean', - }, - }, - invalidText: { - description: - 'Provide the text that is displayed when the form group is in an invalid state', - control: { - type: 'text', - }, - }, - legendText: { - description: - 'Provide the text to be rendered inside of the fieldset ', - control: { - type: 'text', - }, - }, - readOnly: { - description: 'Specify whether the CheckboxGroup is read-only', - control: { - type: 'boolean', - }, - }, - warn: { - description: 'Specify whether the form group is currently in warning state', - control: { - type: 'boolean', - }, - }, - warnText: { - description: - 'Provide the text that is displayed when the form group is in warning state', - control: { - type: 'text', - }, - }, - checked: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - defaultChecked: { - table: { - disable: true, - }, - }, - hideLabel: { - table: { - disable: true, - }, - }, - id: { - table: { - disable: true, - }, - }, - indeterminate: { - table: { - disable: true, - }, - }, - labelText: { - table: { - disable: true, - }, - }, - onChange: { - table: { - disable: true, - }, - }, - title: { - table: { - disable: true, - }, - }, - orientation: { - description: 'Provide how checkbox should be displayed', - control: 'select', - options: ['horizontal', 'vertical'], - }, -}; +withAILabel.argTypes = { ...sharedArgTypes }; diff --git a/packages/react/src/components/ComboBox/ComboBox.stories.js b/packages/react/src/components/ComboBox/ComboBox.stories.js index 451ace723902..d29c9ff6e0a5 100644 --- a/packages/react/src/components/ComboBox/ComboBox.stories.js +++ b/packages/react/src/components/ComboBox/ComboBox.stories.js @@ -65,19 +65,111 @@ export default { }, }; -export const Default = () => ( +const sharedArgTypes = { + ['aria-label']: { + table: { + disable: true, + }, + }, + ariaLabel: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + id: { + table: { + disable: true, + }, + }, + downshiftProps: { + table: { + disable: true, + }, + }, + initialSelectedItem: { + table: { + disable: true, + }, + }, + invalidText: { + control: 'text', + }, + items: { + table: { + disable: true, + }, + }, + itemToElement: { + table: { + disable: true, + }, + }, + itemToString: { + table: { + disable: true, + }, + }, + onChange: { + action: 'changed', + }, + onToggleClick: { + action: 'clicked', + }, + onInputChange: { + table: { + disable: true, + }, + }, + selectedItem: { + table: { + disable: true, + }, + }, + shouldFilterItem: { + table: { + disable: true, + }, + }, + translateWithId: { + table: { + disable: true, + }, + }, + titleText: { + table: { + disable: true, + }, + }, + type: { + table: { + disable: true, + }, + }, + warnText: { + control: 'text', + }, +}; + +export const Default = (args) => (
{}} id="carbon-combobox" items={items} itemToString={(item) => (item ? item.text : '')} titleText="ComboBox title" helperText="Combobox helper text" + {...args} />
); +Default.argTypes = { ...sharedArgTypes }; + export const AllowCustomValue = (args) => { const filterItems = (menu) => { return menu?.item?.toLowerCase().includes(menu?.inputValue?.toLowerCase()); @@ -120,7 +212,7 @@ export const AutocompleteWithTypeahead = (args) => { ); }; -export const ExperimentalAutoAlign = () => ( +export const ExperimentalAutoAlign = (args) => (
( titleText="ComboBox title" helperText="Combobox helper text" autoAlign={true} + {...args} />
); +ExperimentalAutoAlign.argTypes = { ...sharedArgTypes }; + AllowCustomValue.argTypes = { onChange: { action: 'onChange' }, }; -export const _WithLayer = () => ( +export const _WithLayer = (args) => ( {(layer) => (
@@ -151,12 +246,15 @@ export const _WithLayer = () => ( itemToString={(item) => (item ? item.text : '')} titleText="ComboBox title" helperText="Combobox helper text" + {...args} />
)}
); +_WithLayer.argTypes = { ...sharedArgTypes }; + const aiLabel = ( @@ -188,7 +286,7 @@ const aiLabel = ( ); -export const withAILabel = () => ( +export const withAILabel = (args) => (
{}} @@ -198,11 +296,14 @@ export const withAILabel = () => ( titleText="ComboBox title" helperText="Combobox helper text" decorator={aiLabel} + {...args} />
); -export const _fullyControlled = () => { +withAILabel.argTypes = { ...sharedArgTypes }; + +export const _fullyControlled = (args) => { const options = [ { id: 'option-1', @@ -232,6 +333,7 @@ export const _fullyControlled = () => { itemToString={(item) => (item ? item.text : '')} titleText="Fully Controlled ComboBox title" helperText="Combobox helper text" + {...args} />
{ ); }; -export const Playground = (args) => ( -
- (item ? item.text : '')} - titleText="ComboBox title" - helperText="Combobox helper text" - {...args} - /> -
-); +_fullyControlled.argTypes = { ...sharedArgTypes }; AutocompleteWithTypeahead.argTypes = { onChange: { action: 'onChange' }, }; - -Playground.argTypes = { - ['aria-label']: { - table: { - disable: true, - }, - }, - ariaLabel: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - id: { - table: { - disable: true, - }, - }, - downshiftProps: { - table: { - disable: true, - }, - }, - initialSelectedItem: { - table: { - disable: true, - }, - }, - invalidText: { - control: 'text', - }, - items: { - table: { - disable: true, - }, - }, - itemToElement: { - table: { - disable: true, - }, - }, - itemToString: { - table: { - disable: true, - }, - }, - onChange: { - action: 'changed', - }, - onToggleClick: { - action: 'clicked', - }, - onInputChange: { - table: { - disable: true, - }, - }, - selectedItem: { - table: { - disable: true, - }, - }, - shouldFilterItem: { - table: { - disable: true, - }, - }, - translateWithId: { - table: { - disable: true, - }, - }, - titleText: { - table: { - disable: true, - }, - }, - type: { - table: { - disable: true, - }, - }, - warnText: { - control: 'text', - }, -}; diff --git a/packages/react/src/components/ComboButton/ComboButton.stories.js b/packages/react/src/components/ComboButton/ComboButton.stories.js index fed5415c0d8e..2d7d4335df03 100644 --- a/packages/react/src/components/ComboButton/ComboButton.stories.js +++ b/packages/react/src/components/ComboButton/ComboButton.stories.js @@ -28,22 +28,56 @@ export default { }, }; -export const Default = () => ( - - - - - -); +const sharedArgs = { + onClick: action('onClick'), + label: 'Primary action', +}; + +const sharedArgTypes = { + children: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + translateWithId: { + table: { + disable: true, + }, + }, +}; + +export const Default = (args) => { + const onClick = action('onClick (MenuItem)'); + + return ( + + + + + + + + ); +}; +Default.args = { ...sharedArgs }; +Default.argTypes = { ...sharedArgTypes }; -export const ExperimentalAutoAlign = () => ( +export const ExperimentalAutoAlign = (args) => (
- + @@ -52,8 +86,10 @@ export const ExperimentalAutoAlign = () => (
); -export const WithDanger = () => ( - +ExperimentalAutoAlign.argTypes = { ...sharedArgTypes }; + +export const WithDanger = (args) => ( + @@ -62,13 +98,17 @@ export const WithDanger = () => ( ); -export const WithIcons = () => ( - +WithDanger.argTypes = { ...sharedArgTypes }; + +export const WithIcons = (args) => ( + ); +WithIcons.argTypes = { ...sharedArgTypes }; + export const WithMenuAlignment = () => ( <>
@@ -123,43 +163,3 @@ export const WithMenuAlignment = () => (
); - -export const Playground = (args) => { - const onClick = action('onClick (MenuItem)'); - - return ( - - - - - - - - ); -}; - -Playground.argTypes = { - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - translateWithId: { - table: { - disable: true, - }, - }, -}; - -Playground.args = { - onClick: action('onClick'), - label: 'Primary action', -}; diff --git a/packages/react/src/components/ComposedModal/ComposedModal.stories.js b/packages/react/src/components/ComposedModal/ComposedModal.stories.js index 157d8d883ace..1705eb90c7fb 100644 --- a/packages/react/src/components/ComposedModal/ComposedModal.stories.js +++ b/packages/react/src/components/ComposedModal/ComposedModal.stories.js @@ -44,13 +44,51 @@ export default { }, }; -export const Default = () => { +const sharedArgTypes = { + children: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + containerClassName: { + table: { + disable: true, + }, + }, + onClose: { + action: 'onClose', + }, + onKeyDown: { + action: 'onKeyDown', + }, + selectorPrimaryFocus: { + table: { + disable: true, + }, + }, + selectorsFloatingMenus: { + table: { + disable: true, + }, + }, +}; + +export const Default = (args) => { const [open, setOpen] = useState(true); return ( <> - setOpen(false)}> - + setOpen(false)}> +

Custom domains direct requests for your apps in this Cloud Foundry @@ -69,12 +107,18 @@ export const Default = () => { - + ); }; +Default.argTypes = { ...sharedArgTypes }; + export const FullWidth = () => { const [open, setOpen] = useState(true); return ( @@ -449,76 +493,3 @@ export const _withAILabel = { ); }, }; - -export const Playground = (args) => { - const [open, setOpen] = useState(true); - return ( - <> - - setOpen(false)}> - - -

- Custom domains direct requests for your apps in this Cloud Foundry - organization to a URL that you own. A custom domain can be a shared - domain, a shared subdomain, or a shared domain and host. -

- - -
- -
- - ); -}; - -Playground.argTypes = { - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - containerClassName: { - table: { - disable: true, - }, - }, - onClose: { - action: 'onClose', - }, - onKeyDown: { - action: 'onKeyDown', - }, - selectorPrimaryFocus: { - table: { - disable: true, - }, - }, - selectorsFloatingMenus: { - table: { - disable: true, - }, - }, -}; diff --git a/packages/react/src/components/ContainedList/ContainedList.stories.js b/packages/react/src/components/ContainedList/ContainedList.stories.js index 92deeed6da64..32851cccbfbc 100644 --- a/packages/react/src/components/ContainedList/ContainedList.stories.js +++ b/packages/react/src/components/ContainedList/ContainedList.stories.js @@ -60,23 +60,26 @@ export default { }, }; -export const Default = () => ( +const DefaultStory = (args) => ( <> - - List item - List item - List item - List item - - - List item - List item - List item - List item - + {[...Array(4)].map((_, i) => ( + + {[...Array(8)].map((_, j) => ( + List item + ))} + + ))} ); +export const Default = DefaultStory.bind({}); + +Default.args = { + label: 'List title', + kind: 'on-page', + size: 'lg', +}; + export const Disclosed = () => ( <> @@ -352,23 +355,3 @@ export const UsageExamples = () => { ); }; - -const PlaygroundStory = (args) => ( - <> - {[...Array(4)].map((_, i) => ( - - {[...Array(8)].map((_, j) => ( - List item - ))} - - ))} - -); - -export const Playground = PlaygroundStory.bind({}); - -Playground.args = { - label: 'List title', - kind: 'on-page', - size: 'lg', -}; diff --git a/packages/react/src/components/ContentSwitcher/ContentSwitcher.mdx b/packages/react/src/components/ContentSwitcher/ContentSwitcher.mdx index cfab008cd933..d52de1e5c7ad 100644 --- a/packages/react/src/components/ContentSwitcher/ContentSwitcher.mdx +++ b/packages/react/src/components/ContentSwitcher/ContentSwitcher.mdx @@ -39,7 +39,7 @@ Content switchers allow users to toggle between two or more content sections within the same space on screen. Only one content section is shown at a time. Create Switch components for each section in the content switcher. - + ## Component API diff --git a/packages/react/src/components/ContentSwitcher/ContentSwitcher.stories.js b/packages/react/src/components/ContentSwitcher/ContentSwitcher.stories.js index 87b331e8bdc5..bccf75da9636 100644 --- a/packages/react/src/components/ContentSwitcher/ContentSwitcher.stories.js +++ b/packages/react/src/components/ContentSwitcher/ContentSwitcher.stories.js @@ -11,7 +11,12 @@ import { WithLayer } from '../../../.storybook/templates/WithLayer'; import ContentSwitcher from './ContentSwitcher'; import { Switch, IconSwitch } from '../Switch'; import mdx from './ContentSwitcher.mdx'; -import { TableOfContents, Workspace, ViewMode_2 } from '@carbon/icons-react'; +import { + TableOfContents, + Workspace, + ViewMode_2, + Icon, +} from '@carbon/icons-react'; export default { title: 'Components/ContentSwitcher', @@ -34,17 +39,36 @@ export default { }, }; -export const Default = () => ( - {}}> +const sharedArgTypes = { + children: { + control: false, + }, + className: { + control: false, + }, + onChange: { + action: 'onChange', + }, + size: { + options: ['sm', 'md', 'lg'], + }, +}; + +export const Default = (args) => ( + - Second section + ); -export const _WithLayer = () => ( +Default.argTypes = { + ...sharedArgTypes, +}; + +export const _WithLayer = (args) => ( - {}}> + {}} {...args}> @@ -52,6 +76,10 @@ export const _WithLayer = () => ( ); +_WithLayer.argTypes = { + ...sharedArgTypes, +}; + export const IconOnly = (args) => ( {}} {...args}> @@ -66,6 +94,10 @@ export const IconOnly = (args) => ( ); +IconOnly.argTypes = { + ...sharedArgTypes, +}; + export const IconOnlyWithLayer = (args) => ( {}} {...args}> @@ -82,29 +114,6 @@ export const IconOnlyWithLayer = (args) => ( ); -export const Playground = (args) => ( - - - - - -); - -Playground.argTypes = { - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - onChange: { - action: 'onChange', - }, - size: { - options: ['sm', 'md', 'lg'], - }, +IconOnlyWithLayer.argTypes = { + ...sharedArgTypes, }; diff --git a/packages/react/src/components/CopyButton/CopyButton.mdx b/packages/react/src/components/CopyButton/CopyButton.mdx index d6ae3b7a23ce..f7c53d3650c4 100644 --- a/packages/react/src/components/CopyButton/CopyButton.mdx +++ b/packages/react/src/components/CopyButton/CopyButton.mdx @@ -25,7 +25,7 @@ The copy button should be accompanied by a tooltip. Tooltip feedback text should be concise and describe the action taken when the user clicks the copy button. By default we display the text “Copied!”. - + ## Component API diff --git a/packages/react/src/components/CopyButton/CopyButton.stories.js b/packages/react/src/components/CopyButton/CopyButton.stories.js index aeb89a0dcaef..d59cafec1929 100644 --- a/packages/react/src/components/CopyButton/CopyButton.stories.js +++ b/packages/react/src/components/CopyButton/CopyButton.stories.js @@ -20,11 +20,9 @@ export default { }, }; -export const Default = () => ; +export const Default = (args) => ; -export const Playground = (args) => ; - -Playground.argTypes = { +Default.argTypes = { className: { table: { disable: true, diff --git a/packages/react/src/components/DataTable/stories/DataTable-ai-label.stories.js b/packages/react/src/components/DataTable/stories/DataTable-ai-label.stories.js index 4420a233a33d..1c4affdc9db7 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-ai-label.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-ai-label.stories.js @@ -51,6 +51,49 @@ export default { }, }; +const sharedArgTypes = { + filterRows: { + table: { + disable: true, + }, + }, + headers: { + table: { + disable: true, + }, + }, + isSortable: { + table: { + disable: true, + }, + }, + overflowMenuOnHover: { + table: { + disable: true, + }, + }, + radio: { + table: { + disable: true, + }, + }, + rows: { + table: { + disable: true, + }, + }, + translateWithId: { + table: { + disable: true, + }, + }, + sortRow: { + table: { + disable: true, + }, + }, +}; + const columnAILabelHeaders = [ { key: 'name', @@ -143,8 +186,8 @@ const aiLabel = ( ); -export const AILabelWithSelection = () => ( - +export const AILabelWithSelection = (args) => ( + {({ rows, headers, @@ -189,8 +232,10 @@ export const AILabelWithSelection = () => ( ); -export const AILabelWithRadioSelection = () => ( - +AILabelWithSelection.argTypes = { ...sharedArgTypes }; + +export const AILabelWithRadioSelection = (args) => ( + {({ rows, headers, @@ -235,8 +280,10 @@ export const AILabelWithRadioSelection = () => ( ); -export const AILabelWithSelectionAndExpansion = () => ( - +AILabelWithRadioSelection.argTypes = { ...sharedArgTypes }; + +export const AILabelWithSelectionAndExpansion = (args) => ( + {({ rows, headers, @@ -296,8 +343,10 @@ export const AILabelWithSelectionAndExpansion = () => ( ); -export const AILabelWithExpansion = () => ( - +AILabelWithSelectionAndExpansion.argTypes = { ...sharedArgTypes }; + +export const AILabelWithExpansion = (args) => ( + {({ rows, headers, @@ -354,8 +403,10 @@ export const AILabelWithExpansion = () => ( ); -export const ColumnAILabelWithSelectionAndExpansion = () => ( - +AILabelWithExpansion.argTypes = { ...sharedArgTypes }; + +export const ColumnAILabelWithSelectionAndExpansion = (args) => ( + {({ rows, headers, @@ -423,8 +474,10 @@ export const ColumnAILabelWithSelectionAndExpansion = () => ( ); -export const ColumnAILabelSort = () => ( - +ColumnAILabelWithSelectionAndExpansion.argTypes = { ...sharedArgTypes }; + +export const ColumnAILabelSort = (args) => ( + {({ rows, headers, @@ -465,3 +518,5 @@ export const ColumnAILabelSort = () => ( )} ); + +ColumnAILabelSort.argTypes = { ...sharedArgTypes }; diff --git a/packages/react/src/components/DataTable/stories/DataTable-basic.stories.js b/packages/react/src/components/DataTable/stories/DataTable-basic.stories.js index 0a1c81fbe9de..e102e5201b65 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-basic.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-basic.stories.js @@ -40,7 +40,50 @@ export default { }, }; -export const Default = () => { +const sharedArgTypes = { + filterRows: { + table: { + disable: true, + }, + }, + headers: { + table: { + disable: true, + }, + }, + isSortable: { + table: { + disable: true, + }, + }, + overflowMenuOnHover: { + table: { + disable: true, + }, + }, + radio: { + table: { + disable: true, + }, + }, + rows: { + table: { + disable: true, + }, + }, + translateWithId: { + table: { + disable: true, + }, + }, + sortRow: { + table: { + disable: true, + }, + }, +}; + +export const Default = (args) => { const rows = [ { id: 'load-balancer-1', @@ -102,7 +145,7 @@ export const Default = () => { const headers = ['Name', 'Rule', 'Status', 'Other', 'Example']; return ( - +
{headers.map((header) => ( @@ -127,7 +170,11 @@ export const Default = () => { ); }; -export const XLWithTwoLines = () => { +Default.argTypes = { + ...sharedArgTypes, +}; + +export const XLWithTwoLines = (args) => { const rows = [ { id: 'load-balancer-1', @@ -224,7 +271,7 @@ export const XLWithTwoLines = () => { const headers = ['Name', 'Rule', 'Status', 'Other', 'Example']; return ( -
+
{headers.map((header) => ( @@ -249,132 +296,6 @@ export const XLWithTwoLines = () => { ); }; -export const Playground = (args) => { - const rows = [ - { - id: 'load-balancer-1', - name: 'Load Balancer 1', - rule: 'Round robin', - Status: 'Starting', - other: 'Test', - example: '22', - }, - { - id: 'load-balancer-2', - name: 'Load Balancer 2', - rule: 'DNS delegation', - status: 'Active', - other: 'Test', - example: '22', - }, - { - id: 'load-balancer-3', - name: 'Load Balancer 3', - rule: 'Round robin', - status: 'Disabled', - other: 'Test', - example: '22', - }, - { - id: 'load-balancer-4', - name: 'Load Balancer 4', - rule: 'Round robin', - status: 'Disabled', - other: 'Test', - example: '22', - }, - { - id: 'load-balancer-5', - name: 'Load Balancer 5', - rule: 'Round robin', - status: 'Disabled', - other: 'Test', - example: '22', - }, - { - id: 'load-balancer-6', - name: 'Load Balancer 6', - rule: 'Round robin', - status: 'Disabled', - other: 'Test', - example: '22', - }, - { - id: 'load-balancer-7', - name: 'Load Balancer 7', - rule: 'Round robin', - status: 'Disabled', - other: 'Test', - example: '22', - }, - ]; - const headers = ['Name', 'Rule', 'Status', 'Other', 'Example']; - - return ( -
- - - {headers.map((header) => ( - - {header} - - ))} - - - - {rows.map((row) => ( - - {Object.keys(row) - .filter((key) => key !== 'id') - .map((key) => { - return {row[key]}; - })} - - ))} - -
- ); -}; - -Playground.argTypes = { - filterRows: { - table: { - disable: true, - }, - }, - headers: { - table: { - disable: true, - }, - }, - isSortable: { - table: { - disable: true, - }, - }, - overflowMenuOnHover: { - table: { - disable: true, - }, - }, - radio: { - table: { - disable: true, - }, - }, - rows: { - table: { - disable: true, - }, - }, - translateWithId: { - table: { - disable: true, - }, - }, - sortRow: { - table: { - disable: true, - }, - }, +XLWithTwoLines.argTypes = { + ...sharedArgTypes, }; diff --git a/packages/react/src/components/DataTable/stories/DataTable-batch-actions.stories.js b/packages/react/src/components/DataTable/stories/DataTable-batch-actions.stories.js index fccb21d44ccc..e914ded5efe4 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-batch-actions.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-batch-actions.stories.js @@ -61,127 +61,7 @@ export default { }, }; -export const Default = () => ( - - {({ - rows, - headers, - getHeaderProps, - getRowProps, - getSelectionProps, - getToolbarProps, - getBatchActionProps, - onInputChange, - selectedRows, - getTableProps, - getTableContainerProps, - selectRow, - }) => { - const batchActionProps = { - ...getBatchActionProps({ - onSelectAll: () => { - rows.map((row) => { - if (!row.isSelected) { - selectRow(row.id); - } - }); - }, - }), - }; - - return ( - - - - - Delete - - - Delete - - - Save - - - Download - - - - - - alert('Alert 1')}> - Action 1 - - alert('Alert 2')}> - Action 2 - - alert('Alert 3')}> - Action 3 - - - - - - - - - - {headers.map((header, i) => ( - - {header.header} - - ))} - - - - {rows.map((row, i) => ( - - - {row.cells.map((cell) => ( - {cell.value} - ))} - - ))} - -
-
- ); - }} -
-); - -export const Playground = (args) => ( +export const Default = (args) => ( {({ rows, @@ -288,7 +168,7 @@ export const Playground = (args) => ( ); -Playground.argTypes = { +Default.argTypes = { filterRows: { table: { disable: true, diff --git a/packages/react/src/components/DataTable/stories/DataTable-filtering.stories.js b/packages/react/src/components/DataTable/stories/DataTable-filtering.stories.js index 45dfd722d767..9d5c559fe586 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-filtering.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-filtering.stories.js @@ -69,100 +69,7 @@ export default { }, }; -export const Default = () => { - const [renderedRows, setRenderedRows] = useState(rows); - - const handleTableFilter = (selectedCheckboxes) => { - setRenderedRows([]); - - for (let i = 0; i < selectedCheckboxes.length; i++) { - // Filter the items inside the rows list - const filteredRows = rows.filter((row) => { - return Object.values(row).some((value) => - String(value) - .toLowerCase() - .includes(selectedCheckboxes[i].toLowerCase()) - ); - }); - - setRenderedRows((prevData) => { - // Filter out duplicate rows - const uniqueRows = filteredRows.filter((row) => { - return !prevData.some((prevRow) => { - return Object.keys(row).every((key) => { - return row[key] === prevRow[key]; - }); - }); - }); - return [...prevData, ...uniqueRows]; - }); - } - }; - - const handleOnResetFilter = () => { - setRenderedRows(rows); - }; - - return ( - - {({ - rows, - headers, - getHeaderProps, - getRowProps, - getTableProps, - onInputChange, - }) => ( - - - - {/* pass in `onInputChange` change here to make filtering work */} - - - - - Action 1 - - - Action 2 - - - Action 3 - - - - - - - - - {headers.map((header) => ( - - {header.header} - - ))} - - - - {rows.map((row) => ( - - {row.cells.map((cell) => ( - {cell.value} - ))} - - ))} - -
-
- )} -
- ); -}; - -export const Playground = (args) => { +export const Default = (args) => { const [renderedRows, setRenderedRows] = useState(rows); const handleTableFilter = (selectedCheckboxes) => { @@ -260,7 +167,7 @@ export const Playground = (args) => { ); }; -Playground.argTypes = { +Default.argTypes = { filterRows: { table: { disable: true, diff --git a/packages/react/src/components/DataTable/stories/DataTable-selection.stories.js b/packages/react/src/components/DataTable/stories/DataTable-selection.stories.js index 655e53ffb87e..2654837af94b 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-selection.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-selection.stories.js @@ -42,8 +42,29 @@ export default { }, }; -export const Default = () => ( - +const sharedArgTypes = { + filterRows: { + control: false, + }, + headers: { + control: false, + }, + overflowMenuOnHover: { + control: false, + }, + rows: { + control: false, + }, + translateWithId: { + control: false, + }, + sortRow: { + control: false, + }, +}; + +export const Default = (args) => ( + {({ rows, headers, @@ -60,7 +81,11 @@ export const Default = () => ( - + {args.radio ? ( +
+ ) : ( + + )} {headers.map((header, i) => ( {header.header} @@ -70,8 +95,16 @@ export const Default = () => ( {rows.map((row, i) => ( - - + { + action('TableRow onClick')(evt); + }}> + {row.cells.map((cell) => ( {cell.value} ))} @@ -84,8 +117,10 @@ export const Default = () => ( ); -export const WithRadioSelection = () => ( - +Default.argTypes = { ...sharedArgTypes }; + +export const WithRadioSelection = (args) => ( + {({ rows, headers, @@ -126,8 +161,10 @@ export const WithRadioSelection = () => ( ); -export const WithSelectionAndSorting = () => ( - +WithRadioSelection.argTypes = { ...sharedArgTypes }; + +export const WithSelectionAndSorting = (args) => ( + {({ rows, headers, @@ -167,89 +204,5 @@ export const WithSelectionAndSorting = () => ( )} ); -export const Playground = (args) => ( - - {({ - rows, - headers, - getHeaderProps, - getRowProps, - getSelectionProps, - getTableProps, - getTableContainerProps, - }) => ( - - - - - {args.radio ? ( -
- ) : ( - - )} - {headers.map((header, i) => ( - - {header.header} - - ))} - - - - {rows.map((row, i) => ( - { - action('TableRow onClick')(evt); - }}> - - {row.cells.map((cell) => ( - {cell.value} - ))} - - ))} - -
-
- )} -
-); -Playground.argTypes = { - filterRows: { - table: { - disable: true, - }, - }, - headers: { - table: { - disable: true, - }, - }, - overflowMenuOnHover: { - table: { - disable: true, - }, - }, - rows: { - table: { - disable: true, - }, - }, - translateWithId: { - table: { - disable: true, - }, - }, - sortRow: { - table: { - disable: true, - }, - }, -}; +WithSelectionAndSorting.argTypes = { ...sharedArgTypes }; diff --git a/packages/react/src/components/DataTable/stories/DataTable-sorting.stories.js b/packages/react/src/components/DataTable/stories/DataTable-sorting.stories.js index 0298aef6dcba..1705194bd6c8 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-sorting.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-sorting.stories.js @@ -37,36 +37,7 @@ export default { }, }; -export const Default = () => ( - - {({ rows, headers, getHeaderProps, getRowProps, getTableProps }) => ( - - - - - {headers.map((header) => ( - - {header.header} - - ))} - - - - {rows.map((row) => ( - - {row.cells.map((cell) => ( - {cell.value} - ))} - - ))} - -
-
- )} -
-); - -export const Playground = (args) => ( +export const Default = (args) => ( {({ rows, headers, getHeaderProps, getRowProps, getTableProps }) => ( @@ -95,7 +66,7 @@ export const Playground = (args) => ( ); -Playground.argTypes = { +Default.argTypes = { filterRows: { table: { disable: true, diff --git a/packages/react/src/components/DataTable/stories/DataTable-toolbar.stories.js b/packages/react/src/components/DataTable/stories/DataTable-toolbar.stories.js index e430cc02bed9..aafb32e1e25d 100644 --- a/packages/react/src/components/DataTable/stories/DataTable-toolbar.stories.js +++ b/packages/react/src/components/DataTable/stories/DataTable-toolbar.stories.js @@ -47,8 +47,21 @@ export default { }, }; -export const Default = () => ( - +const sharedArgTypes = { + size: { + options: ['xs', 'sm', 'md', 'lg', 'xl'], + control: { type: 'select' }, + }, + useZebraStyles: { + control: { type: 'boolean' }, + }, + isSortable: { control: { type: 'boolean' } }, + persistent: { control: { type: 'boolean' } }, + radio: { table: { disable: true } }, +}; + +export const Default = (args) => ( + {({ rows, headers, @@ -105,8 +118,10 @@ export const Default = () => ( ); -export const PersistentToolbar = () => ( - +Default.argTypes = { ...sharedArgTypes }; + +export const PersistentToolbar = (args) => ( + {({ rows, headers, @@ -163,8 +178,10 @@ export const PersistentToolbar = () => ( ); -export const SmallPersistentToolbar = () => ( - +PersistentToolbar.argTypes = { ...sharedArgTypes }; + +export const SmallPersistentToolbar = (args) => ( + {({ rows, headers, @@ -224,69 +241,9 @@ export const SmallPersistentToolbar = () => ( ); -export const WithOverflowMenu = () => ( - - {({ - rows, - headers, - getHeaderProps, - getRowProps, - getTableProps, - getToolbarProps, - onInputChange, - }) => ( - - - - - - - Action 1 - - - Action 2 - - - Action 3 - - - - - - - - - {headers.map((header) => ( - - {header.header} - - ))} - - - - - {rows.map((row) => ( - - {row.cells.map((cell) => ( - {cell.value} - ))} - - - - - - - - - ))} - -
-
- )} -
-); +SmallPersistentToolbar.argTypes = { ...sharedArgTypes }; -export const Playground = (args) => ( +export const WithOverflowMenu = (args) => ( {({ rows, @@ -300,12 +257,7 @@ export const Playground = (args) => ( - { - action('TableToolbarSearch - onChange')(evt); - onInputChange(evt); - }} - /> + Action 1 @@ -328,7 +280,7 @@ export const Playground = (args) => ( {header.header}
))} - + @@ -353,18 +305,9 @@ export const Playground = (args) => ( ); -Playground.argTypes = { - size: { - options: ['xs', 'sm', 'md', 'lg', 'xl'], - control: { type: 'select' }, - }, - useZebraStyles: { - control: { type: 'boolean' }, - }, - isSortable: { control: { type: 'boolean' } }, - persistent: { control: { type: 'boolean' } }, +WithOverflowMenu.argTypes = { + ...sharedArgTypes, overflowMenuOnHover: { control: { type: 'boolean' }, }, - radio: { table: { disable: true } }, }; diff --git a/packages/react/src/components/DataTable/stories/dynamic-content/DataTable-dynamic-content.stories.js b/packages/react/src/components/DataTable/stories/dynamic-content/DataTable-dynamic-content.stories.js index 6413dca871c3..28376ddd2fde 100644 --- a/packages/react/src/components/DataTable/stories/dynamic-content/DataTable-dynamic-content.stories.js +++ b/packages/react/src/components/DataTable/stories/dynamic-content/DataTable-dynamic-content.stories.js @@ -38,186 +38,7 @@ export default { component: DataTable, }; -export const Default = () => { - const insertInRandomPosition = (array, element) => { - const index = Math.floor(Math.random() * (array.length + 1)); - return [...array.slice(0, index), element, ...array.slice(index)]; - }; - - class DynamicRows extends React.Component { - state = { - rows, - headers: headers, - id: 0, - }; - - handleOnHeaderAdd = () => { - const length = this.state.headers.length; - const header = { - key: `header_${length}`, - header: `Header ${length}`, - }; - - this.setState((state) => { - const rows = state.rows.map((row) => { - return { - ...row, - [header.key]: header.header, - }; - }); - return { - rows, - headers: state.headers.concat(header), - }; - }); - }; - - handleOnRowAdd = () => { - this.setState((state) => { - const { id: _id, rows } = state; - const id = _id + 1; - const row = { - id: '' + id, - name: `New Row ${id}`, - protocol: 'HTTP', - port: id * 100, - rule: id % 2 === 0 ? 'Round robin' : 'DNS delegation', - attached_groups: `Row ${id}'s VM Groups`, - status: 'Starting', - }; - - state.headers - .filter((header) => row[header.key] === undefined) - .forEach((header) => { - row[header.key] = header.header; - }); - - return { - id, - rows: insertInRandomPosition(rows, row), - }; - }); - }; - - render() { - return ( - { - const batchActionProps = getBatchActionProps(); - return ( - - - - - Delete - - - Save - - - Download - - - - - - - Add row - - - Add header - - - - - - - - - - {headers.map((header, i) => ( - - {header.header} - - ))} - - - - {rows.map((row) => ( - - - - {row.cells.map((cell) => ( - {cell.value} - ))} - - -
Expandable row content
-
Description here
-
-
- ))} -
-
-
- ); - }} - /> - ); - } - } - return ; -}; - -export const Playground = (args) => { +export const Default = (args) => { const insertInRandomPosition = (array, element) => { const index = Math.floor(Math.random() * (array.length + 1)); return [...array.slice(0, index), element, ...array.slice(index)]; @@ -414,7 +235,7 @@ export const Playground = (args) => { return ; }; -Playground.argTypes = { +Default.argTypes = { filterRows: { table: { disable: true, diff --git a/packages/react/src/components/DataTable/stories/expansion/DataTable-expansion.stories.js b/packages/react/src/components/DataTable/stories/expansion/DataTable-expansion.stories.js index 9074bac72815..9f8e4b6dd9e9 100644 --- a/packages/react/src/components/DataTable/stories/expansion/DataTable-expansion.stories.js +++ b/packages/react/src/components/DataTable/stories/expansion/DataTable-expansion.stories.js @@ -45,8 +45,16 @@ export default { }, }; -export const Default = () => ( - +const sharedArgTypes = { + radio: { + table: { + disable: true, + }, + }, +}; + +export const Default = (args) => ( + {({ rows, headers, @@ -74,7 +82,9 @@ export const Default = () => ( {rows.map((row) => ( - + {row.cells.map((cell) => ( {cell.value} ))} @@ -95,8 +105,13 @@ export const Default = () => ( ); -export const BatchExpansion = () => ( +Default.argTypes = { + ...sharedArgTypes, +}; + +export const BatchExpansion = (args) => ( ( /> ); -export const Playground = (args) => ( - - {({ - rows, - headers, - getHeaderProps, - getRowProps, - getExpandedRowProps, - getTableProps, - getTableContainerProps, - }) => ( - - - - - - {headers.map((header, i) => ( - - {header.header} - - ))} - - - - {rows.map((row) => ( - - - {row.cells.map((cell) => ( - {cell.value} - ))} - - -
Expandable row content
-
Description here
-
-
- ))} -
-
-
- )} -
-); - -Playground.argTypes = { - radio: { - table: { - disable: true, - }, - }, +BatchExpansion.argTypes = { + ...sharedArgTypes, }; diff --git a/packages/react/src/components/DataTableSkeleton/DataTableSkeleton.stories.js b/packages/react/src/components/DataTableSkeleton/DataTableSkeleton.stories.js index 54385af5de35..24990c0fe6ff 100644 --- a/packages/react/src/components/DataTableSkeleton/DataTableSkeleton.stories.js +++ b/packages/react/src/components/DataTableSkeleton/DataTableSkeleton.stories.js @@ -23,25 +23,14 @@ export default { component: DataTableSkeleton, }; -export const Skeleton = () => { +export const Skeleton = (args) => { const { ...rest } = props(); - return ( -
- -
-
- ); -}; -export const Playground = (args) => { return (
@@ -50,7 +39,7 @@ export const Playground = (args) => { ); }; -Playground.argTypes = { +Skeleton.argTypes = { headers: { table: { disable: true, diff --git a/packages/react/src/components/DatePicker/DatePicker.mdx b/packages/react/src/components/DatePicker/DatePicker.mdx index 951870770afe..5340b36218d9 100644 --- a/packages/react/src/components/DatePicker/DatePicker.mdx +++ b/packages/react/src/components/DatePicker/DatePicker.mdx @@ -46,7 +46,7 @@ picker is best to use. Each picker’s format can be customized depending on location or need. The `DatePicker` component expects a `DatePickerInput` as a child. - + ### Simple DatePicker diff --git a/packages/react/src/components/DatePicker/DatePicker.stories.js b/packages/react/src/components/DatePicker/DatePicker.stories.js index 8da60efe423e..11c54fd8d0d8 100644 --- a/packages/react/src/components/DatePicker/DatePicker.stories.js +++ b/packages/react/src/components/DatePicker/DatePicker.stories.js @@ -41,97 +41,258 @@ export default { }, }; -export const Simple = () => ( - +const sharedArgTypes = { + appendTo: { + table: { + disable: true, + }, + }, + datePickerType: { + table: { + disable: true, + }, + }, + children: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + disable: { + table: { + disable: true, + }, + }, + enable: { + table: { + disable: true, + }, + }, + inline: { + table: { + disable: true, + }, + }, + locale: { + table: { + disable: true, + }, + }, + onChange: { + action: 'onChange', + }, + onClose: { + action: 'onClose', + }, + onOpen: { + action: 'onOpen', + }, + readOnly: { + control: { + type: 'boolean', + }, + }, + value: { + table: { + disable: true, + }, + }, + size: { + options: ['sm', 'md', 'lg'], + control: { type: 'select' }, + table: { + category: 'DatePickerInput', + }, + }, + disabled: { + control: { type: 'boolean' }, + table: { + category: 'DatePickerInput', + }, + }, + invalid: { + control: { type: 'boolean' }, + table: { + category: 'DatePickerInput', + }, + }, + invalidText: { + control: { type: 'text' }, + table: { + category: 'DatePickerInput', + }, + }, + placeholder: { + control: { type: 'text' }, + table: { + category: 'DatePickerInput', + }, + }, + warn: { + control: { type: 'boolean' }, + table: { + category: 'DatePickerInput', + }, + }, + warnText: { + control: { type: 'text' }, + table: { + category: 'DatePickerInput', + }, + }, + helperText: { + control: { type: 'text' }, + table: { + category: 'DatePickerInput', + }, + }, +}; + +export const Default = ({ readOnly, ...args }) => { + return ( + + + {args.datePickerType === 'range' && ( + + )} + + ); +}; + +Default.argTypes = { + ...sharedArgTypes, + datePickerType: { + options: ['sigle', 'simple', 'range'], + control: { type: 'select' }, + }, +}; + +export const Simple = (args) => ( + ); -export const SingleWithCalendar = () => ( - +Simple.argTypes = { ...sharedArgTypes }; + +export const SingleWithCalendar = (args) => ( + ); -export const RangeWithCalendar = () => { +SingleWithCalendar.argTypes = { ...sharedArgTypes }; + +export const RangeWithCalendar = (args) => { return ( - + ); }; -export const SimpleWithLayer = () => ( +RangeWithCalendar.argTypes = { ...sharedArgTypes }; + +export const SimpleWithLayer = (args) => ( {(layer) => ( - + )} ); -export const SingleWithCalendarWithLayer = () => ( +SimpleWithLayer.argTypes = { ...sharedArgTypes }; + +export const SingleWithCalendarWithLayer = (args) => ( {(layer) => ( - + )} ); -export const RangeWithCalendarWithLayer = () => ( +SingleWithCalendarWithLayer.argTypes = { ...sharedArgTypes }; + +export const RangeWithCalendarWithLayer = (args) => ( {(layer) => ( - + )} ); +RangeWithCalendarWithLayer.argTypes = { ...sharedArgTypes }; + export const Skeleton = () => ; const aiLabel = ( @@ -165,144 +326,19 @@ const aiLabel = ( ); -export const withAILabel = () => ( +export const withAILabel = (args) => (
- +
); -export const Playground = ({ readOnly, ...args }) => { - return ( - - - {args.datePickerType === 'range' && ( - - )} - - ); -}; - -Playground.argTypes = { - appendTo: { - table: { - disable: true, - }, - }, - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - disable: { - table: { - disable: true, - }, - }, - enable: { - table: { - disable: true, - }, - }, - inline: { - table: { - disable: true, - }, - }, - locale: { - table: { - disable: true, - }, - }, - onChange: { - action: 'onChange', - }, - onClose: { - action: 'onClose', - }, - onOpen: { - action: 'onOpen', - }, - readOnly: { - control: { - type: 'boolean', - }, - }, - value: { - table: { - disable: true, - }, - }, - size: { - options: ['sm', 'md', 'lg'], - control: { type: 'select' }, - table: { - category: 'DatePickerInput', - }, - }, - disabled: { - control: { type: 'boolean' }, - table: { - category: 'DatePickerInput', - }, - }, - invalid: { - control: { type: 'boolean' }, - table: { - category: 'DatePickerInput', - }, - }, - invalidText: { - control: { type: 'text' }, - table: { - category: 'DatePickerInput', - }, - }, - placeholder: { - control: { type: 'text' }, - table: { - category: 'DatePickerInput', - }, - }, - warn: { - control: { type: 'boolean' }, - table: { - category: 'DatePickerInput', - }, - }, - warnText: { - control: { type: 'text' }, - table: { - category: 'DatePickerInput', - }, - }, - helperText: { - control: { type: 'text' }, - table: { - category: 'DatePickerInput', - }, - }, -}; +withAILabel.argTypes = { ...sharedArgTypes }; diff --git a/packages/react/src/components/Dropdown/Dropdown.stories.js b/packages/react/src/components/Dropdown/Dropdown.stories.js index 0fed948f478c..2c845a78a23c 100644 --- a/packages/react/src/components/Dropdown/Dropdown.stories.js +++ b/packages/react/src/components/Dropdown/Dropdown.stories.js @@ -87,40 +87,7 @@ const items = [ }, ]; -export const ExperimentalAutoAlign = () => ( -
-
- (item ? item.text : '')} - direction="top" - /> -
-
-); - -export const Playground = (args) => ( -
- (item ? item.text : '')} - {...args} - /> -
-); - -Playground.args = { +const sharedArgs = { invalid: false, invalidText: 'invalid selection', disabled: false, @@ -132,7 +99,7 @@ Playground.args = { type: 'default', }; -Playground.argTypes = { +const sharedArgTypes = { invalid: { control: { type: 'boolean', @@ -188,9 +155,34 @@ Playground.argTypes = { }, }; -export const Default = () => ( +export const Default = (args) => ( +
+ (item ? item.text : '')} + {...args} + /> +
+); + +Default.args = { + ...sharedArgs, +}; + +Default.argTypes = { + ...sharedArgTypes, +}; + +export const ExperimentalAutoAlign = (args) => (
+
( label="Option 1" items={items} itemToString={(item) => (item ? item.text : '')} + direction="top" + {...args} /> +
); -export const Inline = () => ( +ExperimentalAutoAlign.argTypes = { + ...sharedArgTypes, +}; + +export const Inline = (args) => (
( type="inline" items={items} itemToString={(item) => (item ? item.text : '')} + {...args} />
); -export const _WithLayer = () => ( +Inline.argTypes = { + ...sharedArgTypes, +}; + +export const _WithLayer = (args) => ( {(layer) => (
@@ -228,13 +232,18 @@ export const _WithLayer = () => ( label="Option 1" items={items} itemToString={(item) => (item ? item.text : '')} + {...args} />
)}
); -export const InlineWithLayer = () => ( +_WithLayer.argTypes = { + ...sharedArgTypes, +}; + +export const InlineWithLayer = (args) => ( {(layer) => (
@@ -246,12 +255,17 @@ export const InlineWithLayer = () => ( type="inline" items={items} itemToString={(item) => (item ? item.text : '')} + {...args} />
)}
); +InlineWithLayer.argTypes = { + ...sharedArgTypes, +}; + export const Skeleton = () => (
@@ -289,7 +303,7 @@ const aiLabel = ( ); -export const withAILabel = () => ( +export const withAILabel = (args) => (
( items={items} itemToString={(item) => (item ? item.text : '')} decorator={aiLabel} + {...args} />
); + +withAILabel.argTypes = { + ...sharedArgTypes, +}; diff --git a/packages/react/src/components/FileUploader/FileUploader.stories.js b/packages/react/src/components/FileUploader/FileUploader.stories.js index f19f241e92c7..39a450c6b0a0 100644 --- a/packages/react/src/components/FileUploader/FileUploader.stories.js +++ b/packages/react/src/components/FileUploader/FileUploader.stories.js @@ -32,26 +32,6 @@ export default { }, }; -export const Default = () => { - return ( -
- -
- ); -}; - export const _FileUploaderItem = (args) => { return ( (
); -export const Playground = (args) => { +export const Default = (args) => { return (
); }; -Playground.args = { +Default.args = { labelTitle: 'Upload files', labelDescription: 'Max file size is 500 MB. Only .jpg files are supported.', buttonLabel: 'Add file', @@ -197,7 +177,7 @@ Playground.args = { iconDescription: 'Delete file', name: '', }; -Playground.argTypes = { +Default.argTypes = { onChange: { action: 'onChange' }, onClick: { action: 'onClick' }, onDelete: { action: 'onDelete' }, diff --git a/packages/react/src/components/FluidComboBox/FluidComboBox.stories.js b/packages/react/src/components/FluidComboBox/FluidComboBox.stories.js index aefd4f0794aa..15f8593a56c9 100644 --- a/packages/react/src/components/FluidComboBox/FluidComboBox.stories.js +++ b/packages/react/src/components/FluidComboBox/FluidComboBox.stories.js @@ -54,6 +54,100 @@ const items = [ }, ]; +const sharedArgTypes = { + className: { + control: { + type: 'text', + }, + }, + isCondensed: { + control: { + type: 'boolean', + }, + }, + disabled: { + control: { + type: 'boolean', + }, + }, + invalid: { + control: { + type: 'boolean', + }, + }, + invalidText: { + control: { + type: 'text', + }, + }, + label: { + control: { + type: 'text', + }, + }, + titleText: { + control: { + type: 'text', + }, + }, + warn: { + control: { + type: 'boolean', + }, + }, + warnText: { + control: { + type: 'text', + }, + }, +}; + +export const Default = (args) => ( +
+ {}} + id="default" + titleText="Label" + label="Choose an option" + items={items} + itemToString={(item) => (item ? item.text : '')} + {...args} + /> +
+ {}} + id="default-3" + titleText={ToggleTip} + label="Choose an option" + items={items} + itemToString={(item) => (item ? item.text : '')} + /> +
+); + +Default.args = { + defaultWidth: 400, + className: 'test-class', + isCondensed: false, + disabled: false, + invalid: false, + invalidText: + 'Error message that is really long can wrap to more lines but should not be excessively long.', + label: 'Choose an option', + titleText: 'Label', + warn: false, + warnText: + 'Warning message that is really long can wrap to more lines but should not be excessively long.', +}; + +Default.argTypes = { + ...sharedArgTypes, + defaultWidth: { + control: { type: 'range', min: 300, max: 800, step: 50 }, + }, +}; + const ToggleTip = ( <> Label @@ -68,19 +162,6 @@ const ToggleTip = ( ); -export const Default = () => ( -
- {}} - id="default" - titleText="Label" - label="Choose an option" - items={items} - itemToString={(item) => (item ? item.text : '')} - /> -
-); - export const Condensed = () => (
); -export const withAILabel = () => ( +export const withAILabel = (args) => (
{}} @@ -136,102 +217,17 @@ export const withAILabel = () => ( items={items} itemToString={(item) => (item ? item.text : '')} decorator={aiLabel} - /> -
-); - -export const Playground = (args) => ( -
- {}} - id="default" - titleText="Label" - label="Choose an option" - items={items} - itemToString={(item) => (item ? item.text : '')} {...args} /> -
- {}} - id="default-3" - titleText={ToggleTip} - label="Choose an option" - items={items} - itemToString={(item) => (item ? item.text : '')} - />
); +withAILabel.argTypes = { + ...sharedArgTypes, +}; + export const Skeleton = () => (
); - -Playground.args = { - playgroundWidth: 400, - className: 'test-class', - isCondensed: false, - disabled: false, - invalid: false, - invalidText: - 'Error message that is really long can wrap to more lines but should not be excessively long.', - label: 'Choose an option', - titleText: 'Label', - warn: false, - warnText: - 'Warning message that is really long can wrap to more lines but should not be excessively long.', -}; - -Playground.argTypes = { - playgroundWidth: { - control: { type: 'range', min: 300, max: 800, step: 50 }, - }, - className: { - control: { - type: 'text', - }, - }, - isCondensed: { - control: { - type: 'boolean', - }, - }, - disabled: { - control: { - type: 'boolean', - }, - }, - invalid: { - control: { - type: 'boolean', - }, - }, - invalidText: { - control: { - type: 'text', - }, - }, - label: { - control: { - type: 'text', - }, - }, - titleText: { - control: { - type: 'text', - }, - }, - warn: { - control: { - type: 'boolean', - }, - }, - warnText: { - control: { - type: 'text', - }, - }, -}; diff --git a/packages/react/src/components/FluidDatePicker/FluidDatePicker.stories.js b/packages/react/src/components/FluidDatePicker/FluidDatePicker.stories.js index e992d8e91fb5..ef6849c289df 100644 --- a/packages/react/src/components/FluidDatePicker/FluidDatePicker.stories.js +++ b/packages/react/src/components/FluidDatePicker/FluidDatePicker.stories.js @@ -25,143 +25,14 @@ export default { }, }; -const ToggleTip = ( - <> - Label - - - - - -

Additional field information here.

-
-
- -); - -export const Simple = () => ( -
- - - -
-); - -export const Single = () => ( -
- - - -
-); - -export const RangeWithCalendar = () => { - return ( -
- - - - -
- ); -}; - -export const Skeleton = () => ( -
- -
-
- -
-
- -
-); - -export const Playground = (args) => { - const { invalid, invalidText, warn, warnText, disabled, readOnly } = args; - return ( -
- - - - -
-
- - - -
- ); -}; - -Playground.args = { +const sharedArgs = { invalidText: 'Error message that is really long can wrap to more lines but should not be excessively long.', warnText: 'Warning message that is really long can wrap to more lines but should not be excessively long.', }; -Playground.argTypes = { +const sharedArgTypes = { appendTo: { table: { disable: true, @@ -263,3 +134,103 @@ Playground.argTypes = { }, }, }; + +const ToggleTip = ( + <> + Label + + + + + +

Additional field information here.

+
+
+ +); + +export const Simple = (args) => ( +
+ + + +
+); + +Simple.args = { ...sharedArgs }; +Simple.argTypes = { ...sharedArgTypes }; + +export const Single = (args) => ( +
+ + + +
+); + +Single.args = { ...sharedArgs }; +Single.argTypes = { ...sharedArgTypes }; + +export const RangeWithCalendar = (args) => { + return ( +
+ + + + +
+ ); +}; + +RangeWithCalendar.args = { ...sharedArgs }; +RangeWithCalendar.argTypes = { ...sharedArgTypes }; + +export const Skeleton = () => ( +
+ +
+
+ +
+
+ +
+); diff --git a/packages/react/src/components/FluidDropdown/FluidDropdown.stories.js b/packages/react/src/components/FluidDropdown/FluidDropdown.stories.js index fa4d1cf440f8..0ff9908006c0 100644 --- a/packages/react/src/components/FluidDropdown/FluidDropdown.stories.js +++ b/packages/react/src/components/FluidDropdown/FluidDropdown.stories.js @@ -54,6 +54,98 @@ const items = [ }, ]; +const sharedArgTypes = { + className: { + control: { + type: 'text', + }, + }, + isCondensed: { + control: { + type: 'boolean', + }, + }, + disabled: { + control: { + type: 'boolean', + }, + }, + invalid: { + control: { + type: 'boolean', + }, + }, + invalidText: { + control: { + type: 'text', + }, + }, + label: { + control: { + type: 'text', + }, + }, + titleText: { + control: { + type: 'text', + }, + }, + warn: { + control: { + type: 'boolean', + }, + }, + warnText: { + control: { + type: 'text', + }, + }, +}; + +export const Default = (args) => ( +
+ (item ? item.text : '')} + {...args} + /> +
+ (item ? item.text : '')} + /> +
+); + +Default.args = { + defaultWidth: 400, + className: 'test-class', + isCondensed: false, + disabled: false, + invalid: false, + invalidText: + 'Error message that is really long can wrap to more lines but should not be excessively long.', + label: 'Choose an option', + titleText: 'Label', + warn: false, + warnText: + 'Warning message that is really long can wrap to more lines but should not be excessively long.', +}; + +Default.argTypes = { + ...sharedArgTypes, + defaultWidth: { + control: { type: 'range', min: 300, max: 800, step: 50 }, + }, +}; + const ToggleTip = ( <> Label @@ -68,19 +160,6 @@ const ToggleTip = ( ); -export const Default = () => ( -
- (item ? item.text : '')} - /> -
-); - export const Condensed = () => (
); -export const withAILabel = () => ( +export const withAILabel = (args) => (
( items={items} itemToString={(item) => (item ? item.text : '')} decorator={aiLabel} - /> -
-); - -export const Playground = (args) => ( -
- (item ? item.text : '')} {...args} /> -
- (item ? item.text : '')} - />
); +withAILabel.argTypes = { + ...sharedArgTypes, +}; + export const Skeleton = () => (
); - -Playground.args = { - playgroundWidth: 400, - className: 'test-class', - isCondensed: false, - disabled: false, - invalid: false, - invalidText: - 'Error message that is really long can wrap to more lines but should not be excessively long.', - label: 'Choose an option', - titleText: 'Label', - warn: false, - warnText: - 'Warning message that is really long can wrap to more lines but should not be excessively long.', -}; - -Playground.argTypes = { - playgroundWidth: { - control: { type: 'range', min: 300, max: 800, step: 50 }, - }, - className: { - control: { - type: 'text', - }, - }, - isCondensed: { - control: { - type: 'boolean', - }, - }, - disabled: { - control: { - type: 'boolean', - }, - }, - invalid: { - control: { - type: 'boolean', - }, - }, - invalidText: { - control: { - type: 'text', - }, - }, - label: { - control: { - type: 'text', - }, - }, - titleText: { - control: { - type: 'text', - }, - }, - warn: { - control: { - type: 'boolean', - }, - }, - warnText: { - control: { - type: 'text', - }, - }, -}; diff --git a/packages/react/src/components/FluidMultiSelect/FluidMultiSelect.stories.js b/packages/react/src/components/FluidMultiSelect/FluidMultiSelect.stories.js index e06050611ab9..650166c0027e 100644 --- a/packages/react/src/components/FluidMultiSelect/FluidMultiSelect.stories.js +++ b/packages/react/src/components/FluidMultiSelect/FluidMultiSelect.stories.js @@ -59,6 +59,106 @@ const items = [ }, ]; +export const Default = (args) => ( +
+ {}} + id="default" + titleText="Label" + label="Choose an option" + items={items} + itemToString={(item) => (item ? item.text : '')} + {...args} + /> +
+ {}} + id="default-3" + titleText={ToggleTip} + label="Choose an option" + items={items} + itemToString={(item) => (item ? item.text : '')} + /> +
+); + +const sharedArgTypes = { + className: { + control: { + type: 'text', + }, + }, + isCondensed: { + control: { + type: 'boolean', + }, + }, + isFilterable: { + control: { + type: 'boolean', + }, + }, + disabled: { + control: { + type: 'boolean', + }, + }, + invalid: { + control: { + type: 'boolean', + }, + }, + invalidText: { + control: { + type: 'text', + }, + }, + label: { + control: { + type: 'text', + }, + }, + titleText: { + control: { + type: 'text', + }, + }, + warn: { + control: { + type: 'boolean', + }, + }, + warnText: { + control: { + type: 'text', + }, + }, +}; + +Default.args = { + defaultWidth: 400, + className: 'test-class', + isCondensed: false, + isFilterable: false, + disabled: false, + invalid: false, + invalidText: + 'Error message that is really long can wrap to more lines but should not be excessively long.', + label: 'Choose an option', + titleText: 'Label', + warn: false, + warnText: + 'Warning message that is really long can wrap to more lines but should not be excessively long.', +}; + +Default.argTypes = { + ...sharedArgTypes, + defaultWidth: { + control: { type: 'range', min: 300, max: 800, step: 50 }, + }, +}; + const ToggleTip = ( <> Label @@ -73,20 +173,6 @@ const ToggleTip = ( ); -export const Default = () => ( -
- {}} - initialSelectedItem={items[2]} - id="default" - titleText="Label" - label="Choose an option" - items={items} - itemToString={(item) => (item ? item.text : '')} - /> -
-); - export const Filterable = () => (
); -export const withAILabel = () => ( +export const withAILabel = (args) => (
{}} @@ -175,108 +261,17 @@ export const withAILabel = () => ( items={items} itemToString={(item) => (item ? item.text : '')} decorator={aiLabel} - /> -
-); - -export const Playground = (args) => ( -
- {}} - id="default" - titleText="Label" - label="Choose an option" - items={items} - itemToString={(item) => (item ? item.text : '')} {...args} /> -
- {}} - id="default-3" - titleText={ToggleTip} - label="Choose an option" - items={items} - itemToString={(item) => (item ? item.text : '')} - />
); +withAILabel.argTypes = { + ...sharedArgTypes, +}; + export const Skeleton = () => (
); - -Playground.args = { - playgroundWidth: 400, - className: 'test-class', - isCondensed: false, - isFilterable: false, - disabled: false, - invalid: false, - invalidText: - 'Error message that is really long can wrap to more lines but should not be excessively long.', - label: 'Choose an option', - titleText: 'Label', - warn: false, - warnText: - 'Warning message that is really long can wrap to more lines but should not be excessively long.', -}; - -Playground.argTypes = { - playgroundWidth: { - control: { type: 'range', min: 300, max: 800, step: 50 }, - }, - className: { - control: { - type: 'text', - }, - }, - isCondensed: { - control: { - type: 'boolean', - }, - }, - isFilterable: { - control: { - type: 'boolean', - }, - }, - disabled: { - control: { - type: 'boolean', - }, - }, - invalid: { - control: { - type: 'boolean', - }, - }, - invalidText: { - control: { - type: 'text', - }, - }, - label: { - control: { - type: 'text', - }, - }, - titleText: { - control: { - type: 'text', - }, - }, - warn: { - control: { - type: 'boolean', - }, - }, - warnText: { - control: { - type: 'text', - }, - }, -}; diff --git a/packages/react/src/components/FluidNumberInput/FluidNumberInput.stories.js b/packages/react/src/components/FluidNumberInput/FluidNumberInput.stories.js index bb1b94407630..ed116a06276a 100644 --- a/packages/react/src/components/FluidNumberInput/FluidNumberInput.stories.js +++ b/packages/react/src/components/FluidNumberInput/FluidNumberInput.stories.js @@ -37,77 +37,27 @@ const ToggleTip = ( ); -export const Default = () => ( -
- -
-
- -
-
- -
-); - -export const Skeleton = () => ( -
- -
-); - -export const Playground = (args) => ( -
+export const Default = (args) => ( +
); -Playground.args = { - playgroundWidth: 400, +Default.args = { + defaultWidth: 400, defaultValue: 50, invalid: false, invalidText: 'Error message that is really long can wrap to more lines but should not be excessively long.', disabled: false, - label: 'Label', + label: ToggleTip, warn: false, warnText: 'Warning message that is really long can wrap to more lines but should not be excessively long.', }; -Playground.argTypes = { - playgroundWidth: { +Default.argTypes = { + defaultWidth: { control: { type: 'range', min: 300, max: 800, step: 50 }, }, defaultValue: { @@ -146,3 +96,13 @@ Playground.argTypes = { }, }, }; + +export const Skeleton = () => ( +
+ +
+); diff --git a/packages/react/src/components/FluidSearch/FluidSearch.stories.js b/packages/react/src/components/FluidSearch/FluidSearch.stories.js index 32fc233402d0..d41a3e14fc28 100644 --- a/packages/react/src/components/FluidSearch/FluidSearch.stories.js +++ b/packages/react/src/components/FluidSearch/FluidSearch.stories.js @@ -16,40 +16,28 @@ export default { }, }; -export const Default = () => ( -
- -
-); - export const Skeleton = () => (
); -export const Playground = (args) => ( -
+export const Default = (args) => ( +
); -Playground.args = { - playgroundWidth: 400, +Default.args = { + defaultWidth: 400, closeButtonLabelText: 'Clear search input', disabled: false, labelText: 'Search', placeholder: 'Prompt text', }; -Playground.argTypes = { - playgroundWidth: { +Default.argTypes = { + defaultWidth: { control: { type: 'range', min: 300, max: 800, step: 50 }, }, className: { diff --git a/packages/react/src/components/FluidSelect/FluidSelect.stories.js b/packages/react/src/components/FluidSelect/FluidSelect.stories.js index 633e9308ab08..f3507d116388 100644 --- a/packages/react/src/components/FluidSelect/FluidSelect.stories.js +++ b/packages/react/src/components/FluidSelect/FluidSelect.stories.js @@ -66,6 +66,44 @@ export default { }, }; +const sharedArgTypes = { + className: { + control: { + type: 'text', + }, + }, + disabled: { + control: { + type: 'boolean', + }, + }, + invalid: { + control: { + type: 'boolean', + }, + }, + invalidText: { + control: { + type: 'text', + }, + }, + labelText: { + control: { + type: 'text', + }, + }, + warn: { + control: { + type: 'boolean', + }, + }, + warnText: { + control: { + type: 'text', + }, + }, +}; + const ToggleTip = ( <> Select an option @@ -80,33 +118,9 @@ const ToggleTip = ( ); -export const Default = () => ( -
- - - - - - - -

- - - - - - - -

- +export const Default = (args) => ( +
+ @@ -116,6 +130,26 @@ export const Default = () => (
); +Default.args = { + labelText: ToggleTip, + defaultWidth: 400, + className: 'test-class', + disabled: false, + invalid: false, + invalidText: + 'Error message that is really long can wrap to more lines but should not be excessively long.', + warn: false, + warnText: + 'Warning message that is really long can wrap to more lines but should not be excessively long.', +}; + +Default.argTypes = { + ...sharedArgTypes, + defaultWidth: { + control: { type: 'range', min: 300, max: 800, step: 50 }, + }, +}; + const aiLabel = ( @@ -147,9 +181,13 @@ const aiLabel = ( ); -export const withAILabel = () => ( +export const withAILabel = (args) => (
- + (
); -export const Playground = (args) => ( -
- - - - - - - -
-); +withAILabel.argTypes = { ...sharedArgTypes }; export const Skeleton = () => (
); - -Playground.args = { - playgroundWidth: 400, - className: 'test-class', - disabled: false, - invalid: false, - invalidText: - 'Error message that is really long can wrap to more lines but should not be excessively long.', - warn: false, - warnText: - 'Warning message that is really long can wrap to more lines but should not be excessively long.', -}; - -Playground.argTypes = { - playgroundWidth: { - control: { type: 'range', min: 300, max: 800, step: 50 }, - }, - className: { - control: { - type: 'text', - }, - }, - disabled: { - control: { - type: 'boolean', - }, - }, - invalid: { - control: { - type: 'boolean', - }, - }, - invalidText: { - control: { - type: 'text', - }, - }, - labelText: { - control: { - type: 'text', - }, - }, - warn: { - control: { - type: 'boolean', - }, - }, - warnText: { - control: { - type: 'text', - }, - }, -}; diff --git a/packages/react/src/components/FluidTextArea/FluidTextArea.stories.js b/packages/react/src/components/FluidTextArea/FluidTextArea.stories.js index b60f4c9360e9..2685bb7507b1 100644 --- a/packages/react/src/components/FluidTextArea/FluidTextArea.stories.js +++ b/packages/react/src/components/FluidTextArea/FluidTextArea.stories.js @@ -59,75 +59,7 @@ export default { }, }; -export const Default = () => ( - -); - -export const DefaultWithLayers = () => ( - - {(layer) => ( - - )} - -); - -const ToggleTip = ( - <> - Text Area label - - - - - -

Additional field information here.

-
-
- -); - -export const DefaultWithTooltip = () => ( - -); - -export const Skeleton = () => ( -
- -
-); - -export const Playground = (args) => ( -
- -
-); - -Playground.args = { - playgroundWidth: 300, - className: 'test-class', - placeholder: 'Placeholder text', - invalid: false, - invalidText: - 'Error message that is really long can wrap to more lines but should not be excessively long.', - disabled: false, - enableCounter: false, - labelText: 'Text Area label', - maxCount: 500, - warn: false, - warnText: 'This is a warning message.', -}; - -Playground.argTypes = { - playgroundWidth: { - control: { type: 'range', min: 300, max: 800, step: 50 }, - }, +const sharedArgTypes = { className: { control: { type: 'text', @@ -179,3 +111,67 @@ Playground.argTypes = { }, }, }; + +export const Default = (args) => ( +
+ +
+); + +Default.args = { + defaultWidth: 300, + className: 'test-class', + placeholder: 'Placeholder text', + invalid: false, + invalidText: + 'Error message that is really long can wrap to more lines but should not be excessively long.', + disabled: false, + enableCounter: false, + labelText: 'Text Area label', + maxCount: 500, + warn: false, + warnText: 'This is a warning message.', +}; + +Default.argTypes = { + ...sharedArgTypes, + defaultWidth: { + control: { type: 'range', min: 300, max: 800, step: 50 }, + }, +}; + +export const DefaultWithLayers = () => ( + + {(layer) => ( + + )} + +); + +const ToggleTip = ( + <> + Text Area label + + + + + +

Additional field information here.

+
+
+ +); + +export const DefaultWithTooltip = () => ( + +); + +export const Skeleton = () => ( +
+ +
+); diff --git a/packages/react/src/components/FluidTextInput/FluidPasswordInput.stories.js b/packages/react/src/components/FluidTextInput/FluidPasswordInput.stories.js index f226380d2526..5db3a124f170 100644 --- a/packages/react/src/components/FluidTextInput/FluidPasswordInput.stories.js +++ b/packages/react/src/components/FluidTextInput/FluidPasswordInput.stories.js @@ -15,16 +15,8 @@ export default { component: FluidPasswordInput, }; -export const Default = () => ( - -); - -export const Playground = (args) => ( -
+export const Default = (args) => ( +
(
); -Playground.args = { - playgroundWidth: 300, +Default.args = { + defaultWidth: 300, className: 'test-class', placeholder: 'Placeholder text', showPasswordLabel: 'Show password label', @@ -51,8 +43,8 @@ Playground.args = { 'Warning message that is really long can wrap to more lines but should not be excessively long.', }; -Playground.argTypes = { - playgroundWidth: { +Default.argTypes = { + defaultWidth: { control: { type: 'range', min: 300, max: 800, step: 50 }, }, className: { diff --git a/packages/react/src/components/FluidTextInput/FluidTextInput.stories.js b/packages/react/src/components/FluidTextInput/FluidTextInput.stories.js index c95298da0f4f..5a9145bdb082 100644 --- a/packages/react/src/components/FluidTextInput/FluidTextInput.stories.js +++ b/packages/react/src/components/FluidTextInput/FluidTextInput.stories.js @@ -25,14 +25,6 @@ export default { }, }; -export const Default = () => ( - -); - const ToggleTip = ( <> Label @@ -47,28 +39,14 @@ const ToggleTip = ( ); -export const DefaultWithTooltip = () => ( - -); - -export const Skeleton = () => ( -
- -
-); - -export const Playground = (args) => ( -
+export const Default = (args) => ( +
); -Playground.args = { - playgroundWidth: 300, +Default.args = { + defaultWidth: 300, className: 'test-class', placeholder: 'Placeholder text', invalid: false, @@ -81,8 +59,8 @@ Playground.args = { 'Warning message that is really long can wrap to more lines but should not be excessively long.', }; -Playground.argTypes = { - playgroundWidth: { +Default.argTypes = { + defaultWidth: { control: { type: 'range', min: 300, max: 800, step: 50 }, }, className: { @@ -141,3 +119,17 @@ Playground.argTypes = { }, }, }; + +export const DefaultWithTooltip = () => ( + +); + +export const Skeleton = () => ( +
+ +
+); diff --git a/packages/react/src/components/FluidTimePicker/FluidTimePicker.stories.js b/packages/react/src/components/FluidTimePicker/FluidTimePicker.stories.js index 82b8ed096f2e..819c884fbaff 100644 --- a/packages/react/src/components/FluidTimePicker/FluidTimePicker.stories.js +++ b/packages/react/src/components/FluidTimePicker/FluidTimePicker.stories.js @@ -41,101 +41,6 @@ const ToggleTip = ( ); -export const Default = () => ( -
-
- - - - - - - - - - - - -
-
- - - - - - -
-
-
-
- - - - - - - - - - - - -
-
- - - - - - -
-
-
-
- - - - - - - - - - - - -
-
- - - - - - -
-
-); - export const Skeleton = () => (
@@ -145,7 +50,7 @@ export const Skeleton = () => (
); -export const Playground = (args) => { +export const Default = (args) => { return (
@@ -176,7 +81,7 @@ export const Playground = (args) => { ); }; -Playground.args = { +Default.args = { labelText: 'Time', invalidText: 'Error message that is really long can wrap to more lines but should not be excessively long.', @@ -185,7 +90,7 @@ Playground.args = { 'Warning message that is really long can wrap to more lines but should not be excessively long.', }; -Playground.argTypes = { +Default.argTypes = { children: { table: { disable: true, diff --git a/packages/react/src/components/FormGroup/FormGroup.stories.js b/packages/react/src/components/FormGroup/FormGroup.stories.js index 6b5018367bbd..aeace1fa2005 100644 --- a/packages/react/src/components/FormGroup/FormGroup.stories.js +++ b/packages/react/src/components/FormGroup/FormGroup.stories.js @@ -40,25 +40,7 @@ export default { }, }; -export const Default = () => ( - - - - - - - - - - - - -); - -export const Playground = (args) => ( +export const Default = (args) => ( @@ -76,7 +58,7 @@ export const Playground = (args) => ( ); -Playground.argTypes = { +Default.argTypes = { legendId: { control: { type: 'text', @@ -99,7 +81,7 @@ Playground.argTypes = { }, }; -Playground.args = { +Default.args = { legendId: 'form-group-1', legendText: 'FormGroup Legend', message: false, diff --git a/packages/react/src/components/Grid/FlexGrid.stories.js b/packages/react/src/components/Grid/FlexGrid.stories.js index 94580021c584..4613aaaf16bb 100644 --- a/packages/react/src/components/Grid/FlexGrid.stories.js +++ b/packages/react/src/components/Grid/FlexGrid.stories.js @@ -297,7 +297,7 @@ export const MixedGutterModes = () => ( ); -export const Playground = (args) => ( +export const Default = (args) => ( @@ -316,14 +316,14 @@ export const Playground = (args) => ( ); -Playground.args = { +Default.args = { as: 'div', fullWidth: false, narrow: false, condensed: false, }; -Playground.argTypes = { +Default.argTypes = { as: { control: { type: 'text', diff --git a/packages/react/src/components/Grid/Grid.stories.js b/packages/react/src/components/Grid/Grid.stories.js index db6e7b489751..3c770ef8bb39 100644 --- a/packages/react/src/components/Grid/Grid.stories.js +++ b/packages/react/src/components/Grid/Grid.stories.js @@ -36,15 +36,49 @@ export default { ], }; -export const Default = () => { - return ( - - - - - - - ); +export const Default = (args) => ( + + + + + + +); + +Default.args = { + as: 'div', + fullWidth: false, + narrow: false, + condensed: false, +}; + +Default.argTypes = { + as: { + control: { + type: 'text', + }, + }, + children: { + control: false, + }, + className: { + control: false, + }, + fullWidth: { + control: { + type: 'boolean', + }, + }, + narrow: { + control: { + type: 'boolean', + }, + }, + condensed: { + control: { + type: 'boolean', + }, + }, }; export const Narrow = () => { @@ -272,48 +306,3 @@ export const Offset = () => ( /> ); - -export const Playground = (args) => ( - - - - - - -); - -Playground.args = { - as: 'div', - fullWidth: false, - narrow: false, - condensed: false, -}; - -Playground.argTypes = { - as: { - control: { - type: 'text', - }, - }, - children: { - control: false, - }, - className: { - control: false, - }, - fullWidth: { - control: { - type: 'boolean', - }, - }, - narrow: { - control: { - type: 'boolean', - }, - }, - condensed: { - control: { - type: 'boolean', - }, - }, -}; diff --git a/packages/react/src/components/IconButton/IconButton.stories.js b/packages/react/src/components/IconButton/IconButton.stories.js index 7a7406d506ee..526d7d9f93cf 100644 --- a/packages/react/src/components/IconButton/IconButton.stories.js +++ b/packages/react/src/components/IconButton/IconButton.stories.js @@ -36,15 +36,7 @@ export default { }, }; -export const Default = () => ( -
- - - -
-); - -const PlaygroundStory = (props) => { +const DefaultStory = (props) => { const { align, defaultOpen, disabled, kind, label, size } = props; return (
@@ -61,9 +53,9 @@ const PlaygroundStory = (props) => { ); }; -export const Playground = PlaygroundStory.bind({}); +export const Default = DefaultStory.bind({}); -Playground.args = { +Default.args = { align: 'bottom', defaultOpen: true, disabled: false, @@ -71,7 +63,7 @@ Playground.args = { kind: 'primary', }; -Playground.argTypes = { +Default.argTypes = { align: { options: [ 'top', diff --git a/packages/react/src/components/Icons/Icons.stories.js b/packages/react/src/components/Icons/Icons.stories.js index 32751beb249d..953d396234fa 100644 --- a/packages/react/src/components/Icons/Icons.stories.js +++ b/packages/react/src/components/Icons/Icons.stories.js @@ -14,36 +14,22 @@ export default { title: 'Elements/Icons', }; -export const Default = () => { +export const Default = (args) => { return ( - <> -
-

16 pixel (default)

- -
- -
-

20 pixel

- -
- -
-

32 pixel

- -
- +
+

+ {args.size} pixel {args.size === 16 ? '(default)' : ''} +

+ +
); }; -export const Playground = (args) => { - return ; -}; - -Playground.args = { +Default.args = { size: 16, }; -Playground.argTypes = { +Default.argTypes = { size: { options: ['16', '20', '32'], control: { type: 'select' }, diff --git a/packages/react/src/components/InlineLoading/InlineLoading.stories.js b/packages/react/src/components/InlineLoading/InlineLoading.stories.js index 5b999ffbadd3..b0cd2f0b1f45 100644 --- a/packages/react/src/components/InlineLoading/InlineLoading.stories.js +++ b/packages/react/src/components/InlineLoading/InlineLoading.stories.js @@ -20,14 +20,6 @@ export default { }, }; -export const Default = () => ( - -); - export const UxExample = () => { function MockSubmission({ children }) { const [isSubmitting, setIsSubmitting] = useState(false); @@ -85,14 +77,14 @@ export const UxExample = () => { ); }; -export const Playground = (args) => ; +export const Default = (args) => ; -Playground.args = { +Default.args = { description: 'Loading', iconDescription: 'Loading data...', }; -Playground.argTypes = { +Default.argTypes = { className: { table: { disable: true, diff --git a/packages/react/src/components/Layer/Layer.stories.js b/packages/react/src/components/Layer/Layer.stories.js index 19feb908072b..f3f588f48187 100644 --- a/packages/react/src/components/Layer/Layer.stories.js +++ b/packages/react/src/components/Layer/Layer.stories.js @@ -61,18 +61,22 @@ export const Default = () => { ); }; -export const CustomLevel = () => { +export const CustomLevel = (args) => { function TestComponent() { return
Test component
; } return ( - + ); }; +CustomLevel.args = { + level: 2, +}; + export const UseLayer = () => { function ExampleComponent() { const { level } = useLayer(); @@ -96,17 +100,3 @@ export const UseLayer = () => { UseLayer.story = { name: 'useLayer', }; - -const PlaygroundStory = (args) => { - function TestComponent() { - return
Test component
; - } - - return ( - - - - ); -}; - -export const Playground = PlaygroundStory.bind({}); diff --git a/packages/react/src/components/Link/Link.stories.js b/packages/react/src/components/Link/Link.stories.js index 38afe5a4198c..60f9811495a5 100644 --- a/packages/react/src/components/Link/Link.stories.js +++ b/packages/react/src/components/Link/Link.stories.js @@ -40,7 +40,11 @@ export default { }, }; -export const Default = () => Link; +export const Default = (args) => ( + + Link + +); export const Inline = () => ( <> @@ -64,14 +68,11 @@ export const Inline = () => ( ); -export const PairedWithIcon = () => ( - }> +export const PairedWithIcon = (args) => ( + } + {...args}> Carbon Docs ); - -export const Playground = (args) => ( - - Link - -); diff --git a/packages/react/src/components/Loading/Loading.stories.js b/packages/react/src/components/Loading/Loading.stories.js index fabd7d250680..501b699bb4a2 100644 --- a/packages/react/src/components/Loading/Loading.stories.js +++ b/packages/react/src/components/Loading/Loading.stories.js @@ -19,22 +19,18 @@ export default { }, }; -export const Default = () => { - return ; -}; - -export const Playground = (args) => { +export const Default = (args) => { return ; }; -Playground.args = { +Default.args = { active: true, withOverlay: false, small: false, description: 'Loading', }; -Playground.argTypes = { +Default.argTypes = { children: { table: { disable: true, diff --git a/packages/react/src/components/Menu/Menu.stories.js b/packages/react/src/components/Menu/Menu.stories.js index ca8350754de4..80a9ca1bf264 100644 --- a/packages/react/src/components/Menu/Menu.stories.js +++ b/packages/react/src/components/Menu/Menu.stories.js @@ -40,7 +40,7 @@ export default { }, }; -export const Playground = (args) => { +export const Default = (args) => { const itemOnClick = action('onClick (MenuItem)'); const selectableOnChange = action('onChange (MenuItemSelectable)'); const radioOnChange = action('onChange (MenuItemRadioGroup)'); @@ -88,12 +88,12 @@ export const Playground = (args) => { ); }; -Playground.args = { +Default.args = { onClose: action('onClose'), open: true, }; -Playground.argTypes = { +Default.argTypes = { target: { table: { disable: true, diff --git a/packages/react/src/components/MenuButton/MenuButton.stories.js b/packages/react/src/components/MenuButton/MenuButton.stories.js index 6c9d0eb932e2..18ffd5b36900 100644 --- a/packages/react/src/components/MenuButton/MenuButton.stories.js +++ b/packages/react/src/components/MenuButton/MenuButton.stories.js @@ -29,21 +29,51 @@ export default { }, }; -export const Default = () => ( - - - - - -); -export const ExperimentalAutoAlign = () => ( +const sharedArgTypes = { + children: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + menuTarget: { + table: { + disable: true, + }, + }, +}; + +export const Default = (args) => { + const onClick = action('onClick (MenuItem)'); + + return ( + + + + + + ); +}; + +Default.args = { label: 'Actions' }; + +Default.argTypes = { ...sharedArgTypes }; + +export const ExperimentalAutoAlign = (args) => (
- + @@ -51,8 +81,11 @@ export const ExperimentalAutoAlign = () => (
); -export const WithDanger = () => ( - + +ExperimentalAutoAlign.argTypes = { ...sharedArgTypes }; + +export const WithDanger = (args) => ( + @@ -61,8 +94,10 @@ export const WithDanger = () => ( ); -export const WithDividers = () => ( - +WithDanger.argTypes = { ...sharedArgTypes }; + +export const WithDividers = (args) => ( + @@ -74,14 +109,18 @@ export const WithDividers = () => ( ); -export const WithIcons = () => ( - +WithDividers.argTypes = { ...sharedArgTypes }; + +export const WithIcons = (args) => ( + ); +WithIcons.argTypes = { ...sharedArgTypes }; + export const WithMenuAlignment = () => ( <>
@@ -130,40 +169,3 @@ export const WithMenuAlignment = () => (
); - -export const Playground = (args) => { - const onClick = action('onClick (MenuItem)'); - - return ( - - - - - - ); -}; - -Playground.args = { - label: 'Actions', -}; - -Playground.argTypes = { - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - menuTarget: { - table: { - disable: true, - }, - }, -}; diff --git a/packages/react/src/components/Modal/Modal.stories.js b/packages/react/src/components/Modal/Modal.stories.js index 176c3049aa25..c30eb8fe57be 100644 --- a/packages/react/src/components/Modal/Modal.stories.js +++ b/packages/react/src/components/Modal/Modal.stories.js @@ -44,294 +44,13 @@ export default { }, }; -export const Default = () => { - const [open, setOpen] = useState(true); - const [openPopover, setOpenPopover] = useState(false); - const menuTargetref = useRef(null); - return ( - <> - - setOpen(false)} - modalHeading="Add a custom domain" - modalLabel="Account resources" - primaryButtonText="Add" - secondaryButtonText="Cancel"> -

- Custom domains direct requests for your apps in this Cloud Foundry - organization to a URL that you own. A custom domain can be a shared - domain, a shared subdomain, or a shared domain and host. -

- -
- { - setOpenPopover(!openPopover); - }} - /> -
- -
-

This popover uses autoAlign

-

- Scroll the container up, down, left or right to observe how the - popover will automatically change its position in attempt to - stay within the viewport. This works on initial render in - addition to on scroll. -

-
-
-
- - - -
-
- - - - - - -
-
- (item ? item.text : '')} - /> -
- - ); -}; - -export const FullWidth = () => { - const [open, setOpen] = useState(true); - return ( - <> - - setOpen(false)} - isFullWidth - modalHeading="Full Width Modal" - modalLabel="An example of a modal with no padding" - primaryButtonText="Add" - secondaryButtonText="Cancel"> - - - - - Column A - - - Column B - - - Column C - - - - - - Row 1 - Row 1 - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc - dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean - posuere sem vel euismod dignissim. Nulla ut cursus dolor. - Pellentesque vulputate nisl a porttitor interdum. - - - - Row 2 - Row 2 - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc - dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean - posuere sem vel euismod dignissim. Nulla ut cursus dolor. - Pellentesque vulputate nisl a porttitor interdum. - - - - Row 3 - Row 3 - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc - dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean - posuere sem vel euismod dignissim. Nulla ut cursus dolor. - Pellentesque vulputate nisl a porttitor interdum. - - - - - - - ); -}; - -export const DangerModal = () => { - const [open, setOpen] = useState(true); - return ( - <> - - setOpen(false)} - danger - modalHeading="Are you sure you want to delete this custom domain?" - modalLabel="Account resources" - primaryButtonText="Delete" - secondaryButtonText="Cancel" - /> - - ); -}; - const buttons = { 'One (1)': '1', 'Two (2)': '2', 'Three (3)': '3', }; -const modalFooter = (numberOfButtons) => { - const secondaryButtons = () => { - switch (numberOfButtons) { - case '1': - return { - secondaryButtons: [], - }; - case '2': - return { - secondaryButtonText: 'Cancel', - }; - case '3': - return { - secondaryButtons: [ - { - buttonText: 'Keep both', - onClick: action('onClick'), - }, - { - buttonText: 'Rename', - onClick: action('onClick'), - }, - ], - }; - default: - return null; - } - }; - return { - ...secondaryButtons(), - }; -}; - -export const WithScrollingContent = () => { - const [open, setOpen] = useState(true); - return ( - <> - - setOpen(false)} - hasScrollingContent - modalHeading="Add a custom domain" - modalLabel="Account resources" - primaryButtonText="Add" - secondaryButtonText="Cancel"> -

- Custom domains direct requests for your apps in this Cloud Foundry - organization to a URL that you own. A custom domain can be a shared - domain, a shared subdomain, or a shared domain and host. -

-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu - nibh odio. Nunc a consequat est, id porttitor sapien. Proin vitae leo - vitae orci tincidunt auctor eget eget libero. Ut tincidunt ultricies - fringilla. Aliquam erat volutpat. Aenean arcu odio, elementum vel - vehicula vitae, porttitor ac lorem. Sed viverra elit ac risus - tincidunt fermentum. Ut sollicitudin nibh id risus ornare ornare. - Etiam gravida orci ut lectus dictum, quis ultricies felis mollis. - Mauris nec commodo est, nec faucibus nibh. Nunc commodo ante quis - pretium consectetur. Ut ac nisl vitae mi mattis vulputate a at elit. - Nullam porttitor ex eget mi feugiat mattis. Nunc non sodales magna. - Proin ornare tellus quis hendrerit egestas. Donec pharetra leo nec - molestie sollicitudin.{' '} -

- -
- -
- - (item ? item.text : '')} - /> -
- - ); -}; -export const Playground = ({ numberOfButtons, ...args }) => { +export const Default = ({ numberOfButtons, ...args }) => { const [open, setOpen] = useState(true); const [popoverOpen, setPopoverOpen] = useState(false); return ( @@ -465,7 +184,7 @@ export const Playground = ({ numberOfButtons, ...args }) => {

-
+
{ setPopoverOpen(!popoverOpen); @@ -555,11 +274,11 @@ export const Playground = ({ numberOfButtons, ...args }) => { ); }; -Playground.args = { +Default.args = { numberOfButtons: 'Two (2)', }; -Playground.argTypes = { +Default.argTypes = { children: { table: { disable: true, @@ -628,6 +347,198 @@ Playground.argTypes = { }, }; +export const FullWidth = () => { + const [open, setOpen] = useState(true); + return ( + <> + + setOpen(false)} + isFullWidth + modalHeading="Full Width Modal" + modalLabel="An example of a modal with no padding" + primaryButtonText="Add" + secondaryButtonText="Cancel"> + + + + + Column A + + + Column B + + + Column C + + + + + + Row 1 + Row 1 + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc + dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean + posuere sem vel euismod dignissim. Nulla ut cursus dolor. + Pellentesque vulputate nisl a porttitor interdum. + + + + Row 2 + Row 2 + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc + dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean + posuere sem vel euismod dignissim. Nulla ut cursus dolor. + Pellentesque vulputate nisl a porttitor interdum. + + + + Row 3 + Row 3 + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc + dui magna, finibus id tortor sed, aliquet bibendum augue. Aenean + posuere sem vel euismod dignissim. Nulla ut cursus dolor. + Pellentesque vulputate nisl a porttitor interdum. + + + + + + + ); +}; + +export const DangerModal = () => { + const [open, setOpen] = useState(true); + return ( + <> + + setOpen(false)} + danger + modalHeading="Are you sure you want to delete this custom domain?" + modalLabel="Account resources" + primaryButtonText="Delete" + secondaryButtonText="Cancel" + /> + + ); +}; + +const modalFooter = (numberOfButtons) => { + const secondaryButtons = () => { + switch (numberOfButtons) { + case '1': + return { + secondaryButtons: [], + }; + case '2': + return { + secondaryButtonText: 'Cancel', + }; + case '3': + return { + secondaryButtons: [ + { + buttonText: 'Keep both', + onClick: action('onClick'), + }, + { + buttonText: 'Rename', + onClick: action('onClick'), + }, + ], + }; + default: + return null; + } + }; + return { + ...secondaryButtons(), + }; +}; + +export const WithScrollingContent = () => { + const [open, setOpen] = useState(true); + return ( + <> + + setOpen(false)} + hasScrollingContent + modalHeading="Add a custom domain" + modalLabel="Account resources" + primaryButtonText="Add" + secondaryButtonText="Cancel"> +

+ Custom domains direct requests for your apps in this Cloud Foundry + organization to a URL that you own. A custom domain can be a shared + domain, a shared subdomain, or a shared domain and host. +

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu + nibh odio. Nunc a consequat est, id porttitor sapien. Proin vitae leo + vitae orci tincidunt auctor eget eget libero. Ut tincidunt ultricies + fringilla. Aliquam erat volutpat. Aenean arcu odio, elementum vel + vehicula vitae, porttitor ac lorem. Sed viverra elit ac risus + tincidunt fermentum. Ut sollicitudin nibh id risus ornare ornare. + Etiam gravida orci ut lectus dictum, quis ultricies felis mollis. + Mauris nec commodo est, nec faucibus nibh. Nunc commodo ante quis + pretium consectetur. Ut ac nisl vitae mi mattis vulputate a at elit. + Nullam porttitor ex eget mi feugiat mattis. Nunc non sodales magna. + Proin ornare tellus quis hendrerit egestas. Donec pharetra leo nec + molestie sollicitudin.{' '} +

+ +
+ +
+ + (item ? item.text : '')} + /> +
+ + ); +}; + export const WithStateManager = () => { /** * Simple state manager for modals. diff --git a/packages/react/src/components/MultiSelect/MultiSelect.stories.js b/packages/react/src/components/MultiSelect/MultiSelect.stories.js index 819d32671c8c..ff22380feb1e 100644 --- a/packages/react/src/components/MultiSelect/MultiSelect.stories.js +++ b/packages/react/src/components/MultiSelect/MultiSelect.stories.js @@ -116,37 +116,7 @@ const items = [ }, ]; -export const Playground = (args) => { - const ref = useRef(); - useEffect(() => { - ref?.current?.scrollIntoView({ block: 'center', inline: 'center' }); - }); - return ( -
-
- (item ? item.text : '')} - selectionFeedback="top-after-reopen" - ref={ref} - {...args} - /> -
-
- ); -}; - -Playground.args = { +const sharedArgs = { size: 'md', autoAlign: false, type: 'default', @@ -166,7 +136,7 @@ Playground.args = { selectAllItemText: 'All options', }; -Playground.argTypes = { +const sharedArgTypes = { selectionFeedback: { options: ['top', 'fixed', 'top-after-reopen'], control: { type: 'select' }, @@ -243,7 +213,7 @@ Playground.argTypes = { }, }; -export const Default = () => { +export const Default = (args) => { return (
{ items={items} itemToString={(item) => (item ? item.text : '')} selectionFeedback="top-after-reopen" + {...args} />
); }; -export const WithInitialSelectedItems = () => { +Default.args = { ...sharedArgs }; +Default.argTypes = { ...sharedArgTypes }; + +export const WithInitialSelectedItems = (args) => { return (
{ itemToString={(item) => (item ? item.text : '')} initialSelectedItems={[items[0], items[1]]} selectionFeedback="top-after-reopen" + {...args} />
); @@ -310,7 +285,7 @@ Filterable.argTypes = { }, }; -export const WithLayerMultiSelect = () => ( +export const WithLayerMultiSelect = (args) => ( {(layer) => (
@@ -322,13 +297,14 @@ export const WithLayerMultiSelect = () => ( items={items} itemToString={(item) => (item ? item.text : '')} selectionFeedback="top-after-reopen" + {...args} />
)}
); -export const _FilterableWithLayer = () => ( +export const _FilterableWithLayer = (args) => ( {(layer) => (
@@ -339,13 +315,14 @@ export const _FilterableWithLayer = () => ( items={items} itemToString={(item) => (item ? item.text : '')} selectionFeedback="top-after-reopen" + {...args} />
)}
); -export const _Controlled = () => { +export const _Controlled = (args) => { const [selectedItems, setSelectedItems] = useState( items.filter((item) => item.id === 'downshift-1-item-0') ); @@ -366,6 +343,7 @@ export const _Controlled = () => { onChange={(data) => onSelectionChanged(data.selectedItems)} itemToString={(item) => (item ? item.text : '')} selectionFeedback="top-after-reopen" + {...args} />
@@ -412,7 +390,7 @@ const itemsWithSelectAll = [ }, ]; -export const SelectAll = () => { +export const SelectAll = (args) => { const [label, setLabel] = useState('Choose options'); const onChange = (value) => { @@ -436,6 +414,7 @@ export const SelectAll = () => { itemToString={(item) => (item ? item.text : '')} selectionFeedback="top-after-reopen" onChange={onChange} + {...args} />
); @@ -487,7 +466,7 @@ export const withAILabel = () => (
); -export const FilterableWithAILabel = () => ( +export const FilterableWithAILabel = (args) => (
( itemToString={(item) => (item ? item.text : '')} selectionFeedback="top-after-reopen" decorator={aiLabel} + {...args} />
); -export const ExperimentalAutoAlign = () => { +export const ExperimentalAutoAlign = (args) => { const ref = useRef(); useEffect(() => { ref?.current?.scrollIntoView({ block: 'center', inline: 'center' }); @@ -526,8 +506,11 @@ export const ExperimentalAutoAlign = () => { selectionFeedback="top-after-reopen" ref={ref} autoAlign + {...args} />
); }; + +ExperimentalAutoAlign.argTypes = { ...sharedArgTypes }; diff --git a/packages/react/src/components/Notification/stories/ActionableNotification.stories.js b/packages/react/src/components/Notification/stories/ActionableNotification.stories.js index 5000132db918..3367ac0854cf 100644 --- a/packages/react/src/components/Notification/stories/ActionableNotification.stories.js +++ b/packages/react/src/components/Notification/stories/ActionableNotification.stories.js @@ -30,27 +30,9 @@ export default { }, }; -export const Default = () => ( - -); +export const Default = (args) => ; Default.argTypes = { - hasFocus: { - table: { - disable: true, - }, - }, -}; - -export const Playground = (args) => ; - -Playground.argTypes = { ['aria-label']: { table: { disable: true, @@ -86,7 +68,7 @@ Playground.argTypes = { }, }, }; -Playground.args = { +Default.args = { actionButtonLabel: 'Action', inline: false, title: 'Notification title', diff --git a/packages/react/src/components/Notification/stories/InlineNotification.stories.js b/packages/react/src/components/Notification/stories/InlineNotification.stories.js index 029e283b07e9..5ebda2cc0424 100644 --- a/packages/react/src/components/Notification/stories/InlineNotification.stories.js +++ b/packages/react/src/components/Notification/stories/InlineNotification.stories.js @@ -30,16 +30,9 @@ export default { }, }; -export const Default = () => ( - -); +export const Default = (args) => ; -export const Playground = (args) => ; - -Playground.argTypes = { +Default.argTypes = { actionButtonLabel: { table: { disable: true, @@ -77,7 +70,7 @@ Playground.argTypes = { }, }, }; -Playground.args = { +Default.args = { title: 'Notification title', subtitle: 'Subtitle text goes here', }; diff --git a/packages/react/src/components/Notification/stories/ToastNotification.stories.js b/packages/react/src/components/Notification/stories/ToastNotification.stories.js index 222908698645..ea37a4b1efe8 100644 --- a/packages/react/src/components/Notification/stories/ToastNotification.stories.js +++ b/packages/react/src/components/Notification/stories/ToastNotification.stories.js @@ -30,19 +30,9 @@ export default { }, }; -export const Default = () => ( - -); +export const Default = (args) => ; -export const Playground = (args) => ; - -Playground.argTypes = { +Default.argTypes = { actionButtonLabel: { table: { disable: true, @@ -80,7 +70,7 @@ Playground.argTypes = { }, }, }; -Playground.args = { +Default.args = { role: 'status', caption: '00:00:00 AM', timeout: 0, diff --git a/packages/react/src/components/NumberInput/NumberInput.mdx b/packages/react/src/components/NumberInput/NumberInput.mdx index 87d94ed5aaa2..27bd8b1795a6 100644 --- a/packages/react/src/components/NumberInput/NumberInput.mdx +++ b/packages/react/src/components/NumberInput/NumberInput.mdx @@ -20,7 +20,7 @@ import * as NumberInputStories from './NumberInput.stories'; ## Overview - + ## Skeleton State diff --git a/packages/react/src/components/NumberInput/NumberInput.stories.js b/packages/react/src/components/NumberInput/NumberInput.stories.js index 94e87ce75881..0b2b754174bb 100644 --- a/packages/react/src/components/NumberInput/NumberInput.stories.js +++ b/packages/react/src/components/NumberInput/NumberInput.stories.js @@ -23,20 +23,88 @@ export default { }, }; -export const Default = () => { +const sharedArgTypes = { + className: { + table: { + disable: true, + }, + }, + min: { control: { type: 'number' } }, + max: { control: { type: 'number' } }, + step: { control: { type: 'number' } }, + disabled: { control: { type: 'boolean' } }, + invalid: { control: { type: 'boolean' } }, + invalidText: { control: { type: 'text' } }, + warn: { control: { type: 'boolean' } }, + warnText: { control: { type: 'text' } }, + size: { + options: ['sm', 'md', 'lg'], + control: { type: 'select' }, + }, + label: { control: { type: 'text' } }, + helperText: { control: { type: 'text' } }, + id: { + table: { + disable: true, + }, + }, + defaultValue: { + table: { + disable: true, + }, + }, + light: { + table: { + disable: true, + }, + }, + slug: { + table: { + disable: true, + }, + }, + translateWithId: { + table: { + disable: true, + }, + }, +}; + +export const Default = ({ ...args }) => { + const [value, setValue] = React.useState(50); + + const handleChange = (event, { value }) => { + setValue(value); + }; + return ( ); }; +Default.args = { + step: 1, + disabled: false, + invalid: false, + invalidText: 'Number is not valid', + helperText: 'Optional helper text.', + warn: false, + warnText: + 'Warning message that is really long can wrap to more lines but should not be excessively long.', + size: 'md', +}; + +Default.argTypes = { ...sharedArgTypes }; + const aiLabel = ( @@ -68,7 +136,7 @@ const aiLabel = ( ); -export const withAILabel = () => ( +export const withAILabel = (args) => (
( helperText="Optional helper text." invalidText="Number is not valid" decorator={aiLabel} + {...args} />
); -export const Skeleton = () => ; -export const Playground = ({ ...args }) => { - const [value, setValue] = React.useState(50); - const handleChange = (event, { value }) => { - setValue(value); - }; - - return ( - - ); -}; - -Playground.args = { - step: 1, - disabled: false, - invalid: false, - invalidText: 'Number is not valid', - helperText: 'Optional helper text.', - warn: false, - warnText: - 'Warning message that is really long can wrap to more lines but should not be excessively long.', - size: 'md', -}; +withAILabel.argTypes = { ...sharedArgTypes }; -Playground.argTypes = { - className: { - table: { - disable: true, - }, - }, - min: { control: { type: 'number' } }, - max: { control: { type: 'number' } }, - step: { control: { type: 'number' } }, - disabled: { control: { type: 'boolean' } }, - invalid: { control: { type: 'boolean' } }, - invalidText: { control: { type: 'text' } }, - warn: { control: { type: 'boolean' } }, - warnText: { control: { type: 'text' } }, - size: { - options: ['sm', 'md', 'lg'], - control: { type: 'select' }, - }, - label: { control: { type: 'text' } }, - helperText: { control: { type: 'text' } }, - id: { - table: { - disable: true, - }, - }, - defaultValue: { - table: { - disable: true, - }, - }, - light: { - table: { - disable: true, - }, - }, - slug: { - table: { - disable: true, - }, - }, - translateWithId: { - table: { - disable: true, - }, - }, -}; +export const Skeleton = () => ; diff --git a/packages/react/src/components/OrderedList/OrderedList.mdx b/packages/react/src/components/OrderedList/OrderedList.mdx index 15fe53768bf2..3e1d81e8a417 100644 --- a/packages/react/src/components/OrderedList/OrderedList.mdx +++ b/packages/react/src/components/OrderedList/OrderedList.mdx @@ -16,7 +16,7 @@ import * as OrderedListStories from './OrderedList.stories'; ## Overview
- +
## Component API diff --git a/packages/react/src/components/OrderedList/OrderedList.stories.js b/packages/react/src/components/OrderedList/OrderedList.stories.js index 8e0a51978638..49f2da52c1d2 100644 --- a/packages/react/src/components/OrderedList/OrderedList.stories.js +++ b/packages/react/src/components/OrderedList/OrderedList.stories.js @@ -16,8 +16,8 @@ export default { }, }; -export const Default = () => ( - +export const Default = (args) => ( + Ordered List level 1 Ordered List level 1 Ordered List level 1 @@ -34,6 +34,40 @@ export const Default = () => ( ); +Default.args = { + isExpressive: false, + native: false, + nested: false, +}; + +Default.argTypes = { + children: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + isExpressive: { + control: { + type: 'boolean', + }, + }, + native: { + control: { + type: 'boolean', + }, + }, + nested: { + control: { + type: 'boolean', + }, + }, +}; + export const Nested = () => { return ( @@ -82,55 +116,3 @@ export const NativeListStyles = () => { ); }; - -export const Playground = (args) => ( - - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - Ordered List level 1 - -); - -Playground.args = { - isExpressive: false, - native: false, - nested: false, -}; - -Playground.argTypes = { - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - isExpressive: { - control: { - type: 'boolean', - }, - }, - native: { - control: { - type: 'boolean', - }, - }, - nested: { - control: { - type: 'boolean', - }, - }, -}; diff --git a/packages/react/src/components/OverflowMenu/OverflowMenu.stories.js b/packages/react/src/components/OverflowMenu/OverflowMenu.stories.js index a392f665a166..ab0066baee09 100644 --- a/packages/react/src/components/OverflowMenu/OverflowMenu.stories.js +++ b/packages/react/src/components/OverflowMenu/OverflowMenu.stories.js @@ -24,17 +24,6 @@ export default { }, }; -export const Default = () => ( - - - - - - - - -); - export const RenderCustomIcon = () => ( @@ -42,7 +31,7 @@ export const RenderCustomIcon = () => ( ); -export const Playground = (args) => ( +export const Default = (args) => ( @@ -53,13 +42,13 @@ export const Playground = (args) => ( ); -Playground.args = { +Default.args = { flipped: document?.dir === 'rtl', focusTrap: false, open: false, }; -Playground.argTypes = { +Default.argTypes = { ariaLabel: { table: { disable: true, diff --git a/packages/react/src/components/Pagination/Pagination.stories.js b/packages/react/src/components/Pagination/Pagination.stories.js index e42e9870fe07..ec897dd7c7a5 100644 --- a/packages/react/src/components/Pagination/Pagination.stories.js +++ b/packages/react/src/components/Pagination/Pagination.stories.js @@ -39,59 +39,9 @@ export default { decorators: [(story) =>
{story()}
], }; -export const Default = (args) => ; +export const Default = (args) => ; -export const MultiplePaginationComponents = (args) => { - return ( -
- - -
- ); -}; - -MultiplePaginationComponents.storyName = 'Multiple Pagination components'; - -export const PaginationWithCustomPageSizesLabel = (args) => { - return ( -
- -
- ); -}; - -PaginationWithCustomPageSizesLabel.storyName = - 'Pagination with custom page sizes label'; - -export const PaginationUnknownPages = (args) => { - return ( -
- -
- ); -}; - -PaginationUnknownPages.storyName = 'Unknown pages and items'; - -export const Playground = (args) => ; - -Playground.args = { +Default.args = { backwardText: 'Previous page', forwardText: 'Next page', disabled: false, @@ -107,7 +57,7 @@ Playground.args = { totalItems: 103, }; -Playground.argTypes = { +Default.argTypes = { className: { control: false, }, @@ -187,3 +137,51 @@ Playground.argTypes = { }, }, }; + +export const MultiplePaginationComponents = (args) => { + return ( +
+ + +
+ ); +}; + +MultiplePaginationComponents.storyName = 'Multiple Pagination components'; + +export const PaginationWithCustomPageSizesLabel = (args) => { + return ( +
+ +
+ ); +}; + +PaginationWithCustomPageSizesLabel.storyName = + 'Pagination with custom page sizes label'; + +export const PaginationUnknownPages = (args) => { + return ( +
+ +
+ ); +}; + +PaginationUnknownPages.storyName = 'Unknown pages and items'; diff --git a/packages/react/src/components/PaginationNav/PaginationNav.stories.js b/packages/react/src/components/PaginationNav/PaginationNav.stories.js index 4f6f1e601fec..fa02273c3b9e 100644 --- a/packages/react/src/components/PaginationNav/PaginationNav.stories.js +++ b/packages/react/src/components/PaginationNav/PaginationNav.stories.js @@ -16,19 +16,13 @@ export default { parameters: {}, }; -export const Default = () => ( -
- -
-); - -export const Playground = (args) => ( +export const Default = (args) => (
); -Playground.args = { +Default.args = { size: 'lg', loop: false, itemsShown: 10, @@ -37,7 +31,7 @@ Playground.args = { disableOverflow: false, }; -Playground.argTypes = { +Default.argTypes = { size: { options: ['sm', 'md', 'lg'], control: { type: 'select' }, diff --git a/packages/react/src/components/Popover/Popover.stories.js b/packages/react/src/components/Popover/Popover.stories.js index 7007f18b6678..6a5f6a29dab9 100644 --- a/packages/react/src/components/Popover/Popover.stories.js +++ b/packages/react/src/components/Popover/Popover.stories.js @@ -26,28 +26,6 @@ export default { subcomponents: { PopoverContent, }, - argTypes: { - as: { - table: { - disable: true, - }, - }, - children: { - table: { - disable: true, - }, - }, - className: { - table: { - disable: true, - }, - }, - relative: { - table: { - disable: true, - }, - }, - }, parameters: { controls: { hideNoControlsWarning: true, @@ -58,7 +36,30 @@ export default { }, }; -const PlaygroundStory = (props) => { +const sharedArgTypes = { + as: { + table: { + disable: true, + }, + }, + children: { + table: { + disable: true, + }, + }, + className: { + table: { + disable: true, + }, + }, + relative: { + table: { + disable: true, + }, + }, +}; + +const DefaultStory = (props) => { const { align, caret, dropShadow, highContrast, open } = props; return ( { caret={caret} dropShadow={dropShadow} highContrast={highContrast} - open={open}> + open={open} + {...props}>
@@ -80,7 +82,9 @@ const PlaygroundStory = (props) => { ); }; -export const TabTip = () => { +DefaultStory.argTypes = { ...sharedArgTypes }; + +export const TabTip = (args) => { const [open, setOpen] = useState(true); const [openTwo, setOpenTwo] = useState(false); const align = document?.dir === 'rtl' ? 'bottom-right' : 'bottom-left'; @@ -96,7 +100,8 @@ export const TabTip = () => { } }} isTabTip - onRequestClose={() => setOpen(false)}> + onRequestClose={() => setOpen(false)} + {...args}> - setVal(value)} - /> -

{val}

- - ); -}; - -export const _WithLayer = () => ( - - - -); - -export const ControlledSliderWithLayer = () => { - const [val, setVal] = useState(87); - return ( - - - setVal(value)} - /> -

{val}

-
- ); -}; - -export const TwoHandleSlider = () => ( - -); - -export const TwoHandleSliderWithHiddenInputs = () => ( - -); - -export const Skeleton = () => ; - -export const TwoHandleSkeleton = () => ; - -export const Playground = (args) => ( +export const Default = (args) => ( ); -Playground.argTypes = { +Default.argTypes = { ariaLabelInput: { control: { type: 'text' }, }, @@ -292,7 +153,7 @@ Playground.argTypes = { }, }; -Playground.args = { +Default.args = { ariaLabelInput: 'Lower bound', unstable_ariaLabelInputUpper: 'Upper bound', disabled: false, @@ -310,3 +171,129 @@ Playground.args = { warn: false, warnText: 'Warning message goes here', }; + +export const SliderWithHiddenInputs = () => ( + +); + +export const SliderWithCustomValueLabel = () => ( + { + if (val < 25) { + return 'Low'; + } else if (val > 75) { + return 'High'; + } + return 'Medium'; + }} + /> +); + +export const ControlledSlider = () => { + const [val, setVal] = useState(87); + return ( + <> + + setVal(value)} + /> +

{val}

+ + ); +}; + +export const _WithLayer = () => ( + + + +); + +export const ControlledSliderWithLayer = () => { + const [val, setVal] = useState(87); + return ( + + + setVal(value)} + /> +

{val}

+
+ ); +}; + +export const TwoHandleSlider = () => ( + +); + +export const TwoHandleSliderWithHiddenInputs = () => ( + +); + +export const Skeleton = () => ; + +export const TwoHandleSkeleton = () => ; diff --git a/packages/react/src/components/Tabs/Tabs.stories.js b/packages/react/src/components/Tabs/Tabs.stories.js index 18fc473b20fb..f296b10449cf 100644 --- a/packages/react/src/components/Tabs/Tabs.stories.js +++ b/packages/react/src/components/Tabs/Tabs.stories.js @@ -64,39 +64,70 @@ export default { }, }; -export const Default = () => ( - - +export const Default = ({ dismissable, ...args }) => ( + {}}> + Dashboard Monitoring Activity - Settings + Settings Tab Panel 1 - -
- Validation example - - - - -
+ Tab Panel 2 Tab Panel 3 Tab Panel 4
); +Default.args = { + contained: false, + dismissable: false, + scrollDebounceWait: 200, +}; + +Default.argTypes = { + activation: { + control: { type: 'select' }, + options: ['automatic', 'manual'], + }, + contained: { + control: { + type: 'boolean', + }, + }, + dismissable: { + control: { + type: 'boolean', + }, + }, + iconSize: { + control: { type: 'select' }, + options: ['default', 'lg'], + }, + leftOverflowButtonProps: { + control: { + type: 'object', + }, + }, + rightOverflowButtonProps: { + control: { + type: 'object', + }, + }, + scrollDebounceWait: { + control: { + type: 'number', + }, + }, + scrollIntoView: { + control: { + type: 'boolean', + }, + }, +}; + export const Dismissable = () => { const tabs = [ { @@ -655,67 +686,3 @@ export const Skeleton = () => {
); }; - -export const Playground = ({ dismissable, ...args }) => ( - {}}> - - Dashboard - Monitoring - Activity - Settings - - - Tab Panel 1 - Tab Panel 2 - Tab Panel 3 - Tab Panel 4 - - -); - -Playground.args = { - contained: false, - dismissable: false, - scrollDebounceWait: 200, -}; - -Playground.argTypes = { - activation: { - control: { type: 'select' }, - options: ['automatic', 'manual'], - }, - contained: { - control: { - type: 'boolean', - }, - }, - dismissable: { - control: { - type: 'boolean', - }, - }, - iconSize: { - control: { type: 'select' }, - options: ['default', 'lg'], - }, - leftOverflowButtonProps: { - control: { - type: 'object', - }, - }, - rightOverflowButtonProps: { - control: { - type: 'object', - }, - }, - scrollDebounceWait: { - control: { - type: 'number', - }, - }, - scrollIntoView: { - control: { - type: 'boolean', - }, - }, -}; diff --git a/packages/react/src/components/TextArea/TextArea.stories.js b/packages/react/src/components/TextArea/TextArea.stories.js index 39139a06ce44..440a0f32fd0a 100644 --- a/packages/react/src/components/TextArea/TextArea.stories.js +++ b/packages/react/src/components/TextArea/TextArea.stories.js @@ -35,74 +35,7 @@ export default { }, }; -export const Default = () => ( -