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

[RNMobile] Adjust vertical margins in InnerBlock #19960

Merged
merged 9 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
2 changes: 2 additions & 0 deletions packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ $block-selected-to-content: $block-edge-to-content - $block-selected-margin - $b
$block-selected-child-to-content: $block-selected-to-content - $block-selected-child-margin - $block-selected-child-border-width;
$block-custom-appender-to-content: $block-selected-margin - $block-selected-border-width;
$block-media-container-to-content: $block-selected-child-margin + $block-selected-border-width;
$block-selected-vertical-margin-descendant: 2 * $block-selected-to-content;
$block-selected-vertical-margin-child: $block-edge-to-content;
jbinda marked this conversation as resolved.
Show resolved Hide resolved

// Buttons & UI Widgets
$radius-round-rectangle: 4px;
Expand Down
15 changes: 9 additions & 6 deletions packages/block-editor/src/components/block-list/block.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class BlockListBlock extends Component {
isAncestorSelected,
hasParent,
getStylesFromColorScheme,
isLastBlock,
} = this.props;

// if block does not have parent apply neutral or full
Expand All @@ -138,16 +139,19 @@ class BlockListBlock extends Component {

// return apply childOfSelected or childOfSelectedLeaf
// margins depending if block has children or not
return hasChildren
? { ...styles.childOfSelected, ...dashedBorderStyle }
: { ...styles.childOfSelectedLeaf, ...dashedBorderStyle };
return {
...( hasChildren ? styles.childOfSelected : styles.childOfSelectedLeaf ),
...dashedBorderStyle,
...( ! isLastBlock && styles.marginVerticalChild ),
};
}

if ( isAncestorSelected ) {
// ancestor of a block is selected
return {
...styles.descendantOfSelectedLeaf,
...( hasChildren && styles.marginHorizontalNone ),
...( hasChildren && { ...styles.marginHorizontalNone, ...styles.marginVerticalNone } ),
...( ! isLastBlock && styles.marginVerticalDescendant ),
};
}

Expand Down Expand Up @@ -234,7 +238,6 @@ export default compose( [
withSelect( ( select, { clientId, rootClientId } ) => {
const {
getBlockIndex,
getBlocks,
isBlockSelected,
__unstableGetBlockWithoutInnerBlocks,
getBlockHierarchyRootClientId,
Expand All @@ -250,7 +253,7 @@ export default compose( [

const order = getBlockIndex( clientId, rootClientId );
const isSelected = isBlockSelected( clientId );
const isLastBlock = order === getBlocks().length - 1;
const isLastBlock = order === getBlockCount( rootClientId ) - 1;
const block = __unstableGetBlockWithoutInnerBlocks( clientId );
const { name, attributes, isValid } = block || {};

Expand Down
13 changes: 13 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 @@ -54,6 +54,19 @@
margin-right: 0;
}

.marginVerticalDescendant {
margin-bottom: $block-selected-vertical-margin-descendant;
}

.marginVerticalChild {
margin-bottom: $block-selected-vertical-margin-child;
}

.marginVerticalNone {
margin-top: 0;
margin-bottom: 0;
}

.blockTitle {
background-color: $gray;
padding-left: 8px;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const registerCoreBlocks = () => {
mediaText,
preformatted,
gallery,
devOnly( group ),
group,
jbinda marked this conversation as resolved.
Show resolved Hide resolved
spacer,
shortcode,
].forEach( registerBlock );
Expand Down