From 48b609b3972087a63d72a18ccdd8a9ea46469160 Mon Sep 17 00:00:00 2001 From: Juan Aldasoro Date: Tue, 19 Nov 2024 15:18:48 +0100 Subject: [PATCH 1/8] Add reset button to color control --- .../components/colors-gradients/style.scss | 20 +++++++++++++ .../components/global-styles/color-panel.js | 28 +++++++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/colors-gradients/style.scss b/packages/block-editor/src/components/colors-gradients/style.scss index fc1b1a4d469033..44281b31d5eddc 100644 --- a/packages/block-editor/src/components/colors-gradients/style.scss +++ b/packages/block-editor/src/components/colors-gradients/style.scss @@ -64,6 +64,7 @@ $swatch-gap: 12px; .block-editor-tools-panel-color-gradient-settings__item { padding: 0; max-width: 100%; + position: relative; // Border styles. border-left: 1px solid $gray-300; @@ -120,3 +121,22 @@ $swatch-gap: 12px; flex-shrink: 0; } } + +.block-editor-panel-color-gradient-settings__reset { + position: absolute; + display: inline-flex; + right: 0; + top: 0; + bottom: 0; + opacity: 0; + transition: opacity 0.1s ease-in-out; + + .block-editor-panel-color-gradient-settings__dropdown:hover + & { + opacity: 1; + } + + &:focus, + &:hover { + opacity: 1; + } +} diff --git a/packages/block-editor/src/components/global-styles/color-panel.js b/packages/block-editor/src/components/global-styles/color-panel.js index 7c5257ae93bfaa..129f2d79be4a5c 100644 --- a/packages/block-editor/src/components/global-styles/color-panel.js +++ b/packages/block-editor/src/components/global-styles/color-panel.js @@ -30,6 +30,7 @@ import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks'; import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils'; import { setImmutably } from '../../utils/object'; import { unlock } from '../../lock-unlock'; +import { reset as resetIcon } from '@wordpress/icons'; export function useHasColorPanel( settings ) { const hasTextPanel = useHasTextPanel( settings ); @@ -231,12 +232,27 @@ function ColorPanelDropdown( { }; return ( - + <> + + { hasValue() && ( +