Repository navigation
[RNMobile] Adjust new borders implementations to columns PR #21073
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
Changes from all commits
1acf841
ea78723
21f11c8
db92a0c
b337fb4
413e4a7
cf924e8
cfca28e
87e493a
5cc2190
89873ba
e14e8ca
4268f57
69eec82
67bb907
55c6e17
a760d74
2f9ec61
e966382
39eb44a
316f79d
295c391
9b27c32
a1479e5
9599f88
f1b7c0f
41fda77
be8b42c
de9ad00
58b1e39
cba5e96
3047ea8
7f6f069
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,6 @@ function ColumnEdit( { | |
| isSelected, | ||
| getStylesFromColorScheme, | ||
| isParentSelected, | ||
| isDescendantOfParentSelected, | ||
| isDescendantSelected, | ||
| isAncestorSelected, | ||
| customBlockProps, | ||
| } ) { | ||
| const { verticalAlignment } = attributes; | ||
|
|
@@ -40,69 +37,11 @@ function ColumnEdit( { | |
| const minWidth = Math.min( containerWidth, containerMaxWidth ); | ||
| const columnBaseWidth = minWidth / Math.max( 1, columnsInRow ); | ||
|
|
||
| const applyBlockStyle = ( placeholder = false ) => { | ||
| const pullWidths = ( names ) => | ||
| names.map( | ||
| ( name ) => | ||
| ( styles[ `column-${ name }-margin` ] || {} ).width || 0 | ||
| ); | ||
|
|
||
| const applyBlockStyle = () => { | ||
| let width = columnBaseWidth; | ||
| const names = [ | ||
| 'selected', | ||
| 'parent-selected', | ||
| 'descendant-selected', | ||
| 'placeholder-selected', | ||
| 'dashed-border', | ||
| ]; | ||
| const widths = pullWidths( names ); | ||
| const [ | ||
| emptyColumnSelected, | ||
| parentSelected, | ||
| columnSelected, | ||
| placeholderParentSelected, | ||
| dashedBorderWidth, | ||
| ] = widths; | ||
|
|
||
| switch ( true ) { | ||
| case isSelected: | ||
| width = columnBaseWidth; | ||
| width -= ! hasChildren | ||
| ? emptyColumnSelected | ||
| : columnSelected + dashedBorderWidth; | ||
| break; | ||
|
|
||
| case isParentSelected: | ||
| width -= placeholder | ||
| ? placeholderParentSelected | ||
| : parentSelected; | ||
| break; | ||
|
|
||
| case isDescendantSelected: | ||
| width = columnBaseWidth; | ||
| break; | ||
|
|
||
| case isDescendantOfParentSelected: | ||
| width = columnBaseWidth; | ||
| if ( ! hasChildren ) width -= emptyColumnSelected; | ||
| break; | ||
|
|
||
| case isAncestorSelected: | ||
| width = columnBaseWidth; | ||
| if ( ! hasChildren ) width -= parentSelected; | ||
| break; | ||
|
|
||
| case placeholder: | ||
| width -= | ||
| columnsInRow === 1 | ||
| ? parentSelected | ||
| : placeholderParentSelected; | ||
| width -= | ||
| columnSelected + | ||
| ( columnsInRow === 1 ? parentSelected : dashedBorderWidth ); | ||
| break; | ||
|
|
||
| default: | ||
| if ( columnsInRow > 1 ) { | ||
| const margins = columnsInRow * 2 * styles.columnMargin.marginLeft; | ||
| width = ( minWidth - margins ) / Math.max( 1, columnsInRow ); | ||
|
Comment on lines
+42
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have checked and this also works for more than 2 However we need to implement ideal version of FloatingToolbar because it breaks the layout when there is no enough space (it has minWIdth and the Column container is stretch to this sizes - see below screen). It's not something we need to change here just as reminder) Selected Column with broken Columns layout Selected Column with proper Columns layout after disable FloatingToolbar
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it's known issue and exists also in buttons block |
||
| } | ||
|
|
||
| return { width }; | ||
|
|
@@ -121,11 +60,8 @@ function ColumnEdit( { | |
| styles.columnPlaceholder, | ||
| styles.columnPlaceholderDark | ||
| ), | ||
| applyBlockStyle( true ), | ||
| { | ||
| ...styles.marginVerticalDense, | ||
| ...styles.marginHorizontalNone, | ||
| }, | ||
| applyBlockStyle(), | ||
| styles.columnPlaceholderNotSelected, | ||
| ] } | ||
| ></View> | ||
| ); | ||
|
|
@@ -140,10 +76,16 @@ function ColumnEdit( { | |
| isCollapsed={ false } | ||
| /> | ||
| </BlockControls> | ||
| <View style={ applyBlockStyle() }> | ||
| <View | ||
| style={ [ | ||
| applyBlockStyle(), | ||
| isSelected && hasChildren && styles.innerBlocksBottomSpace, | ||
| ] } | ||
| > | ||
| <InnerBlocks | ||
| flatListProps={ { | ||
| scrollEnabled: false, | ||
| style: styles.innerBlocks, | ||
| } } | ||
| renderAppender={ | ||
| isSelected && InnerBlocks.ButtonBlockAppender | ||
|
|
@@ -175,7 +117,6 @@ function ColumnEditWrapper( props ) { | |
| export default compose( [ | ||
| withSelect( ( select, { clientId } ) => { | ||
| const { | ||
| getBlockParents, | ||
| getBlockCount, | ||
| getBlockRootClientId, | ||
| getSelectedBlockClientId, | ||
|
|
@@ -190,26 +131,10 @@ export default compose( [ | |
| const isParentSelected = | ||
| selectedBlockClientId && selectedBlockClientId === parentId; | ||
|
|
||
| const selectedParents = selectedBlockClientId | ||
| ? getBlockParents( selectedBlockClientId ) | ||
| : []; | ||
| const isDescendantOfParentSelected = selectedParents.includes( | ||
| parentId | ||
| ); | ||
|
|
||
| const parents = getBlockParents( clientId, true ); | ||
|
|
||
| const isAncestorSelected = | ||
| selectedBlockClientId && parents.includes( selectedBlockClientId ); | ||
| const isDescendantSelected = selectedParents.includes( clientId ); | ||
|
|
||
| return { | ||
| hasChildren, | ||
| isParentSelected, | ||
| isSelected, | ||
| isDescendantOfParentSelected, | ||
| isAncestorSelected, | ||
| isDescendantSelected, | ||
| }; | ||
| } ), | ||
| withPreferredColorScheme, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,17 @@ | ||
| .columnsPlaceholder { | ||
| padding: 12px; | ||
| margin-bottom: 12px; | ||
| background-color: $white; | ||
| border: $border-width dashed $gray; | ||
| border-radius: 4px; | ||
| } | ||
|
|
||
| .columnsPlaceholderDark { | ||
| background-color: $black; | ||
| border: $border-width dashed $gray-70; | ||
| } | ||
|
|
||
| .marginVerticalDense { | ||
| margin-top: $block-selected-child-margin; | ||
| margin-bottom: $block-selected-child-margin; | ||
| } | ||
|
|
||
| .marginHorizontalNone { | ||
| margin-left: 0; | ||
| margin-right: 0; | ||
| } | ||
|
|
||
| .columnsContainer { | ||
| flex-direction: row; | ||
| flex-wrap: wrap; | ||
| justify-content: flex-start; | ||
| justify-content: space-between; | ||
| align-items: stretch; | ||
| max-width: $content-width; | ||
| overflow: hidden; | ||
| overflow: visible; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .innerBlocks { | ||
| overflow: visible; | ||
| } | ||
|
|
||
| .innerBlocksSelected { | ||
| margin-bottom: $block-edge-to-content; | ||
| } |



Uh oh!
There was an error while loading. Please reload this page.