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

Add RangeControl component to Storybook #18146

Merged
merged 1 commit into from
Oct 30, 2019
Merged
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
99 changes: 99 additions & 0 deletions packages/components/src/range-control/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* External dependencies
*/
import { number, text } from '@storybook/addon-knobs';

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import RangeControl from '../';

export default { title: 'RangeControl', component: RangeControl };

const RangeControlWithState = ( { ...props } ) => {
gziolo marked this conversation as resolved.
Show resolved Hide resolved
const [ value, setValue ] = useState( 5 );
gziolo marked this conversation as resolved.
Show resolved Hide resolved

return (
<RangeControl
{ ...props }
value={ value }
onChange={ setValue }
/>
);
};

export const _default = () => {
const label = text( 'Label', 'How many columns should this use?' );

return (
<RangeControlWithState
label={ label }
/>
);
};

export const withHelp = () => {
const label = text( 'Label', 'How many columns should this use?' );
const help = text( 'Help Text', 'Please select the number of columns you would like this to contain.' );

return (
<RangeControlWithState
label={ label }
help={ help }
/>
);
};

export const withMinimumAndMaximumLimits = () => {
const label = text( 'Label', 'How many columns should this use?' );
const min = number( 'Min Value', 2 );
const max = number( 'Max Value', 10 );

return (
<RangeControlWithState
label={ label }
min={ min }
max={ max }
/>
);
};

export const withIconBefore = () => {
const label = text( 'Label', 'How many columns should this use?' );
const icon = text( 'Icon', 'wordpress' );

return (
<RangeControlWithState
label={ label }
beforeIcon={ icon }
/>
);
};

export const withIconAfter = () => {
const label = text( 'Label', 'How many columns should this use?' );
const icon = text( 'Icon', 'wordpress' );

return (
<RangeControlWithState
label={ label }
afterIcon={ icon }
/>
);
};

export const withReset = () => {
const label = text( 'Label', 'How many columns should this use?' );

return (
<RangeControlWithState
label={ label }
allowReset={ true }
/>
);
};