Skip to content

Commit

Permalink
Invert toggle and language to be on by default.
Browse files Browse the repository at this point in the history
Addresses points raised in #16790
  • Loading branch information
getdave committed Sep 15, 2019
1 parent da03c7c commit 16daa12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
} from '@wordpress/components';

function ResponsiveBlockControl( props ) {
const { legend = '', property, toggleLabel, isOpen = false, onToggleResponsive, renderDefaultControl, defaultLabel = __( 'All' ), devices = [ __( 'Desktop' ), __( 'Tablet' ), __( 'Mobile' ) ], renderResponsiveControls } = props;
const { legend = '', property, toggleLabel, isOpen = false, onToggle, renderDefaultControl, defaultLabel = __( 'All' ), devices = [ __( 'Desktop' ), __( 'Tablet' ), __( 'Mobile' ) ], renderResponsiveControls } = props;

if ( ! legend || ! property || ! renderDefaultControl ) {
return null;
}

const toggleControlLabel = toggleLabel || sprintf( __( 'Manually adjust %s based on screensize.' ), property );
const toggleControlLabel = toggleLabel || sprintf( __( 'Use the same %s on all screensizes.' ), property );

const defaultControl = (
<fieldset>
Expand All @@ -23,7 +23,7 @@ function ResponsiveBlockControl( props ) {
</fieldset>
);

const responsiveControls = devices.map( ( deviceLabel ) => {
const defaultResponsiveControls = devices.map( ( deviceLabel ) => {
return (
<fieldset key={ deviceLabel }>
<legend>{ deviceLabel }</legend>
Expand All @@ -40,12 +40,12 @@ function ResponsiveBlockControl( props ) {
<div className="block-editor-responsive-block-control__inner">
{ ! isOpen && defaultControl }

{ isOpen && ( renderResponsiveControls ? renderResponsiveControls() : responsiveControls ) }
{ isOpen && ( renderResponsiveControls ? renderResponsiveControls() : defaultResponsiveControls ) }

<ToggleControl
label={ toggleControlLabel }
checked={ isOpen }
onChange={ onToggleResponsive }
checked={ ! isOpen }
onChange={ onToggle }
/>
</div>
</fieldset>
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function GroupEdit( {
legend="Padding"
property="padding"
isOpen={ showResponsiveControls }
onToggleResponsive={ ( isOpen ) => {
onToggle={ ( isOn ) => {
setState( {
showResponsiveControls: isOpen,
showResponsiveControls: ! isOn,
} );
} }
renderDefaultControl={ ( label ) => (
Expand Down

0 comments on commit 16daa12

Please sign in to comment.