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: Add Color Palette Component #17997

Merged
merged 4 commits into from
Oct 25, 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
56 changes: 56 additions & 0 deletions packages/components/src/color-palette/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* External dependencies
*/
import { object } from '@storybook/addon-knobs';

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

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

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

const ColorPaletteWithState = ( props ) => {
const [ color, setColor ] = useState( '#F00' );
return (
<ColorPalette
{ ...props }
value={ color }
onChange={ setColor }
/>
);
};

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

return (
<ColorPaletteWithState
colors={ colors }
/>
);
};

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

return (
<ColorPaletteWithState
colors={ colors }
/>
);
};