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] Breadcrumbs #17471

Merged
merged 59 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
635108e
[RNMobile] Native mobile release v1.11.0 (#17181)
etoledom Aug 28, 2019
643c1b2
Activate Travis CI on rnmobile/master branch (#17229)
etoledom Aug 28, 2019
a78f204
Add native support for the MediaText block (#16305)
Tug Aug 29, 2019
3db95b7
MediaUpload and MediaPlaceholder unify props (#17145)
dratwas Aug 30, 2019
7aa44a2
Unify media placeholder and upload props within media-text (#17268)
lukewalczak Aug 30, 2019
f9fa455
[RNMobile] Fix dismiss keyboard button for the post title (#17260)
geriux Aug 30, 2019
7b12673
Recover border colors (#17269)
etoledom Aug 30, 2019
14d482b
[RNMobile] Insure tapping at end of post inserts at end
mchowning Aug 6, 2019
89664eb
Support group block on mobile (#17251)
lukewalczak Sep 3, 2019
fc8c3da
Remove redundant bg color within button appender (#17325)
lukewalczak Sep 4, 2019
264b178
[RNMobile] DarkMode improvements (#17309)
etoledom Sep 4, 2019
654e162
Add FloatingToolbar component
lukewalczak Sep 10, 2019
111059c
Add visible overflow to flat list wrapper
lukewalczak Sep 10, 2019
89ed4d7
Remove useless codelines
lukewalczak Sep 10, 2019
900233d
Update test
lukewalczak Sep 10, 2019
2deb517
Trigger CI
lukewalczak Sep 10, 2019
6106f27
Remove redundant conditions
lukewalczak Sep 10, 2019
67c5cca
Trigger CI
lukewalczak Sep 10, 2019
6cd7f52
add breadcrumbs
dratwas Sep 19, 2019
648a1b9
[RNMobile] Add autosave to mobile apps (#17329)
daniloercoli Sep 19, 2019
d0c4b3c
styles tweaks
dratwas Sep 19, 2019
92b527e
add icon and some tweaks
dratwas Sep 19, 2019
e9d0ade
fix typo
dratwas Sep 19, 2019
b4a2a77
add subdirectory icon
dratwas Sep 23, 2019
6147e47
use subdirectory icon
dratwas Sep 23, 2019
9659a73
Trigger CI
lukewalczak Sep 23, 2019
e99d365
Add isAppender functionality on mobile (#17195)
lukewalczak Sep 25, 2019
69da85e
Autosave monitor - Make the mobile editor ping the native at each key…
daniloercoli Sep 25, 2019
ae6d2ce
[RNMobile] Refactor Dark Mode HOC (#17552)
Tug Sep 25, 2019
1c9b133
Add missing heading levels to the UI (H4, H5, H6) (#17533)
SergioEstevao Sep 25, 2019
8752302
Fix FloatingToolbar for the first item in FlatList
lukewalczak Sep 26, 2019
e3a4f1a
Small cleanup
lukewalczak Sep 26, 2019
df025a6
Fix lint issue (#17598)
lukewalczak Sep 26, 2019
d8b0d83
Fix list filter on paste for RN mobile. (#17550)
SergioEstevao Sep 26, 2019
59f0d5f
Merge branch 'rnmobile/master' into rnmobile/floating-toolbar
lukewalczak Sep 26, 2019
f3085c1
[RNMobile] Move MediaUploadPorgress to its own component folder (#17392)
geriux Sep 27, 2019
636bf83
Working on Android toolbar behaviour
lukewalczak Sep 27, 2019
b6e9627
style fix
dratwas Sep 27, 2019
e51a87c
update toolbar background
dratwas Sep 30, 2019
95acf23
Rnmobile/fix link editing on start (#17631)
SergioEstevao Sep 30, 2019
47cd600
Small code refactor
lukewalczak Sep 30, 2019
6449038
Use temporary solution for first item in group
lukewalczak Oct 1, 2019
d0ba0fe
Merge branch 'rnmobile/master' into rnmobile/floating-toolbar
lukewalczak Oct 1, 2019
c70edc5
Merge branch 'master' into rnmobile/floating-toolbar
lukewalczak Oct 1, 2019
300a8a5
Merge fix
lukewalczak Oct 1, 2019
a9d7489
Merge fix
lukewalczak Oct 1, 2019
2695248
Make FloatingToolbar conditional to show flag
lukewalczak Oct 1, 2019
d2a07ec
Fix after merging
lukewalczak Oct 1, 2019
e911f5d
Add check for Media&Text block
lukewalczak Oct 1, 2019
89e0790
Merge branch 'rnmobile/master' into rnmobile/breadcrumbs
dratwas Oct 1, 2019
e3b3b59
Merge branch 'rnmobile/floating-toolbar' into rnmobile/breadcrumbs
dratwas Oct 1, 2019
98ad647
Merge branch 'master' into rnmobile/breadcrumbs
dratwas Oct 9, 2019
addee65
move icon to separate file
dratwas Oct 9, 2019
4d4850a
fix icon
dratwas Oct 9, 2019
60a77f2
fix padding
dratwas Oct 9, 2019
72d41ef
remove incorrect comment
dratwas Oct 9, 2019
171fb82
Merge branch 'master' into rnmobile/breadcrumbs
dratwas Oct 9, 2019
5646a15
remove unused props and change colors
dratwas Oct 17, 2019
7e5bab0
add dark mode
dratwas Oct 17, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ import styles from './block-mobile-floating-toolbar.scss';
/**
* WordPress dependencies
*/
import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { createSlotFill } from '@wordpress/components';

const { Fill, Slot } = createSlotFill( 'FloatingToolbar' );

function FloatingToolbar( { children } ) {
const FloatingToolbarFill = ( { children, getStylesFromColorScheme } ) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is also a usePreferredColorScheme hook. I'm fine with either option, but the hook seemed like a better fit for a functional component, so just raising awareness of it 😁

Copy link
Contributor Author

@dratwas dratwas Oct 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that there is a hook called usePreferredColorScheme but I would need to duplicate logic from here since the hook provides only 'dark' or 'light' string.
https://github.com/WordPress/gutenberg/blob/master/packages/compose/src/higher-order/with-preferred-color-scheme/index.native.js#L9-L18

Maybe we could extract that logic somewhere which will allow us to easily use withusePreferredColorScheme hook w/o duplication.

return (
<Fill>
{ ( { innerFloatingToolbar } ) => {
const fillStyle = getStylesFromColorScheme( styles.floatingToolbarFillColor, styles.floatingToolbarFillColorDark );
return (
<TouchableWithoutFeedback>
<View
// Issue: `FloatingToolbar` placed above the first item in group is not touchable on Android.
// Temporary solution: Use `innerFloatingToolbar` to place `FloatingToolbar` over the first item in group.
// TODO: `{ top: innerFloatingToolbar ? 0 : -44 }` along with `innerFloatingToolbar` should be removed once issue is fixed.
style={ [ styles.floatingToolbarFill, { top: innerFloatingToolbar ? 0 : -44 } ] }
style={ [ fillStyle, styles.floatingToolbarFill, { top: innerFloatingToolbar ? 0 : -44 } ] }
>{ children }
</View>
</TouchableWithoutFeedback>
Expand All @@ -33,8 +35,9 @@ function FloatingToolbar( { children } ) {

</Fill>
);
}
};

const FloatingToolbar = compose( withPreferredColorScheme )( FloatingToolbarFill );
FloatingToolbar.Slot = Slot;

export default FloatingToolbar;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.floatingToolbarFill {
background-color: $dark-gray-500;
margin: auto;
min-width: 100;
max-height: $floating-toolbar-height;
Expand All @@ -13,3 +12,11 @@
justify-content: center;
align-self: center;
}

.floatingToolbarFillColor {
background-color: rgba(#1d2327, 0.85);
}

.floatingToolbarFillColorDark {
background-color: rgba(#3c434a, 0.85);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import BlockEdit from '../block-edit';
import BlockInvalidWarning from './block-invalid-warning';
import BlockMobileToolbar from './block-mobile-toolbar';
import FloatingToolbar from './block-mobile-floating-toolbar';
import Breadcrumbs from './breadcrumb';
import NavigateUpSVG from './nav-up-icon';

class BlockListBlock extends Component {
Expand Down Expand Up @@ -136,6 +137,7 @@ class BlockListBlock extends Component {
/>
<View style={ styles.pipe } />
</Toolbar>
<Breadcrumbs clientId={ clientId } />
</FloatingToolbar>
) }
<TouchableWithoutFeedback
Expand Down
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 );
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;
}
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;