From 302c9052188e55f2427885c57f9a549da2183872 Mon Sep 17 00:00:00 2001 From: lukewalczak Date: Mon, 26 Aug 2019 14:33:06 +0200 Subject: [PATCH] Add isAppender functionality on mobile --- .../components/media-placeholder/README.md | 9 +++ .../media-placeholder/index.native.js | 77 +++++++++++-------- .../media-placeholder/styles.native.scss | 15 ++++ .../block-library/src/image/edit.native.js | 14 ++-- .../block-library/src/video/edit.native.js | 14 ++-- 5 files changed, 81 insertions(+), 48 deletions(-) diff --git a/packages/block-editor/src/components/media-placeholder/README.md b/packages/block-editor/src/components/media-placeholder/README.md index 59795b5469c8cc..a46ad755c7e348 100644 --- a/packages/block-editor/src/components/media-placeholder/README.md +++ b/packages/block-editor/src/components/media-placeholder/README.md @@ -80,6 +80,15 @@ If false the default placeholder style is used. - Type: `Boolean` - Required: No - Default: `false` +- Platform: Web | Mobile + +### isSelected + +Whether the block is selected or not. + +- Type: `Boolean` +- Required: No +- Platform: Mobile ### labels diff --git a/packages/block-editor/src/components/media-placeholder/index.native.js b/packages/block-editor/src/components/media-placeholder/index.native.js index a19a28588200c9..12521d7a033bc7 100644 --- a/packages/block-editor/src/components/media-placeholder/index.native.js +++ b/packages/block-editor/src/components/media-placeholder/index.native.js @@ -8,6 +8,7 @@ import { View, Text, TouchableWithoutFeedback } from 'react-native'; */ import { __, sprintf } from '@wordpress/i18n'; import { MediaUpload, MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO } from '@wordpress/block-editor'; +import { Dashicon } from '@wordpress/components'; /** * Internal dependencies @@ -15,7 +16,7 @@ import { MediaUpload, MEDIA_TYPE_IMAGE, MEDIA_TYPE_VIDEO } from '@wordpress/bloc import styles from './styles.scss'; function MediaPlaceholder( props ) { - const { mediaType, labels = {}, icon, onSelectURL } = props; + const { mediaType, labels = {}, icon, onSelectURL, isAppender, isSelected } = props; const isImage = MEDIA_TYPE_IMAGE === mediaType; const isVideo = MEDIA_TYPE_VIDEO === mediaType; @@ -46,41 +47,53 @@ function MediaPlaceholder( props ) { accessibilityHint = __( 'Double tap to select a video' ); } + if ( isAppender !== undefined && ! isSelected ) { + return null; + } + return ( - { - return ( - + { + return ( + { - props.onFocus( event ); - open(); - } } - > - - { getMediaOptions() } - - { icon } + __( '%s block. Empty' ), + placeholderTitle + ) } + accessibilityRole={ 'button' } + accessibilityHint={ accessibilityHint } + onPress={ ( event ) => { + props.onFocus( event ); + open(); + } } + > + + { getMediaOptions() } + { isAppender ? + : + <> + + { icon } + + + { placeholderTitle } + + + { instructions } + + } - - { placeholderTitle } - - - { instructions } - - - - ); - } } /> + + ); + } } /> + + ); } export default MediaPlaceholder; + diff --git a/packages/block-editor/src/components/media-placeholder/styles.native.scss b/packages/block-editor/src/components/media-placeholder/styles.native.scss index f76be4b8f36a42..c5d2230c147e73 100644 --- a/packages/block-editor/src/components/media-placeholder/styles.native.scss +++ b/packages/block-editor/src/components/media-placeholder/styles.native.scss @@ -33,3 +33,18 @@ align-items: center; fill: $gray-dark; } + +.isAppender { + height: auto; + background-color: $white; + border: $border-width solid $light-gray-500; + border-radius: 4px; +} + +.addBlockButton { + color: $white; + background-color: $dark-gray-500; + border-radius: $icon-button-size-small / 2; + overflow: hidden; + size: $icon-button-size-small; +} diff --git a/packages/block-library/src/image/edit.native.js b/packages/block-library/src/image/edit.native.js index 3eb19a6bfa991b..d301131c678fed 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -258,14 +258,12 @@ class ImageEdit extends React.Component { if ( ! url ) { return ( - - - + ); } diff --git a/packages/block-library/src/video/edit.native.js b/packages/block-library/src/video/edit.native.js index 3b0a9d186d3084..739f6dfda01540 100644 --- a/packages/block-library/src/video/edit.native.js +++ b/packages/block-library/src/video/edit.native.js @@ -179,14 +179,12 @@ class VideoEdit extends React.Component { if ( ! id ) { return ( - - - + ); }