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 1 commit
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
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 };
mkaz marked this conversation as resolved.
Show resolved Hide resolved

export const _default = () => {
const [ color, setColor ] = useState( '#f00' );
mkaz marked this conversation as resolved.
Show resolved Hide resolved

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 = () => {
mkaz marked this conversation as resolved.
Show resolved Hide resolved
const [ color, setColor ] = useState( '#f00' );
mkaz marked this conversation as resolved.
Show resolved Hide resolved

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 }
/>
);
};