-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RangeControl component to Storyboard
- Loading branch information
1 parent
669da7a
commit 07e4563
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* 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 = ( { label, help, min, max, beforeIcon, afterIcon, allowReset, ...props } ) => { | ||
const [ value, setValue ] = useState( 5 ); | ||
|
||
return ( | ||
<RangeControl | ||
{ ...props } | ||
help={ help } | ||
label={ label } | ||
value={ value } | ||
onChange={ ( val ) => setValue( val ) } | ||
min={ min } | ||
max={ max } | ||
beforeIcon={ beforeIcon } | ||
afterIcon={ afterIcon } | ||
allowReset={ allowReset } | ||
/> | ||
); | ||
}; | ||
|
||
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 } | ||
/> | ||
); | ||
}; |