UNPKG

@wordpress/components

Version:
102 lines (90 loc) 2.45 kB
import { createElement } from "@wordpress/element"; /** * 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(_ref) { let { onPress, icon, text } = _ref; const buttonTextStyle = usePreferredColorSchemeStyle(styles['button-text'], styles['button-text-dark']); return createElement(View, { style: styles['back-button'] }, createElement(ActionButton, { onPress: onPress, accessibilityLabel: __('Go back'), accessibilityHint: __('Navigates to the previous content sheet') }, icon, text && createElement(Text, { style: buttonTextStyle, maxFontSizeMultiplier: 2 }, text))); } function BackButton(_ref2) { let { onPress } = _ref2; const chevronLeftStyle = usePreferredColorSchemeStyle(styles['chevron-left-icon'], styles['chevron-left-icon-dark']); const arrowLeftStyle = usePreferredColorSchemeStyle(styles['arrow-left-icon'], styles['arrow-left-icon-dark']); let backIcon; let backText; if (Platform.OS === 'ios') { backIcon = createElement(Icon, { icon: chevronBack, size: 21, style: chevronLeftStyle }); backText = __('Back'); } else { backIcon = createElement(Icon, { icon: arrowLeft, size: 24, style: arrowLeftStyle }); } return createElement(Button, { onPress: onPress, icon: backIcon, text: backText }); } function DismissButton(_ref3) { let { onPress, iosText } = _ref3; const arrowLeftStyle = usePreferredColorSchemeStyle(styles['arrow-left-icon'], styles['arrow-left-icon-dark']); let backIcon; let backText; if (Platform.OS === 'ios') { backText = iosText ? iosText : __('Cancel'); } else { backIcon = createElement(Icon, { icon: close, size: 24, style: arrowLeftStyle }); } return createElement(Button, { onPress: onPress, icon: backIcon, text: backText }); } Button.Back = BackButton; Button.Dismiss = DismissButton; // Cancel or Close Button. export default Button; //# sourceMappingURL=back-button.native.js.map