Skip to content

Commit

Permalink
Add Color Palette to Storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaz committed Oct 17, 2019
1 parent f5f824e commit 1757698
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/components/src/color-palette/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* External dependencies
*/
import { object } from '@storybook/addon-knobs';

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

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

export default { title: 'Color Palette', component: ColorPalette };

export const _default = () => {
const [ color, setColor ] = useState( '#f00' );

const colors = [
{ name: 'red', color: '#f00' },
{ name: 'white', color: '#fff' },
{ name: 'blue', color: '#00f' },
];

return (
<ColorPalette
colors={ colors }
value={ color }
onChange={ setColor }
/>
);
};

export const WithKnobs = () => {
const [ color, setColor ] = useState( '#f00' );

const colors = [
object( 'Red', { name: 'red', color: '#f00' } ),
object( 'White', { name: 'white', color: '#fff' } ),
object( 'Blue', { name: 'blue', color: '#00f' } ),
];

return (
<ColorPalette
colors={ colors }
value={ color }
onChange={ setColor }
/>
);
};

0 comments on commit 1757698

Please sign in to comment.