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
3 changes: 0 additions & 3 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
function gutenberg_enable_experiments() {
global $pagenow;

if ( gutenberg_is_experiment_enabled( 'gutenberg-color-randomizer' ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableColorRandomizer = true', 'before' );
}
if ( gutenberg_is_experiment_enabled( 'gutenberg-grid-interactivity' ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableGridInteractivity = true', 'before' );
}
Expand Down
5 changes: 0 additions & 5 deletions lib/experimental/experiments/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ function gutenberg_initialize_experiments_settings() {
'slug' => 'other',
'label' => _x( 'Other', 'experiments group name', 'gutenberg' ),
'items' => array(
array(
'id' => 'gutenberg-color-randomizer',
'label' => __( 'Color randomizer', 'gutenberg' ),
'description' => __( 'Enables the Global Styles color randomizer in the Site Editor; a utility that lets you mix the current color palette pseudo-randomly.', 'gutenberg' ),
),
array(
'id' => 'gutenberg-workflow-palette',
'label' => __( 'Workflow Palette', 'gutenberg' ),
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/global-styles-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

### Internal

- Remove the experimental color randomizer from the palette editor, along with the `colord` dependency it used ([#82452](https://github.com/WordPress/gutenberg/pull/82452)).
- Exclude the JavaScript tests and story from the build project so their declarations are not published. ([#81516](https://github.com/WordPress/gutenberg/pull/81516))

## 1.20.0 (2026-08-12)
Expand Down
3 changes: 1 addition & 2 deletions packages/global-styles-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/private-apis": "file:../private-apis",
"@wordpress/ui": "file:../ui",
"clsx": "^2.1.1",
"colord": "^2.9.3"
"clsx": "^2.1.1"
},
"devDependencies": {
"@testing-library/dom": "^10.4.1",
Expand Down
39 changes: 10 additions & 29 deletions packages/global-styles-ui/src/color-palette-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { useViewportMatch } from '@wordpress/compose';
import {
__experimentalPaletteEdit as PaletteEdit,
__experimentalVStack as VStack,
Button,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { shuffle } from '@wordpress/icons';
import { useSetting, useColorRandomizer } from './hooks';
import { useSetting } from './hooks';
import ColorVariations from './variations/variations-color';

const mobilePopoverProps = { placement: 'bottom-start' as const, offset: 8 };
Expand Down Expand Up @@ -48,35 +46,18 @@ export default function ColorPalettePanel( { name }: ColorPalettePanelProps ) {
const isMobileViewport = useViewportMatch( 'small', '<' );
const popoverProps = isMobileViewport ? mobilePopoverProps : undefined;

const [ randomizeThemeColors ] = useColorRandomizer( name );

return (
<VStack className="global-styles-ui-color-palette-panel" spacing={ 8 }>
{ /* Both children need theme colors, so without them the wrapper
renders empty and still takes a slot in the parent's gap. */ }
{ !! themeColors?.length && (
<VStack spacing={ 4 }>
<PaletteEdit
canReset={ themeColors !== baseThemeColors }
canOnlyChangeValues
colors={ themeColors }
onChange={ setThemeColors }
paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
{ ( window as any ).__experimentalEnableColorRandomizer &&
randomizeThemeColors && (
<Button
__next40pxDefaultSize
variant="secondary"
icon={ shuffle }
onClick={ randomizeThemeColors }
>
{ __( 'Randomize colors' ) }
</Button>
) }
</VStack>
<PaletteEdit
canReset={ themeColors !== baseThemeColors }
canOnlyChangeValues
colors={ themeColors }
onChange={ setThemeColors }
paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
{ !! defaultColors &&
!! defaultColors.length &&
Expand Down
45 changes: 0 additions & 45 deletions packages/global-styles-ui/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { colord, extend } from 'colord';
import a11yPlugin from 'colord/plugins/a11y';
import { useCallback, useContext, useMemo } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
Expand All @@ -15,14 +13,10 @@ import {
import type {
GlobalStylesConfig,
StyleVariation,
Color,
} from '@wordpress/global-styles-engine';
import { GlobalStylesContext } from './context';
import { removePropertiesFromObject, isVariationWithProperties } from './utils';

// Enable colord's a11y plugin.
extend( [ a11yPlugin ] );

/**
* Hook to get and set style values with memoization.
*
Expand Down Expand Up @@ -251,45 +245,6 @@ export function useColorVariations(): StyleVariation[] {
);
}

/**
* Hook to randomize theme colors using color rotation.
*
* @param blockName The name of the block, if applicable.
* @return Array containing the randomize function if feature is enabled, empty array otherwise.
*/
export function useColorRandomizer( blockName?: string ): [ () => void ] | [] {
const [ themeColors, setThemeColors ] = useSetting< Color[] >(
'color.palette.theme',
blockName
);

const randomizeColors = useCallback( () => {
if ( ! themeColors || ! themeColors.length ) {
return;
}

const randomRotationValue = Math.floor( Math.random() * 225 );

const newColors = themeColors.map( ( colorObject ) => {
const { color } = colorObject;
const newColor = colord( color )
.rotate( randomRotationValue )
.toHex();

return {
...colorObject,
color: newColor,
};
} );

setThemeColors( newColors );
}, [ themeColors, setThemeColors ] );

return ( window as any ).__experimentalEnableColorRandomizer
? [ randomizeColors ]
: [];
}

/**
* Resolves `ref` pointers and theme-relative (`file:./…`) URLs in a style
* object's `background` sub-tree, for display. The Global Styles screens
Expand Down
Loading