From 72170027be8f8d96758e88cd3292d9db1d6ee281 Mon Sep 17 00:00:00 2001 From: John Godley Date: Fri, 6 Jul 2018 10:04:53 +0100 Subject: [PATCH] Block warning: use new warning block Some dummy hidden actions are supplied while WIP --- ...ck-warning.js => block-invalid-warning.js} | 12 ++-- editor/components/block-list/block.js | 4 +- editor/components/block-list/style.scss | 11 +++- editor/components/warning/index.js | 56 +++++++------------ 4 files changed, 38 insertions(+), 45 deletions(-) rename editor/components/block-list/{invalid-block-warning.js => block-invalid-warning.js} (78%) diff --git a/editor/components/block-list/invalid-block-warning.js b/editor/components/block-list/block-invalid-warning.js similarity index 78% rename from editor/components/block-list/invalid-block-warning.js rename to editor/components/block-list/block-invalid-warning.js index e3ab117339c98c..ea9a14acf13122 100644 --- a/editor/components/block-list/invalid-block-warning.js +++ b/editor/components/block-list/block-invalid-warning.js @@ -15,21 +15,25 @@ import { withDispatch } from '@wordpress/data'; */ import Warning from '../warning'; -function InvalidBlockWarning( { convertToHTML, convertToBlocks } ) { +function BlockInvalidWarning( { convertToHTML, convertToBlocks } ) { const hasHTMLBlock = !! getBlockType( 'core/html' ); return ( { __( 'Convert to Blocks' ) } , hasHTMLBlock && ( ), ] } + hiddenActions={ [ + { onClick: convertToBlocks, title: __( 'Convert to Blocks' ) }, + { onClick: convertToHTML, title: __( 'Keep as HTML' ) }, + ] } > { __( 'This block appears to have been modified externally.' ) } @@ -51,4 +55,4 @@ export default withDispatch( ( dispatch, { block } ) => { } ) ); }, }; -} )( InvalidBlockWarning ); +} )( BlockInvalidWarning ); diff --git a/editor/components/block-list/block.js b/editor/components/block-list/block.js index 710d9c5ceccd9c..ed1ee3e06107c6 100644 --- a/editor/components/block-list/block.js +++ b/editor/components/block-list/block.js @@ -36,7 +36,7 @@ import BlockEdit from '../block-edit'; import BlockMover from '../block-mover'; import BlockDropZone from '../block-drop-zone'; import BlockSettingsMenu from '../block-settings-menu'; -import InvalidBlockWarning from './invalid-block-warning'; +import BlockInvalidWarning from './block-invalid-warning'; import BlockCrashWarning from './block-crash-warning'; import BlockCrashBoundary from './block-crash-boundary'; import BlockHtml from './block-html'; @@ -546,7 +546,7 @@ export class BlockListBlock extends Component {
{ getSaveElement( blockType, block.attributes ) }
, - , diff --git a/editor/components/block-list/style.scss b/editor/components/block-list/style.scss index a70977d41fb3be..ead94c3f8313ad 100644 --- a/editor/components/block-list/style.scss +++ b/editor/components/block-list/style.scss @@ -289,6 +289,14 @@ } } + &.has-warning .editor-block-list__block-edit > div { + border: 1px solid $light-gray-500; + } + + &.has-warning .editor-block-list__block-edit > div:first-child { + padding: 10px; + } + &.has-warning .editor-block-list__block-edit:after { content: ''; position: absolute; @@ -296,8 +304,7 @@ right: 0; bottom: 0; left: 0; - background-color: rgba( $white, 0.6 ); - background-image: linear-gradient( to bottom, transparent, $white ); + background-image: linear-gradient( rgba( $light-gray-500, 0.6 ), rgba( $light-gray-500, 0.6 ) ); } // Appender diff --git a/editor/components/warning/index.js b/editor/components/warning/index.js index 57cf45fa5a433f..16a88e6ae4a42c 100644 --- a/editor/components/warning/index.js +++ b/editor/components/warning/index.js @@ -1,13 +1,8 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; - /** * WordPress dependencies */ import { Children } from '@wordpress/element'; -import { Dropdown, IconButton, NavigableMenu, Button } from '@wordpress/components'; +import { Dropdown, IconButton, MenuGroup, MenuItem } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** @@ -35,39 +30,26 @@ function Warning( { primaryActions, children, hiddenActions } ) { { hiddenActions && (
{ - const toggleClassname = classnames( 'editor-block-settings-menu__toggle', 'is-visible', { - 'is-opened': isOpen, - } ); - const label = isOpen ? __( 'Hide Options' ) : __( 'More Options' ); - - return ( - - ); - } } + renderToggle={ ( { isOpen, onToggle } ) => ( + + ) } renderContent={ () => ( - -

{ __( 'More options' ) }

- { hiddenActions.map( ( item, pos ) => - - ) } -
+
+ + { hiddenActions.map( ( item, pos ) => + + { item.title } + + ) } + +
) } />