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 stories for DateFormatPicker Component #67290

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Changes from 3 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Internal dependencies
*/
import DateFormatPicker from '../';
t-hamano marked this conversation as resolved.
Show resolved Hide resolved

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

export default {
title: 'BlockEditor/DateFormatPicker',
component: DateFormatPicker,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component:
'The `DateFormatPicker` component enables users to configure their preferred *date format*. This determines how dates are displayed.',
},
},
},
argTypes: {
defaultFormat: {
control: 'text',
description:
'The date format that will be used if the user selects "Default".',
table: {
type: { summary: 'string' },
},
},
format: {
control: { type: null },
description:
'The selected date format. If `null`, _Default_ is selected.',
table: {
type: { summary: 'string' },
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
},
},
onChange: {
action: 'onChange',
control: { type: null },
description:
'Called when a selection is made. If `null`, _Default_ is selected.',
table: {
type: { summary: 'function' },
},
},
},
};

export const Default = {
args: {
defaultFormat: 'M j, Y',
},
render: function Template( { onChange, ...args } ) {
const [ format, setFormat ] = useState();
return (
<DateFormatPicker
{ ...args }
onChange={ ( ...changeArgs ) => {
onChange( ...changeArgs );
setFormat( ...changeArgs );
} }
format={ format }
/>
);
},
};
Loading