Skip to content

Commit

Permalink
Storybook: Update BoxControl stories (#31029)
Browse files Browse the repository at this point in the history
* Update BoxControl stories to highlight configurable sides
* Update BoxControl readme with sides prop info
  • Loading branch information
aaronrobertshaw authored Apr 22, 2021
1 parent 7e300aa commit 5d0b32a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
7 changes: 7 additions & 0 deletions packages/components/src/box-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ A callback function for visualizer changes, based on input hover interactions.
- Type: `Function`
- Required: Yes

### sides

Collection of sides to allow control of. If omitted or empty, all sides will be available.

- Type: `Array<Object>`
- Required: No

### units

Collection of available units which are compatible with [UnitControl](../unit-control).
Expand Down
34 changes: 27 additions & 7 deletions packages/components/src/box-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export const _default = () => {
return <BoxControl />;
};

function DemoExample() {
const [ values, setValues ] = useState( {
top: '10px',
right: '10px',
bottom: '10px',
left: '10px',
} );
const defaultSideValues = {
top: '10px',
right: '10px',
bottom: '10px',
left: '10px',
};

function DemoExample( { sides, defaultValues = defaultSideValues } ) {
const [ values, setValues ] = useState( defaultValues );
const [ showVisualizer, setShowVisualizer ] = useState( {} );

return (
Expand All @@ -37,6 +38,7 @@ function DemoExample() {
<BoxControl
label="Padding"
values={ values }
sides={ sides }
onChange={ setValues }
onChangeShowVisualizer={ setShowVisualizer }
/>
Expand All @@ -62,6 +64,24 @@ export const visualizer = () => {
return <DemoExample />;
};

export const arbitrarySides = () => {
return (
<DemoExample
sides={ [ 'top', 'bottom' ] }
defaultValues={ { top: '10px', bottom: '10px' } }
/>
);
};

export const singleSide = () => {
return (
<DemoExample
sides={ [ 'bottom' ] }
defaultValues={ { bottom: '10px' } }
/>
);
};

const Container = styled( Flex )`
max-width: 780px;
`;
Expand Down

0 comments on commit 5d0b32a

Please sign in to comment.