Skip to content

Commit

Permalink
Use Notice component for displaying error message
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecRust committed Jul 27, 2023
1 parent 0126ccf commit d13cb6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/edit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { __ } from '@wordpress/i18n'
import { useBlockProps, BlockIcon } from '@wordpress/block-editor' // eslint-disable-line no-unused-vars
import { Placeholder, TextControl } from '@wordpress/components' // eslint-disable-line no-unused-vars
import { Placeholder, TextControl, Notice } from '@wordpress/components' // eslint-disable-line no-unused-vars
import { pluginIcon } from './icons'
import getVideoId from 'get-video-id'

Expand Down Expand Up @@ -69,12 +69,16 @@ export default function Edit({ attributes, setAttributes }) {
/>
{videoUrl && (
<div>
{videoId
? renderVideoThumb()
: __(
{videoId ? (
renderVideoThumb()
) : (
<Notice status="error" isDismissible={false}>
{__(
'Sorry, a video ID could not be found in that URL.',
'protected-video'
)}
</Notice>
)}
</div>
)}
</Placeholder>
Expand Down
6 changes: 6 additions & 0 deletions src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
/* Override flex layout in editor */
.wp-block-protected-video-protected-video .components-placeholder__fieldset {
flex-direction: column;

/* Disable default flash margin */
.components-notice {
margin-left: 0;
margin-right: 0;
}
}

0 comments on commit d13cb6c

Please sign in to comment.