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

Feat: Button groups in Typography tools should use ToggleGroupControl #64529

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {
alignJustify,
} from '@wordpress/icons';
import { useMemo } from '@wordpress/element';

/**
* Internal dependencies
*/
import SegmentedTextControl from '../segmented-text-control';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
} from '@wordpress/components';

const TEXT_ALIGNMENT_OPTIONS = [
{
Expand Down Expand Up @@ -75,9 +74,11 @@ export default function TextAlignmentControl( {
}

return (
<SegmentedTextControl
<ToggleGroupControl
isDeselectable
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Text alignment' ) }
options={ validOptions }
className={ clsx(
'block-editor-text-alignment-control',
className
Expand All @@ -86,6 +87,17 @@ export default function TextAlignmentControl( {
onChange={ ( newValue ) => {
onChange( newValue === value ? undefined : newValue );
} }
/>
>
{ validOptions.map( ( option ) => {
return (
<ToggleGroupControlOptionIcon
key={ option.value }
value={ option.value }
icon={ option.icon }
label={ option.label }
/>
);
} ) }
</ToggleGroupControl>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import clsx from 'clsx';
*/
import { reset, formatStrikethrough, formatUnderline } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import SegmentedTextControl from '../segmented-text-control';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
} from '@wordpress/components';

const TEXT_DECORATIONS = [
{
Expand Down Expand Up @@ -48,9 +47,11 @@ export default function TextDecorationControl( {
className,
} ) {
return (
<SegmentedTextControl
<ToggleGroupControl
isDeselectable
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Decoration' ) }
options={ TEXT_DECORATIONS }
className={ clsx(
'block-editor-text-decoration-control',
className
Expand All @@ -59,6 +60,17 @@ export default function TextDecorationControl( {
onChange={ ( newValue ) => {
onChange( newValue === value ? undefined : newValue );
} }
/>
>
{ TEXT_DECORATIONS.map( ( option ) => {
return (
<ToggleGroupControlOptionIcon
key={ option.value }
value={ option.value }
icon={ option.icon }
label={ option.label }
/>
);
} ) }
</ToggleGroupControl>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {
formatLowercase,
formatUppercase,
} from '@wordpress/icons';

/**
* Internal dependencies
*/
import SegmentedTextControl from '../segmented-text-control';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
} from '@wordpress/components';

const TEXT_TRANSFORMS = [
{
Expand Down Expand Up @@ -54,9 +53,11 @@ const TEXT_TRANSFORMS = [
*/
export default function TextTransformControl( { className, value, onChange } ) {
return (
<SegmentedTextControl
<ToggleGroupControl
isDeselectable
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Letter case' ) }
options={ TEXT_TRANSFORMS }
className={ clsx(
'block-editor-text-transform-control',
className
Expand All @@ -65,6 +66,17 @@ export default function TextTransformControl( { className, value, onChange } ) {
onChange={ ( newValue ) => {
onChange( newValue === value ? undefined : newValue );
} }
/>
>
{ TEXT_TRANSFORMS.map( ( option ) => {
return (
<ToggleGroupControlOptionIcon
key={ option.value }
value={ option.value }
icon={ option.icon }
label={ option.label }
/>
);
} ) }
</ToggleGroupControl>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import clsx from 'clsx';
*/
import { __, isRTL } from '@wordpress/i18n';
import { textHorizontal, textVertical } from '@wordpress/icons';

/**
* Internal dependencies
*/
import SegmentedTextControl from '../segmented-text-control';
import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
} from '@wordpress/components';

const WRITING_MODES = [
{
Expand All @@ -39,14 +38,27 @@ const WRITING_MODES = [
*/
export default function WritingModeControl( { className, value, onChange } ) {
return (
<SegmentedTextControl
<ToggleGroupControl
isDeselectable
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Orientation' ) }
options={ WRITING_MODES }
className={ clsx( 'block-editor-writing-mode-control', className ) }
value={ value }
onChange={ ( newValue ) => {
onChange( newValue === value ? undefined : newValue );
} }
/>
>
{ WRITING_MODES.map( ( option ) => {
return (
<ToggleGroupControlOptionIcon
key={ option.value }
value={ option.value }
icon={ option.icon }
label={ option.label }
/>
);
} ) }
</ToggleGroupControl>
);
}
1 change: 0 additions & 1 deletion packages/block-editor/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
@import "./components/multi-selection-inspector/style.scss";
@import "./components/responsive-block-control/style.scss";
@import "./components/rich-text/style.scss";
@import "./components/segmented-text-control/style.scss";
@import "./components/skip-to-selected-block/style.scss";
@import "./components/tabbed-sidebar/style.scss";
@import "./components/tool-selector/style.scss";
Expand Down
Loading