Skip to content

Commit

Permalink
Storybook: Add stories for HeadingLevelDropdown component (WordPress#…
Browse files Browse the repository at this point in the history
…67294)

* Storybook: Add HeadingLevelDropdown Stories

* Update HeadingLevelDropdown story to CSF 3

* Update control types

* Update HeadingLevelDropdown story for improved usability

Co-authored-by: Sukhendu2002 <[email protected]>
Co-authored-by: dcalhoun <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
4 people authored and yogeshbhutkar committed Dec 18, 2024
1 parent c085e78 commit 771d4e8
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

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

const meta = {
title: 'BlockEditor/HeadingLevelDropdown',
component: HeadingLevelDropdown,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component:
'Dropdown for selecting a heading level (1 through 6) or paragraph (0).',
},
},
},
argTypes: {
value: {
control: { type: null },
description: 'The chosen heading level.',
},
options: {
control: 'check',
options: [ 1, 2, 3, 4, 5, 6 ],
description: 'An array of supported heading levels.',
},
onChange: {
action: 'onChange',
control: { type: null },
description: 'Function called with the selected value changes.',
},
},
};

export default meta;

export const Default = {
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState( args.value );

return (
<HeadingLevelDropdown
{ ...args }
value={ value }
onChange={ ( ...changeArgs ) => {
setValue( ...changeArgs );
onChange( ...changeArgs );
} }
/>
);
},
args: {
value: 2,
},
};

0 comments on commit 771d4e8

Please sign in to comment.