From 26b5c79e070ce7c64ca8734bb9de2a3a44f953f4 Mon Sep 17 00:00:00 2001 From: Vipul Gupta Date: Tue, 24 Dec 2024 12:19:14 +0530 Subject: [PATCH] feat: Adds story for duotone component. --- .../duotone-control/stories/index.story.js | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 packages/block-editor/src/components/duotone-control/stories/index.story.js diff --git a/packages/block-editor/src/components/duotone-control/stories/index.story.js b/packages/block-editor/src/components/duotone-control/stories/index.story.js new file mode 100644 index 00000000000000..6934f7d7633cb6 --- /dev/null +++ b/packages/block-editor/src/components/duotone-control/stories/index.story.js @@ -0,0 +1,130 @@ +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import DuotoneControl from '../'; + +const meta = { + title: 'BlockEditor/DuotoneControl', + component: DuotoneControl, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + '`DuotoneControl` is a component that allows users to apply a duotone filter to images or media elements. It includes a dropdown for selecting predefined filters or customizing duotone settings.', + }, + }, + }, + argTypes: { + id: { + control: 'text', + description: 'Optional ID for the control.', + table: { + type: { + summary: 'string', + }, + }, + }, + colorPalette: { + control: 'array', + description: + 'An array of color options available for custom duotone.', + table: { + type: { + summary: 'Array', + }, + }, + }, + duotonePalette: { + control: 'array', + description: + 'An array of predefined duotone filter options available in the control.', + table: { + type: { + summary: 'Array', + }, + }, + }, + disableCustomColors: { + control: 'boolean', + description: 'Disable the option to use custom colors in duotone.', + table: { + type: { + summary: 'boolean', + }, + }, + }, + disableCustomDuotone: { + control: 'boolean', + description: + 'Disable the ability to define custom duotone filters.', + table: { + type: { + summary: 'boolean', + }, + }, + }, + value: { + control: 'object', + description: + 'The currently selected duotone filter, either predefined or custom.', + table: { + type: { + summary: 'Duotone | "unset"', + }, + }, + }, + onChange: { + action: 'changed', + description: + 'Callback function triggered when the duotone value changes.', + table: { + type: { + summary: 'function', + }, + }, + control: false, + }, + }, +}; + +export default meta; + +const Template = ( args ) => { + const [ selectedValue, setSelectedValue ] = useState( + args.value || 'unset' + ); + + return ( + { + setSelectedValue( newValue ); + } } + /> + ); +}; + +export const Default = { + render: Template, + args: { + colorPalette: [ + { color: '#000000', name: 'Black' }, + { color: '#FFFFFF', name: 'White' }, + { color: '#FF0000', name: 'Red' }, + ], + duotonePalette: [ + { colors: [ '#000000', '#FFFFFF' ], name: 'Grayscale' }, + { colors: [ '#FF0000', '#00FF00' ], name: 'Sunset' }, + ], + disableCustomColors: false, + disableCustomDuotone: false, + value: 'unset', + }, +};