Skip to content

Commit

Permalink
Storybook: Add story for the Warning component (#68124)
Browse files Browse the repository at this point in the history
* doc: Add storybook for warning component

* feat: Add story with actions, and secondary actions

Co-authored-by: im3dabasia <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent 813c24b commit 080189e
Showing 1 changed file with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';

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

const meta = {
title: 'BlockEditor/Warning',
component: Warning,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component:
'Displays a warning message with optional action buttons and secondary actions dropdown.',
},
},
},
argTypes: {
children: {
control: 'text',
description:
'Intended to represent the block to which the warning pertains.',
table: {
type: { summary: 'string|element' },
},
},
className: {
control: 'text',
description: 'Classes to pass to element.',
table: {
type: { summary: 'string' },
},
},
actions: {
control: 'object',
description:
'An array of elements to be rendered as action buttons in the warning element.',
table: {
type: { summary: 'Element[]' },
},
},
secondaryActions: {
control: 'object',
description:
'An array of { title, onClick } to be rendered as options in a dropdown of secondary actions.',
table: {
type: { summary: '{ title: string, onClick: Function }[]' },
},
},
},
};

export default meta;

export const Default = {
args: {
children: __( 'This block ran into an issue.' ),
},
};

export const WithActions = {
args: {
...Default.args,
actions: [
<Button key="fix-issue" __next40pxDefaultSize variant="primary">
{ __( 'Fix issue' ) }
</Button>,
],
},
};

export const WithSecondaryActions = {
args: {
...Default.args,
secondaryActions: [
{ title: __( 'Get help' ) },
{ title: __( 'Remove block' ) },
],
},
};

1 comment on commit 080189e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 080189e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12467363793
📝 Reported issues:

Please sign in to comment.