-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support group block on mobile (#17251)
* First working version of the MediaText component for native mobile * Fix adding a block to an innerblock list * Disable mediaText on production * MediaText native: improve editor visuals * Move BlockToolbar from BlockList to Layout * Remove BlockEditorProvider from BlockList and add native version of EditorProvider to Editor. Plus support InsertionPoint and BlockListAppender * Update BlockMover for native to hide if locked or if it's the only block * Make the vertical align button work, add more styling options for toolbar buttons * Make sure registerCoreBlocks does not break in production * Copy docblock comment from the web version for registerCoreBlocks * Fix focusing on the media placeholder * Only support adding image for now * Update usage of MediaPlaceholder in MediaContainer * Enable autoScroll for just the out most block list * Fix JS Unit tests * Roll back to IconButton refactor and fix tests * Fix BlockVerticalAlignmentToolbar buttons style on mobile * Fix thing for web and ensure ariaPressed is always passed down * Use AriaPressed directly to style SVG on mobile * Update snapshots * Support group block on mobile * Extend shouldShowInsertionPoint condition to be false when group is selected * Code refactor * Update package-lock
- Loading branch information
1 parent
14d482b
commit 89664eb
Showing
10 changed files
with
161 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/block-editor/src/components/button-block-appender/index.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button, Dashicon } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Inserter from '../inserter'; | ||
import styles from './styles.scss'; | ||
|
||
function ButtonBlockAppender( { rootClientId } ) { | ||
return ( | ||
<> | ||
<Inserter | ||
rootClientId={ rootClientId } | ||
renderToggle={ ( { onToggle, disabled, isOpen } ) => ( | ||
<Button | ||
onClick={ onToggle } | ||
aria-expanded={ isOpen } | ||
disabled={ disabled } | ||
fixedRatio={ false } | ||
> | ||
<View style={ [ styles.appender, { flex: 1 } ] }> | ||
<Dashicon | ||
icon="plus-alt" | ||
style={ styles.addBlockButton } | ||
color={ styles.addBlockButton.color } | ||
size={ styles.addBlockButton.size } | ||
/> | ||
</View> | ||
</Button> | ||
) } | ||
isAppender | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
/** | ||
* @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/button-block-appender/README.md | ||
*/ | ||
export default ButtonBlockAppender; |
17 changes: 17 additions & 0 deletions
17
packages/block-editor/src/components/button-block-appender/styles.native.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.appender { | ||
align-items: center; | ||
justify-content: center; | ||
background-color: $gray-light; | ||
padding: 12px; | ||
background-color: $white; | ||
border: $border-width solid $light-gray-500; | ||
border-radius: 4px; | ||
} | ||
|
||
.addBlockButton { | ||
color: $white; | ||
background-color: $gray; | ||
border-radius: $icon-button-size-small / 2; | ||
overflow: hidden; | ||
size: $icon-button-size-small; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withSelect } from '@wordpress/data'; | ||
import { compose } from '@wordpress/compose'; | ||
import { | ||
InnerBlocks, | ||
withColors, | ||
} from '@wordpress/block-editor'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import styles from './editor.scss'; | ||
|
||
function GroupEdit( { | ||
hasInnerBlocks, | ||
isSelected, | ||
} ) { | ||
if ( ! isSelected && ! hasInnerBlocks ) { | ||
return ( | ||
<View style={ styles.groupPlaceholder } /> | ||
); | ||
} | ||
|
||
return ( | ||
<InnerBlocks | ||
renderAppender={ isSelected && InnerBlocks.ButtonBlockAppender } | ||
/> | ||
); | ||
} | ||
|
||
export default compose( [ | ||
withColors( 'backgroundColor' ), | ||
withSelect( ( select, { clientId } ) => { | ||
const { | ||
getBlock, | ||
} = select( 'core/block-editor' ); | ||
|
||
const block = getBlock( clientId ); | ||
|
||
return { | ||
hasInnerBlocks: !! ( block && block.innerBlocks.length ), | ||
}; | ||
} ), | ||
] )( GroupEdit ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.groupPlaceholder { | ||
padding: 12px; | ||
background-color: $white; | ||
border: $border-width dashed $light-gray-500; | ||
border-radius: 4px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters