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] Introduce grouping in the block settings inspector #17703

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { InspectorControls } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import styles from './container.native.scss';

function BottomSheetSettings( { editorSidebarOpened, closeGeneralSidebar, ...props } ) {
return (
<BottomSheet
isVisible={ editorSidebarOpened }
onClose={ closeGeneralSidebar }
hideHeader
contentStyle={ styles.content }
lukewalczak marked this conversation as resolved.
Show resolved Hide resolved
{ ...props }
>
<InspectorControls.Slot />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.content {
padding-left: 0;
padding-right: 0;
}
12 changes: 5 additions & 7 deletions packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Toolbar,
ToolbarButton,
PanelBody,
PanelActions,
} from '@wordpress/components';

import {
Expand Down Expand Up @@ -240,6 +241,8 @@ export class ImageEdit extends React.Component {
const { attributes, isSelected } = this.props;
const { url, height, width, alt, href, id, linkTarget, sizeSlug } = attributes;

const actions = [ { label: __( 'Clear All Settings' ), onPress: this.onClearSettings } ];

const getToolbarEditButton = ( open ) => (
<BlockControls>
<Toolbar>
Expand Down Expand Up @@ -286,16 +289,11 @@ export class ImageEdit extends React.Component {
label={ __( 'Alt Text' ) }
value={ alt || '' }
valuePlaceholder={ __( 'None' ) }
separatorType={ 'fullWidth' }
onChange={ this.updateAlt }
/>
<TextControl
label={ __( 'Clear All Settings' ) }
labelStyle={ styles.clearSettingsButton }
separatorType={ 'none' }
onPress={ this.onClearSettings }
onChangeValue={ this.updateAlt }
/>
</PanelBody>
<PanelActions actions={ actions } />
lukewalczak marked this conversation as resolved.
Show resolved Hide resolved
</InspectorControls>
);

Expand Down
4 changes: 0 additions & 4 deletions packages/block-library/src/image/styles.native.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
align-items: center;
}

.clearSettingsButton {
color: $alert-red;
}

.modalIcon {
width: 80px;
height: 80px;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot
export { default as BaseControl } from './base-control';
export { default as TextareaControl } from './textarea-control';
export { default as PanelBody } from './panel/body';
export { default as PanelActions } from './panel/actions';
export { default as Button } from './button';
export { default as TextControl } from './text-control';
export { default as ToggleControl } from './toggle-control';
Expand Down
9 changes: 7 additions & 2 deletions packages/components/src/mobile/bottom-sheet/cell.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class BottomSheetCell extends Component {
const defaultLabelStyle = showValue || icon !== undefined ? cellLabelStyle : defaultMissingIconAndValue;

const drawSeparator = ( separatorType && separatorType !== 'none' ) || separatorStyle === undefined;
const drawTopSeparator = drawSeparator && separatorType === 'topFullWidth';

const onCellPress = () => {
if ( isValueEditable ) {
Expand Down Expand Up @@ -91,6 +92,7 @@ class BottomSheetCell extends Component {
case 'leftMargin':
return leftMarginStyle;
case 'fullWidth':
case 'topFullWidth':
return defaultSeparatorStyle;
case 'none':
return undefined;
Expand Down Expand Up @@ -169,6 +171,9 @@ class BottomSheetCell extends Component {
onPress={ onCellPress }
style={ { ...styles.clipToBounds, ...style } }
>
{ drawTopSeparator && (
<View style={ separatorStyle() } />
) }
<View style={ styles.cellContainer }>
<View style={ styles.cellRowContainer }>
{ icon && (
Expand All @@ -177,14 +182,14 @@ class BottomSheetCell extends Component {
<View style={ platformStyles.labelIconSeparator } />
</View>
) }
<Text numberOfLines={ 1 } style={ { ...defaultLabelStyle, ...labelStyle } }>
<Text numberOfLines={ 1 } style={ [ defaultLabelStyle, labelStyle ] }>
{ label }
</Text>
</View>
{ showValue && getValueComponent() }
{ children }
</View>
{ drawSeparator && (
{ ! drawTopSeparator && (
<View style={ separatorStyle() } />
) }
</TouchableOpacity>
Expand Down
36 changes: 36 additions & 0 deletions packages/components/src/panel/actions.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* External dependencies
*/
import { View } from 'react-native';

/**
* WordPress dependencies
*/
import {
TextControl,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import styles from './actions.scss';

function PanelActions( { actions } ) {
return (
<View style={ styles.panelActionsContainer }>
{ actions.map( ( { label, onPress } ) => {
return (
<TextControl
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed the PR where this happened, but this doesn't make sense. TextControl is supposed to be a component that "let users enter and edit text":

Unfilled and filled TextControl components

This looks a lot more like a Button

Copy link
Contributor

Choose a reason for hiding this comment

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

you are absolutely right, there's a tech debt here we should be addressing, thanks for opening #18018

label={ label }
separatorType="topFullWidth"
onPress={ onPress }
labelStyle={ styles.defaultLabelStyle }
key={ label }
/>
);
} ) }
</View>
);
}

export default PanelActions;
7 changes: 7 additions & 0 deletions packages/components/src/panel/actions.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.panelActionsContainer {
padding-top: 24;
}

.defaultLabelStyle {
color: $alert-red;
}
12 changes: 9 additions & 3 deletions packages/components/src/panel/body.native.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/**
* External dependencies
*/
import { View } from 'react-native';
import { Text, View } from 'react-native';

/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import styles from './body.scss';

export class PanelBody extends Component {
constructor( ) {
Expand All @@ -15,9 +19,11 @@ export class PanelBody extends Component {
}

render() {
const { children } = this.props;
const { children, title } = this.props;

return (
<View >
<View style={ styles.panelContainer }>
{ title && <Text style={ styles.sectionHeaderText }>{ title }</Text> }
{ children }
</View>
);
Expand Down
11 changes: 11 additions & 0 deletions packages/components/src/panel/body.native.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.panelContainer {
padding: 0 16px;
}

.sectionHeaderText {
color: #87a6bc;
padding-top: 24;
padding-bottom: 8;
font-size: 14;
font-weight: 500;
}