From 435119c3bed91c10737a574e072d7482e7e5c6bb Mon Sep 17 00:00:00 2001 From: Enej Bajgoric Date: Tue, 7 Sep 2021 08:56:36 -0700 Subject: [PATCH] [Mobile] Update the bottom sheet header (#34309) * Add new Header bottomSheet component * Include the new Header component in buttomSheet * Update NavigationHeader to use the new Header component for backwards compatibility * Update all instances of NavigationHeader with Header * Update BottomSheet Header documentation to reduce its size (#34339) Leverage short, declarative statements when possible. * Move Header to NavBar * Update usage from Header to NavBar * Remove the NavigationHeader component * Fix space in the styles Co-authored-by: David Calhoun <438664+dcalhoun@users.noreply.github.com> --- .../src/font-size-picker/index.native.js | 10 +- .../index.native.js | 10 +- .../bottom-sheet-text-control/index.native.js | 10 +- .../src/mobile/bottom-sheet/index.native.js | 4 +- .../src/mobile/bottom-sheet/nav-bar/README.md | 61 ++++++++ .../nav-bar/action-button.native.js | 30 ++++ .../nav-bar/apply-button.native.js | 53 +++++++ .../nav-bar/back-button.native.js | 94 +++++++++++ .../bottom-sheet/nav-bar/heading.native.js | 33 ++++ .../bottom-sheet/nav-bar/index.native.js | 23 +++ .../bottom-sheet/nav-bar/styles.native.scss | 69 ++++++++ .../bottom-sheet/navigation-header.native.js | 147 ------------------ .../mobile/bottom-sheet/sub-sheet/README.md | 8 +- .../gradient-picker-screen.native.js | 10 +- .../color-settings/palette.screen.native.js | 10 +- .../index.native.js | 19 ++- .../src/mobile/link-picker/index.native.js | 13 +- .../help-detail-navigation-screen.native.js | 12 +- .../components/editor-help/index.native.js | 24 +-- 19 files changed, 437 insertions(+), 203 deletions(-) create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/README.md create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/action-button.native.js create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/apply-button.native.js create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/back-button.native.js create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/heading.native.js create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/index.native.js create mode 100644 packages/components/src/mobile/bottom-sheet/nav-bar/styles.native.scss delete mode 100644 packages/components/src/mobile/bottom-sheet/navigation-header.native.js diff --git a/packages/components/src/font-size-picker/index.native.js b/packages/components/src/font-size-picker/index.native.js index 2be833c450a82..1da82363c4789 100644 --- a/packages/components/src/font-size-picker/index.native.js +++ b/packages/components/src/font-size-picker/index.native.js @@ -84,10 +84,12 @@ function FontSizePicker( { showSheet={ showSubSheet } > <> - + + + + { label } + + <> - + + + + { label } + + { items.map( ( item, index ) => ( <> - + + + + { label } + + ( + + + {} } /> + A Sheet Title + {} } /> + + +); +``` + +## BottomSheet.NavBar + +Provides structural styles for left-center-right layout for header UI. + +## BottomSheet.NavBar.Title + +Displays a styled title for a bottom sheet. + +## BottomSheet.NavBar.ApplyButton + +Displays a styled button to apply settings of bottom sheet controls. + +### Props + +#### onPress + +Callback invoked once the button is pressed. + +## BottomSheet.NavBar.BackButton + +Displays a styled button to navigate backwards from a bottom sheet. + +### Props + +#### onPress + +Callback invoked once the button is pressed. + +## BottomSheet.NavBar.DismissButton + +Displays a styled button to dismiss a full screen bottom sheet. + +### Props + +#### onPress + +Callback invoked once the button is pressed. + +#### iosText + +Used to display iOS text if different from "Cancel". \ No newline at end of file diff --git a/packages/components/src/mobile/bottom-sheet/nav-bar/action-button.native.js b/packages/components/src/mobile/bottom-sheet/nav-bar/action-button.native.js new file mode 100644 index 0000000000000..6b11f30959fe5 --- /dev/null +++ b/packages/components/src/mobile/bottom-sheet/nav-bar/action-button.native.js @@ -0,0 +1,30 @@ +/** + * External dependencies + */ +import { View, TouchableWithoutFeedback } from 'react-native'; + +/** + * Internal dependencies + */ +import styles from './styles.scss'; + +// Action button component is used by both Back and Apply Button componenets. +function ActionButton( { + onPress, + accessibilityLabel, + accessibilityHint, + children, +} ) { + return ( + + { children } + + ); +} + +export default ActionButton; diff --git a/packages/components/src/mobile/bottom-sheet/nav-bar/apply-button.native.js b/packages/components/src/mobile/bottom-sheet/nav-bar/apply-button.native.js new file mode 100644 index 0000000000000..a5362f1a67a09 --- /dev/null +++ b/packages/components/src/mobile/bottom-sheet/nav-bar/apply-button.native.js @@ -0,0 +1,53 @@ +/** + * External dependencies + */ +import { View, Text, Platform } from 'react-native'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { Icon, check } from '@wordpress/icons'; +import { usePreferredColorSchemeStyle } from '@wordpress/compose'; + +/** + * Internal dependencies + */ +import styles from './styles.scss'; +import ActionButton from './action-button'; + +function ApplyButton( { onPress } ) { + const buttonTextStyle = usePreferredColorSchemeStyle( + styles[ 'button-text' ], + styles[ 'button-text-dark' ] + ); + + const applyButtonStyle = usePreferredColorSchemeStyle( + styles[ 'apply-button-icon' ], + styles[ 'apply-button-icon-dark' ] + ); + + return ( + + + { Platform.OS === 'ios' ? ( + + { __( 'Apply' ) } + + ) : ( + + ) } + + + ); +} + +export default ApplyButton; diff --git a/packages/components/src/mobile/bottom-sheet/nav-bar/back-button.native.js b/packages/components/src/mobile/bottom-sheet/nav-bar/back-button.native.js new file mode 100644 index 0000000000000..859eba98b9604 --- /dev/null +++ b/packages/components/src/mobile/bottom-sheet/nav-bar/back-button.native.js @@ -0,0 +1,94 @@ +/** + * External dependencies + */ +import { View, Platform, Text } from 'react-native'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { Icon, arrowLeft, close } from '@wordpress/icons'; +import { usePreferredColorSchemeStyle } from '@wordpress/compose'; + +/** + * Internal dependencies + */ +import styles from './styles.scss'; +import ActionButton from './action-button'; +import chevronBack from './../chevron-back'; + +function Button( { onPress, icon, text } ) { + const buttonTextStyle = usePreferredColorSchemeStyle( + styles[ 'button-text' ], + styles[ 'button-text-dark' ] + ); + + return ( + + + { icon } + { text && ( + + { text } + + ) } + + + ); +} + +function BackButton( { onPress } ) { + const chevronLeftStyle = usePreferredColorSchemeStyle( + styles[ 'chevron-left-icon' ], + styles[ 'chevron-left-icon-dark' ] + ); + const arrowLeftStyle = usePreferredColorSchemeStyle( + styles[ 'arrow-left-icon' ], + styles[ 'arrow-right-icon-dark' ] + ); + + let backIcon; + let backText; + + if ( Platform.OS === 'ios' ) { + backIcon = ( + + ); + backText = __( 'Back' ); + } else { + backIcon = ( + + ); + } + + return