Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mobile] Update media placeholders and block outline #52702

Merged
merged 20 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
da71015
Add new colors: $blue-60, $blue-40 and $dark-dim
geriux Jul 17, 2023
14268bc
Gallery block - Remove native icon variant
geriux Jul 17, 2023
00d8a72
Media Placeholder - Update colors
geriux Jul 17, 2023
378235e
Embed - Update placeholder styles
geriux Jul 17, 2023
6991c3b
Embed - Placeholder - Add button styles for the more options action
geriux Jul 17, 2023
3caf096
Add back BlockOutline with update logic around parent blocks and medi…
geriux Jul 17, 2023
2ce51c7
BlockOutline - Update paddings for text blocks
geriux Jul 18, 2023
ff3866c
ButtonBlockAppender - Update left and right margins
geriux Jul 18, 2023
cc1ed48
Update colors for media placeholders
geriux Jul 18, 2023
87d0a40
Image component - Update selected styles
geriux Jul 18, 2023
a7968f1
Merge branch 'trunk' into rnmobile/update-media-placeholders-and-bloc…
geriux Jul 18, 2023
d095a4f
MediaPlaceholder - Fix missing touch action for the appender
geriux Jul 18, 2023
4dfd049
Update styleMock
geriux Jul 18, 2023
bcdaaf5
Audio and File block - Update component snapshot
geriux Jul 18, 2023
989fff6
Update Embed, Gallery and Image tests to use new text placeholders
geriux Jul 18, 2023
f298e58
Update block outline component to show border for unsupported blocks
geriux Jul 19, 2023
eeeee97
Synced patterns - Fix seperator line to overflow outside the block's …
geriux Jul 19, 2023
2209870
Unsupported block - Update placeholder styles
geriux Jul 19, 2023
38b9a3f
E2E Test - Remove unsupported block test in favor of a visual test
geriux Jul 19, 2023
ad16a7a
Missing block - Update snapshot
geriux Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/base-styles/_colors.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ $red-50: #d63638;
// Primary Accent (Blues)
$blue-wordpress: #0087be;
$blue-medium: #00aadc;
$blue-60: #055d9c;
$blue-500: #016087;
// Primary tint color (light)
$blue-50: #2271b1;
$blue-40: #1689db;
// Primary tint color (dark)
$blue-30: #5198d9;

Expand Down Expand Up @@ -97,6 +99,7 @@ $dark-secondary: #fff9; //rgba(255, 255, 255, 0.6);
$dark-tertiary: #ffffff6d; //rgba(255, 255, 255, 0.43);
$dark-quaternary: #ffffff3f; //rgba(255, 255, 255, 0.25);
$dark-ultra-dim: #ffffff14; //rgba(255, 255, 255, 0.08);
$dark-dim: #ffffff1f; //rgba(255, 255, 255, 0.12)

// Design Token colors
$app-background: $white;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* External dependencies
*/
import { View } from 'react-native';

/**
* WordPress dependencies
*/
import { usePreferredColorSchemeStyle } from '@wordpress/compose';

/**
* Internal dependencies
*/
import styles from './block.scss';

function BlockOutline( {
blockCategory,
hasInnerBlocks,
isRootList,
isSelected,
} ) {
const hasBlockTextCategory = blockCategory === 'text';
const hasBlockMediaCategory =
blockCategory === 'media' ||
blockCategory === 'embed' ||
! blockCategory;

const styleSolidBorder = [
styles.solidBorder,
usePreferredColorSchemeStyle(
styles.solidBorderColor,
styles.solidBorderColorDark
),
hasBlockMediaCategory && ! hasInnerBlocks && styles.solidBorderCompact,
hasBlockTextCategory && styles.solidBorderTextContent,
];

const shoudlShowOutline =
isSelected &&
( ( hasBlockTextCategory && hasInnerBlocks ) ||
( ! hasBlockTextCategory && hasInnerBlocks ) ||
( ! hasBlockTextCategory && isRootList ) );

return (
shoudlShowOutline && (
<View pointerEvents="box-none" style={ styleSolidBorder } />
)
);
}

export default BlockOutline;
24 changes: 22 additions & 2 deletions packages/block-editor/src/components/block-list/block.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { compose, ifCondition, pure } from '@wordpress/compose';
import BlockEdit from '../block-edit';
import BlockDraggable from '../block-draggable';
import BlockInvalidWarning from './block-invalid-warning';
import BlockOutline from './block-outline';
import { store as blockEditorStore } from '../../store';
import { useLayout } from './layout';
import useSetting from '../use-setting';
Expand All @@ -59,11 +60,14 @@ function getWrapperProps( value, getWrapperPropsFunction ) {

function BlockWrapper( {
accessibilityLabel,
blockCategory,
children,
clientId,
draggingClientId,
draggingEnabled,
hasInnerBlocks,
isDescendentBlockSelected,
isRootList,
isSelected,
isTouchable,
marginHorizontal,
Expand All @@ -89,6 +93,12 @@ function BlockWrapper( {
onPress={ onFocus }
style={ blockWrapperStyle }
>
<BlockOutline
blockCategory={ blockCategory }
hasInnerBlocks={ hasInnerBlocks }
isRootList={ isRootList }
isSelected={ isSelected }
/>
<BlockDraggable
clientId={ clientId }
draggingClientId={ draggingClientId }
Expand Down Expand Up @@ -127,9 +137,11 @@ function BlockListBlock( {
} ) {
const {
baseGlobalStyles,
blockCategory,
blockType,
draggingClientId,
draggingEnabled,
hasInnerBlocks,
isDescendantOfParentSelected,
isDescendentBlockSelected,
isParentSelected,
Expand All @@ -146,6 +158,7 @@ function BlockListBlock( {
hasSelectedInnerBlock,
} = select( blockEditorStore );
const currentBlockType = getBlockType( name || 'core/missing' );
const currentBlockCategory = currentBlockType?.category;
const blockOrder = getBlockIndex( clientId );
const descendentBlockSelected = hasSelectedInnerBlock(
clientId,
Expand All @@ -162,13 +175,15 @@ function BlockListBlock( {
const selectedParents = clientId ? parents : [];
const descendantOfParentSelected =
selectedParents.includes( rootClientId );
const hasInnerBlocks = getBlockCount( clientId ) > 0;
const blockHasInnerBlocks = getBlockCount( clientId ) > 0;

// For blocks with inner blocks, we only enable the dragging in the nested
// blocks if any of them are selected. This way we prevent the long-press
// gesture from being disabled for elements within the block UI.
const isDraggingEnabled =
! hasInnerBlocks || isSelected || ! descendentBlockSelected;
! blockHasInnerBlocks ||
isSelected ||
! descendentBlockSelected;
// Dragging nested blocks is not supported yet. For this reason, the block to be dragged
// will be the top in the hierarchy.
const currentDraggingClientId =
Expand All @@ -179,9 +194,11 @@ function BlockListBlock( {

return {
baseGlobalStyles: globalStylesBaseStyles,
blockCategory: currentBlockCategory,
blockType: currentBlockType,
draggingClientId: currentDraggingClientId,
draggingEnabled: isDraggingEnabled,
hasInnerBlocks: blockHasInnerBlocks,
isDescendantOfParentSelected: descendantOfParentSelected,
isDescendentBlockSelected: descendentBlockSelected,
isParentSelected: parentSelected,
Expand Down Expand Up @@ -279,11 +296,14 @@ function BlockListBlock( {
return (
<BlockWrapper
accessibilityLabel={ accessibilityLabel }
blockCategory={ blockCategory }
clientId={ clientId }
draggingClientId={ draggingClientId }
draggingEnabled={ draggingEnabled }
isFocused={ isFocused }
hasInnerBlocks={ hasInnerBlocks }
isDescendentBlockSelected={ isDescendentBlockSelected }
isRootList={ ! rootClientId }
isSelected={ isSelected }
isStackedHorizontally={ isStackedHorizontally }
isTouchable={ isTouchable }
Expand Down
32 changes: 32 additions & 0 deletions packages/block-editor/src/components/block-list/block.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
flex: 1 1 auto;
}

.solidBorderColor {
border-color: $blue-40;
}

.solidBorderColorDark {
border-color: $blue-50;
}

.dimmed {
opacity: $dimmed-opacity;
}
Expand All @@ -25,6 +33,30 @@
min-height: 50px;
}

.solidBorder {
position: absolute;
top: -6px;
bottom: -6px;
left: -6px;
right: -6px;
border-width: 2px;
border-radius: 2px;
border-style: solid;
z-index: 1;
}

.solidBorderCompact {
top: 0;
bottom: 0;
left: 0;
right: 0;
}

.solidBorderTextContent {
left: 0;
right: 0;
}

.fullWidthPadding {
padding: $block-selected-to-content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
align-items: center;
justify-content: center;
padding: 9px;
margin-left: 0;
margin-right: 0;
margin-left: $grid-unit;
margin-right: $grid-unit;
border-radius: 4px;
}

Expand Down
Loading
Loading