-
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.
Block Editor: Warning: Add README.md (#25574)
* Block Editor: Warning: Add README.md Part of #22891 * Add captions to illustrations
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
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
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,51 @@ | ||
# Warning | ||
|
||
Displays a warning message, typically in the context of a particular block. It may present given _actions_ to the user. | ||
|
||
_As seen in [BlockInvalidWarning](https://github.com/WordPress/gutenberg/blob/e92672936a3c8c3e20cf7b98a442f311af7b45fe/packages/block-editor/src/components/block-list/block-invalid-warning.js#L53-L66):_ | ||
|
||
<img width="614" alt="warning-block-invalid" src="https://user-images.githubusercontent.com/150562/94034403-e6223500-fdb9-11ea-8166-c73629f42e38.png"> | ||
|
||
_As seen in [withMultipleValidation](https://github.com/WordPress/gutenberg/blob/e92672936a3c8c3e20cf7b98a442f311af7b45fe/packages/edit-post/src/hooks/validate-multiple-use/index.js#L78-L115):_ | ||
|
||
<img width="625" alt="warning-block-use-once" src="https://user-images.githubusercontent.com/150562/94034410-e7ebf880-fdb9-11ea-8873-9df9ef194825.png"> | ||
|
||
|
||
## Usage | ||
|
||
### Props | ||
|
||
All of the following are optional. | ||
|
||
- `children`: Intended to represent the block to which the warning pertains. See screenshots above. | ||
|
||
- `className`: Classes to pass to element. | ||
|
||
- `actions`: An array of elements to be rendered as action buttons in the warning element. | ||
|
||
- `secondaryActions`: An array of { title, onClick } to be rendered as options in a dropdown of secondary actions. | ||
|
||
|
||
### Example | ||
|
||
```js | ||
<Warning | ||
actions={ [ | ||
<Button onClick={ fixIssue }> | ||
{ __( 'Fix issue' ) } | ||
</Button>, | ||
] } | ||
secondaryActions={ [ | ||
{ | ||
title: __( 'Get help' ), | ||
onClick: getHelp, | ||
}, | ||
{ | ||
title: __( 'Remove block' ), | ||
onClick: removeBlock, | ||
}, | ||
] } | ||
> | ||
{ __( 'This block ran into an issue.' ) } | ||
</Warning> | ||
``` |
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