Skip to content

Commit

Permalink
Enhance WritingModeControl usability and simplify structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukhendu2002 committed Dec 3, 2024
1 parent c99be7b commit f510d8a
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { isRTL } from '@wordpress/i18n';
import { useState } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -24,14 +25,7 @@ const meta = {
},
argTypes: {
value: {
control: { type: 'select' },
options: ( () => {
const modes = [
'horizontal-tb',
isRTL() ? 'vertical-lr' : 'vertical-rl',
];
return modes;
} )(),
control: { type: null },
description: 'Currently selected writing mode.',
},
className: {
Expand All @@ -40,6 +34,7 @@ const meta = {
},
onChange: {
action: 'onChange',
control: { type: null },
description: 'Handles change in the writing mode selection.',
},
},
Expand All @@ -48,16 +43,20 @@ const meta = {
export default meta;

export const Default = {
args: {
value: 'horizontal-tb',
},
};
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState(
isRTL() ? 'vertical-lr' : 'vertical-rl'
);

/**
* This story demonstrates the WritingModeControl component with the vertical writing mode.
*/
export const Vertical = {
args: {
value: isRTL() ? 'vertical-lr' : 'vertical-rl',
return (
<WritingModeControl
{ ...args }
onChange={ ( ...changeArgs ) => {
onChange( ...changeArgs );
setValue( ...changeArgs );
} }
value={ value }
/>
);
},
};

0 comments on commit f510d8a

Please sign in to comment.