Skip to content

Commit

Permalink
Improve name of AdditionalSettings component
Browse files Browse the repository at this point in the history
  • Loading branch information
mchowning committed Aug 19, 2019
1 parent d4b828a commit 0f74d0a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
44 changes: 0 additions & 44 deletions packages/block-library/src/list/additional-settings.js

This file was deleted.

15 changes: 8 additions & 7 deletions packages/block-library/src/list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
* Internal dependencies
*/
import { name } from './';
import AdditionalSettings from './additional-settings';
import OrderedListSettings from './ordered-list-settings';

export default function ListEdit( {
attributes,
Expand Down Expand Up @@ -138,11 +138,12 @@ export default function ListEdit( {
>
{ controls }
</RichText>
<AdditionalSettings
setAttributes={ setAttributes }
ordered={ ordered }
reversed={ reversed }
start={ start }
/>
{ ordered && (
<OrderedListSettings
setAttributes={ setAttributes }
ordered={ ordered }
reversed={ reversed }
start={ start }
/> ) }
</>;
}
43 changes: 43 additions & 0 deletions packages/block-library/src/list/ordered-list-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import {
TextControl,
PanelBody,
ToggleControl,
} from '@wordpress/components';

const OrderedListSettings = ( { setAttributes, reversed, start } ) => (
<InspectorControls>
<PanelBody title={ __( 'Ordered List Settings' ) }>
<TextControl
label={ __( 'Start Value' ) }
type="number"
onChange={ ( value ) => {
const int = parseInt( value, 10 );

setAttributes( {
// It should be possible to unset the value,
// e.g. with an empty string.
start: isNaN( int ) ? undefined : int,
} );
} }
value={ Number.isInteger( start ) ? start.toString( 10 ) : '' }
step="1"
/>
<ToggleControl
label={ __( 'Reverse List Numbering' ) }
checked={ reversed || false }
onChange={ ( value ) => {
setAttributes( {
// Unset the attribute if not reversed.
reversed: value || undefined,
} );
} }
/>
</PanelBody>
</InspectorControls> );

export default OrderedListSettings;

0 comments on commit 0f74d0a

Please sign in to comment.