Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import { useViewportMatch } from '@wordpress/compose';
import {
__experimentalPaletteEdit as PaletteEdit,
__experimentalVStack as VStack,
Button,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { shuffle } from '@wordpress/icons';

/**
* Internal dependencies
*/
import { unlock } from '../../lock-unlock';
import ColorVariations from './variations/variations-color';
import { useColorRandomizer } from './hooks';

const { useGlobalSetting } = unlock( blockEditorPrivateApis );
const mobilePopoverProps = { placement: 'bottom-start', offset: 8 };
Expand Down Expand Up @@ -49,22 +52,37 @@ export default function ColorPalettePanel( { name } ) {
const isMobileViewport = useViewportMatch( 'small', '<' );
const popoverProps = isMobileViewport ? mobilePopoverProps : undefined;

const [ randomizeThemeColors ] = useColorRandomizer();

return (
<VStack
className="edit-site-global-styles-color-palette-panel"
spacing={ 8 }
>
{ !! themeColors && !! themeColors.length && (
<PaletteEdit
canReset={ themeColors !== baseThemeColors }
canOnlyChangeValues
colors={ themeColors }
onChange={ setThemeColors }
paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
<VStack spacing={ 4 }>
{ !! themeColors && !! themeColors.length && (
<PaletteEdit
canReset={ themeColors !== baseThemeColors }
canOnlyChangeValues
colors={ themeColors }
onChange={ setThemeColors }
paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
{ window.__experimentalEnableColorRandomizer &&
themeColors?.length > 0 && (
<Button
__next40pxDefaultSize
variant="secondary"
icon={ shuffle }
onClick={ randomizeThemeColors }
>
{ __( 'Randomize colors' ) }
</Button>
) }
</VStack>
{ !! defaultColors &&
!! defaultColors.length &&
!! defaultPaletteEnabled && (
Expand Down
17 changes: 1 addition & 16 deletions packages/edit-site/src/components/global-styles/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import {
__experimentalZStack as ZStack,
__experimentalVStack as VStack,
ColorIndicator,
Button,
} from '@wordpress/components';
import { isRTL, __ } from '@wordpress/i18n';
import { Icon, shuffle, chevronLeft, chevronRight } from '@wordpress/icons';
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
import { useMemo } from '@wordpress/element';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

Expand All @@ -20,7 +19,6 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
*/
import Subtitle from './subtitle';
import { NavigationButtonAsItem } from './navigation-button';
import { useColorRandomizer } from './hooks';
import ColorIndicatorWrapper from './color-indicator-wrapper';
import { unlock } from '../../lock-unlock';

Expand All @@ -38,8 +36,6 @@ function Palette( { name } ) {
name
);

const [ randomizeThemeColors ] = useColorRandomizer();

const colors = useMemo(
() => [
...( customColors || EMPTY_COLORS ),
Expand Down Expand Up @@ -87,17 +83,6 @@ function Palette( { name } ) {
</HStack>
</NavigationButtonAsItem>
</ItemGroup>
{ window.__experimentalEnableColorRandomizer &&
themeColors?.length > 0 && (
<Button
__next40pxDefaultSize
variant="secondary"
icon={ shuffle }
onClick={ randomizeThemeColors }
>
{ __( 'Randomize colors' ) }
</Button>
) }
</VStack>
);
}
Expand Down
Loading