-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds story for duotone component.
- Loading branch information
Showing
1 changed file
with
130 additions
and
0 deletions.
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
packages/block-editor/src/components/duotone-control/stories/index.story.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Color>', | ||
}, | ||
}, | ||
}, | ||
duotonePalette: { | ||
control: 'array', | ||
description: | ||
'An array of predefined duotone filter options available in the control.', | ||
table: { | ||
type: { | ||
summary: 'Array<Duotone>', | ||
}, | ||
}, | ||
}, | ||
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 ( | ||
<DuotoneControl | ||
{ ...args } | ||
value={ selectedValue } | ||
onChange={ ( newValue ) => { | ||
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', | ||
}, | ||
}; |