Skip to content

Commit

Permalink
Move fontSizes array into a knob so that it can be customized and som…
Browse files Browse the repository at this point in the history
…e small code quality improvements
  • Loading branch information
brentswisher committed Oct 30, 2019
1 parent bdf8cfd commit cb5da51
Showing 1 changed file with 59 additions and 17 deletions.
76 changes: 59 additions & 17 deletions packages/components/src/font-size-picker/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { number, object } from '@storybook/addon-knobs';

/**
* WordPress dependencies
*/
Expand All @@ -12,7 +17,18 @@ export default { title: 'FontSizePicker', component: FontSizePicker };

const FontSizePickerWithState = ( { ...props } ) => {
const [ fontSize, setFontSize ] = useState( 16 );
const fontSizes = [

return (
<FontSizePicker
{ ...props }
value={ fontSize }
onChange={ setFontSize }
/>
);
};

export const _default = () => {
const fontSizes = object( 'Font Sizes', [
{
name: 'Small',
slug: 'small',
Expand All @@ -28,38 +44,64 @@ const FontSizePickerWithState = ( { ...props } ) => {
slug: 'big',
size: 26,
},
];
const fallbackFontSize = 16;

] );
return (
<FontSizePicker
{ ...props }
<FontSizePickerWithState
fontSizes={ fontSizes }
fallbackFontSize={ fallbackFontSize }
value={ fontSize }
onChange={ setFontSize }
/>
);
};

export const _default = () => {
return (
<FontSizePickerWithState />
);
};

export const withSlider = () => {
const fontSizes = object( 'Font Sizes', [
{
name: 'Small',
slug: 'small',
size: 12,
},
{
name: 'Normal',
slug: 'normal',
size: 16,
},
{
name: 'Big',
slug: 'big',
size: 26,
},
] );
const fallbackFontSize = number( 'Fallback Font Size - Slider Only', 16 );
return (
<FontSizePickerWithState
withSlider={ true }
fontSizes={ fontSizes }
fallbackFontSize={ fallbackFontSize }
withSlider
/>
);
};

export const withoutCustomSizes = () => {
const fontSizes = object( 'Font Sizes', [
{
name: 'Small',
slug: 'small',
size: 12,
},
{
name: 'Normal',
slug: 'normal',
size: 16,
},
{
name: 'Big',
slug: 'big',
size: 26,
},
] );
return (
<FontSizePickerWithState
disableCustomFontSizes={ true }
fontSizes={ fontSizes }
disableCustomFontSizes
/>
);
};

0 comments on commit cb5da51

Please sign in to comment.