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

Move the global styles reset action to a dropdown menu #35559

Merged
merged 2 commits into from
Oct 13, 2021
Merged
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
42 changes: 24 additions & 18 deletions packages/edit-site/src/components/sidebar/global-styles-sidebar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* WordPress dependencies
*/
import { Button } from '@wordpress/components';
import { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { styles } from '@wordpress/icons';
import { styles, moreVertical } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -12,7 +12,7 @@ import DefaultSidebar from './default-sidebar';
import { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';

export default function GlobalStylesSidebar() {
const [ canRestart, onReset ] = useGlobalStylesReset();
const [ canReset, onReset ] = useGlobalStylesReset();

return (
<DefaultSidebar
Expand All @@ -22,21 +22,27 @@ export default function GlobalStylesSidebar() {
icon={ styles }
closeLabel={ __( 'Close global styles sidebar' ) }
header={
<>
<strong>{ __( 'Styles' ) }</strong>
<span className="edit-site-global-styles-sidebar__beta">
{ __( 'Beta' ) }
</span>
<Button
className="edit-site-global-styles-sidebar__reset-button"
isSmall
variant="tertiary"
disabled={ ! canRestart }
onClick={ onReset }
>
{ __( 'Reset to defaults' ) }
</Button>
</>
<Flex>
<FlexBlock>
<strong>{ __( 'Styles' ) }</strong>
<span className="edit-site-global-styles-sidebar__beta">
{ __( 'Beta' ) }
</span>
</FlexBlock>
<FlexItem>
<DropdownMenu
icon={ moreVertical }
label={ __( 'More Global Styles Actions' ) }
toggleProps={ { disabled: ! canReset } }
controls={ [
{
title: __( 'Reset to defaults' ),
onClick: onReset,
},
] }
/>
</FlexItem>
</Flex>
}
>
<GlobalStylesUI />
Expand Down