Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook: Update BoxControl stories #31029

Merged
merged 3 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved

### 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