-
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.
* Add breadcrumbs to floating toolbar * Add dark mode support
- Loading branch information
Showing
6 changed files
with
130 additions
and
4 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
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
68 changes: 68 additions & 0 deletions
68
packages/block-editor/src/components/block-list/breadcrumb.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,68 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Icon } from '@wordpress/components'; | ||
import { withSelect } from '@wordpress/data'; | ||
import { compose } from '@wordpress/compose'; | ||
import { getBlockType } from '@wordpress/blocks'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import { View, Text, TouchableOpacity } from 'react-native'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockTitle from '../block-title'; | ||
import SubdirectorSVG from './subdirectory-icon'; | ||
|
||
import styles from './breadcrumb.scss'; | ||
|
||
const BlockBreadcrumb = ( { clientId, blockIcon, rootClientId, rootBlockIcon } ) => { | ||
return ( | ||
<View style={ styles.breadcrumbContainer }> | ||
<TouchableOpacity style={ styles.button } onPress={ () => {/* Open BottomSheet with markup */} }> | ||
{ rootClientId && rootBlockIcon && ( | ||
[ <Icon key="parent-icon" size={ 20 } icon={ rootBlockIcon.src } fill={ styles.icon.color } />, | ||
<View key="subdirectory-icon" style={ styles.arrow }><SubdirectorSVG fill={ styles.arrow.color } /></View>, | ||
] | ||
) } | ||
<Icon size={ 24 } icon={ blockIcon.src } fill={ styles.icon.color } /> | ||
<Text style={ styles.breadcrumbTitle }><BlockTitle clientId={ clientId } /></Text> | ||
</TouchableOpacity> | ||
</View> | ||
); | ||
}; | ||
|
||
export default compose( [ | ||
withSelect( ( select, { clientId } ) => { | ||
const { | ||
getBlockRootClientId, | ||
getBlockName, | ||
} = select( 'core/block-editor' ); | ||
|
||
const blockName = getBlockName( clientId ); | ||
const blockType = getBlockType( blockName ); | ||
const blockIcon = blockType.icon; | ||
|
||
const rootClientId = getBlockRootClientId( clientId ); | ||
|
||
if ( ! rootClientId ) { | ||
return { | ||
clientId, | ||
blockIcon, | ||
}; | ||
} | ||
const rootBlockName = getBlockName( rootClientId ); | ||
const rootBlockType = getBlockType( rootBlockName ); | ||
const rootBlockIcon = rootBlockType.icon; | ||
|
||
return { | ||
clientId, | ||
blockIcon, | ||
rootClientId, | ||
rootBlockIcon, | ||
}; | ||
} ), | ||
] )( BlockBreadcrumb ); |
28 changes: 28 additions & 0 deletions
28
packages/block-editor/src/components/block-list/breadcrumb.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,28 @@ | ||
.breadcrumbContainer { | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: flex-start; | ||
padding-left: 5; | ||
padding-right: 15; | ||
} | ||
|
||
.breadcrumbTitle { | ||
color: $white; | ||
margin-left: 4; | ||
} | ||
|
||
.icon { | ||
color: $white; | ||
} | ||
|
||
.button { | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
|
||
.arrow { | ||
color: $light-opacity-light-700; | ||
margin-top: -4px; | ||
margin-left: 4; | ||
margin-right: 4; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/block-editor/src/components/block-list/subdirectory-icon.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,18 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/components'; | ||
|
||
const Subdirectory = ( { ...extraProps } ) => ( | ||
<SVG | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={ 14 } | ||
height={ 14 } | ||
viewBox="0 0 20 20" | ||
{ ...extraProps } | ||
> | ||
<Path d="M19 15l-6 6-1.42-1.42L15.17 16H4V4h2v10h9.17l-3.59-3.58L13 9l6 6z" /> | ||
</SVG> ) | ||
; | ||
|
||
export default Subdirectory; |