Skip to content

Commit

Permalink
Replace with ToggleGroupControl
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Aug 17, 2022
1 parent 7f8e461 commit 15ac97d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/**
* WordPress dependencies
*/
import { BaseControl, Button } from '@wordpress/components';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
} from '@wordpress/components';
import { formatStrikethrough, formatUnderline } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

Expand All @@ -27,32 +30,26 @@ const TEXT_DECORATIONS = [
*
* @return {WPElement} Text decoration control.
*/
export default function TextDecorationControl( { value, onChange } ) {
export default function TextDecorationControl( { value, onChange, ...props } ) {
return (
<fieldset className="block-editor-text-decoration-control">
<BaseControl.VisualLabel as="legend">
{ __( 'Decoration' ) }
</BaseControl.VisualLabel>
<div className="block-editor-text-decoration-control__buttons">
{ TEXT_DECORATIONS.map( ( textDecoration ) => {
return (
<Button
key={ textDecoration.value }
icon={ textDecoration.icon }
isSmall
isPressed={ textDecoration.value === value }
onClick={ () =>
onChange(
textDecoration.value === value
? undefined
: textDecoration.value
)
}
aria-label={ textDecoration.name }
/>
);
} ) }
</div>
</fieldset>
<ToggleGroupControl
{ ...props }
className="block-editor-text-decoration-control"
__experimentalIsIconGroup
label={ __( 'Decoration' ) }
value={ value }
onChange={ onChange }
>
{ TEXT_DECORATIONS.map( ( textDecoration ) => {
return (
<ToggleGroupControlOptionIcon
key={ textDecoration.value }
value={ textDecoration.value }
icon={ textDecoration.icon }
label={ textDecoration.name }
/>
);
} ) }
</ToggleGroupControl>
);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
import { BaseControl, Button } from '@wordpress/components';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import {
formatCapitalize,
Expand Down Expand Up @@ -36,32 +42,26 @@ const TEXT_TRANSFORMS = [
*
* @return {WPElement} Text transform control.
*/
export default function TextTransformControl( { value, onChange } ) {
export default function TextTransformControl( { value, onChange, ...props } ) {
return (
<fieldset className="block-editor-text-transform-control">
<BaseControl.VisualLabel as="legend">
{ __( 'Letter case' ) }
</BaseControl.VisualLabel>
<div className="block-editor-text-transform-control__buttons">
{ TEXT_TRANSFORMS.map( ( textTransform ) => {
return (
<Button
key={ textTransform.value }
icon={ textTransform.icon }
isSmall
isPressed={ value === textTransform.value }
aria-label={ textTransform.name }
onClick={ () =>
onChange(
value === textTransform.value
? undefined
: textTransform.value
)
}
/>
);
} ) }
</div>
</fieldset>
<ToggleGroupControl
{ ...props }
className="block-editor-text-transform-control"
__experimentalIsIconGroup
label={ __( 'Letter case' ) }
value={ value }
onChange={ onChange }
>
{ TEXT_TRANSFORMS.map( ( textTransform ) => {
return (
<ToggleGroupControlOptionIcon
key={ textTransform.value }
value={ textTransform.value }
icon={ textTransform.icon }
label={ textTransform.name }
/>
);
} ) }
</ToggleGroupControl>
);
}

This file was deleted.

2 changes: 0 additions & 2 deletions packages/block-editor/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
@import "./components/responsive-block-control/style.scss";
@import "./components/rich-text/style.scss";
@import "./components/skip-to-selected-block/style.scss";
@import "./components/text-transform-control/style.scss";
@import "./components/text-decoration-control/style.scss";
@import "./components/tool-selector/style.scss";
@import "./components/url-input/style.scss";
@import "./components/url-popover/style.scss";
Expand Down

0 comments on commit 15ac97d

Please sign in to comment.