-
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.
Storybook: Add story for the Warning component (#68124)
* 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
1 parent
813c24b
commit 080189e
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
packages/block-editor/src/components/warning/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,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' ) }, | ||
], | ||
}, | ||
}; |
080189e
There was a problem hiding this comment.
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:
/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js
/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js