Skip to content

Commit

Permalink
docs(select): add playground story, controls (#11623)
Browse files Browse the repository at this point in the history
* docs(select): add playground story, controls

* fix(select): remove unused playground argtypes

* fix(select): ensure string controls work, remove unecessary props from controls

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
tay1orjones and kodiakhq[bot] authored Jun 23, 2022
1 parent e46fb81 commit 2623b63
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 22 deletions.
14 changes: 7 additions & 7 deletions packages/react/src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ const Select = React.forwardRef(function Select(
{
className,
id,
inline,
inline = false,
labelText,
disabled,
disabled = false,
children,
// reserved for use with <Pagination> component
noLabel,
noLabel = false,
// eslint-disable-next-line no-unused-vars
hideLabel,
invalid,
hideLabel = false,
invalid = false,
invalidText,
helperText,
light,
light = false,
size,
warn,
warn = false,
warnText,
...other
},
Expand Down
95 changes: 80 additions & 15 deletions packages/react/src/components/Select/Select.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,48 @@ import { Layer } from '../Layer';
export default {
title: 'Components/Select',
component: Select,
argTypes: {
size: {
options: ['sm', 'md', 'lg'],
control: { type: 'select' },
},
},
args: {
disabled: false,
inline: false,
noLabel: false,
hideLabel: false,
invalid: false,
warn: false,
size: 'md',
},
argTypes: {
onChange: {
action: 'onChange',
table: {
disable: true,
},
},
children: {
table: {
disable: true,
},
},
className: {
table: {
disable: true,
},
},
defaultValue: {
table: {
disable: true,
},
},
id: {
table: {
disable: true,
},
},
light: {
table: {
disable: true,
},
},
},
decorators: [(story) => <div style={{ width: '400px' }}>{story()}</div>],
subcomponents: {
SelectItem,
Expand All @@ -31,11 +64,10 @@ export default {
},
};

export const _Default = (args) => {
export const Default = () => {
return (
<div>
<Select
{...args}
id="select-1"
defaultValue="placeholder-item"
labelText="Select an option"
Expand All @@ -59,11 +91,10 @@ export const _Default = (args) => {
);
};

export const Inline = (args) => {
export const Inline = () => {
return (
<div>
<Select
{...args}
inline
id="select-1"
defaultValue="placeholder-item"
Expand All @@ -88,7 +119,7 @@ export const Inline = (args) => {
);
};

export const _Skeleton = () => (
export const Skeleton = () => (
<div
aria-label="loading select"
aria-live="assertive"
Expand All @@ -99,11 +130,10 @@ export const _Skeleton = () => (
</div>
);

export const WithLayer = (args) => {
export const WithLayer = () => {
return (
<>
<Select
{...args}
id="select-1"
defaultValue="placeholder-item"
labelText=""
Expand All @@ -119,7 +149,6 @@ export const WithLayer = (args) => {
</Select>
<Layer>
<Select
{...args}
id="select-1"
defaultValue="placeholder-item"
labelText=""
Expand All @@ -137,7 +166,6 @@ export const WithLayer = (args) => {
</Select>
<Layer>
<Select
{...args}
id="select-1"
defaultValue="placeholder-item"
labelText=""
Expand All @@ -158,3 +186,40 @@ export const WithLayer = (args) => {
</>
);
};

export const Playground = (args) => {
return (
<div>
<Select
id="select-1"
defaultValue="placeholder-item"
labelText="Select an option"
helperText="Optional helper text"
{...args}>
<SelectItem
disabled
hidden
value="placeholder-item"
text="Choose an option"
/>
<SelectItemGroup label="Category 1">
<SelectItem value="option-1" text="Option 1" />
<SelectItem value="option-2" text="Option 2" />
</SelectItemGroup>
<SelectItemGroup label="Category 2">
<SelectItem value="option-3" text="Option 3" />
<SelectItem value="option-4" text="Option 4" />
</SelectItemGroup>
</Select>
</div>
);
};

Playground.argTypes = {
helperText: {
control: 'text',
},
invalidText: { control: 'text' },
labelText: { control: 'text' },
warnText: { control: 'text' },
};

0 comments on commit 2623b63

Please sign in to comment.