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

[WIP] Global styles: add text alignment section #52426

Closed
wants to merge 5 commits into from
Closed
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
11 changes: 10 additions & 1 deletion packages/edit-site/src/components/global-styles/root-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __experimentalItemGroup as ItemGroup } from '@wordpress/components';
import { typography, color, layout } from '@wordpress/icons';
import { typography, color, layout, alignLeft } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

Expand Down Expand Up @@ -40,6 +40,15 @@ function RootMenu() {
{ __( 'Typography' ) }
</NavigationButtonAsItem>
) }
{ hasTypographyPanel && (
<NavigationButtonAsItem
icon={ alignLeft }
path="/text-alignment"
aria-label={ __( 'Text alignment' ) }
>
{ __( 'Text alignment' ) }
</NavigationButtonAsItem>
) }
{ hasColorPanel && (
<NavigationButtonAsItem
icon={ color }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import {
__experimentalVStack as VStack,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
Button,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import ScreenHeader from './header';
import Subtitle from './subtitle';
import BlockPreviewPanel from './block-preview-panel';
import {
alignCenter,
alignJustify,
alignLeft,
alignRight,
} from '@wordpress/icons';

const DEFAULT_ALIGNMENT_CONTROLS = [
{
icon: alignLeft,
title: __( 'Align text left' ),
align: 'left',
},
{
icon: alignCenter,
title: __( 'Align text center' ),
align: 'center',
},
{
icon: alignRight,
title: __( 'Align text right' ),
align: 'right',
},
{
icon: alignJustify,
title: __( 'Align justify' ),
align: 'justify',
},
];

function ScreenTextAlignment() {
return (
<>
<ScreenHeader
title={ __( 'Text Alignment' ) }
description={ __(
'Manage the global text alignment for pages and posts content.'
) }
/>

<BlockPreviewPanel />

<div className="edit-site-global-styles-screen-typography">
<VStack spacing={ 3 }>
<Subtitle level={ 3 }>{ __( 'Alignment' ) }</Subtitle>
{ DEFAULT_ALIGNMENT_CONTROLS.map(
( { icon, title, align } ) => (
<Button
icon={ icon }
key={ title }
onClick={ () => {
// TODO: update the style with useGlobalStyle
// eslint-disable-next-line no-console
console.log( 'clicked', align );
} }
>
{ title }
</Button>
)
) }

<ToggleGroupControl
isBlock
label={ __( 'Hyphens' ) }
onChange={ ( value ) => {
// TODO: update the style with useGlobalStyle
// eslint-disable-next-line no-console
console.log( 'changed', value );
} }
value="auto"
>
<ToggleGroupControlOption
label={ __( 'auto' ) }
value="auto"
/>
<ToggleGroupControlOption
label={ __( 'manual' ) }
value="manual"
/>
<ToggleGroupControlOption
label={ __( 'none' ) }
value="none"
/>
</ToggleGroupControl>
</VStack>
</div>
</>
);
}

export default ScreenTextAlignment;
5 changes: 5 additions & 0 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import ScreenBlock from './screen-block';
import ScreenTypography from './screen-typography';
import ScreenTypographyElement from './screen-typography-element';
import ScreenTextAlignment from './screen-text-alignment';
import ScreenColors from './screen-colors';
import ScreenColorPalette from './screen-color-palette';
import ScreenLayout from './screen-layout';
Expand Down Expand Up @@ -380,6 +381,10 @@ function GlobalStylesUI() {
<ScreenTypographyElement element="button" />
</GlobalStylesNavigationScreen>

<GlobalStylesNavigationScreen path="/text-alignment">
<ScreenTextAlignment />
</GlobalStylesNavigationScreen>

<GlobalStylesNavigationScreen path="/colors">
<ScreenColors />
</GlobalStylesNavigationScreen>
Expand Down