diff --git a/packages/block-editor/src/components/colors-gradients/style.scss b/packages/block-editor/src/components/colors-gradients/style.scss index fc1b1a4d469033..222a5b239cf992 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,23 @@ $swatch-gap: 12px; flex-shrink: 0; } } + +.block-editor-panel-color-gradient-settings__reset { + position: absolute; + right: 0; + top: $grid-unit; + margin: auto $grid-unit auto; + opacity: 0; + transition: opacity 0.1s ease-in-out; + @include reduce-motion("transition"); + + &.block-editor-panel-color-gradient-settings__reset { + border-radius: $radius-small; + } + + .block-editor-panel-color-gradient-settings__dropdown:hover + &, + &: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..f1a1834967ed92 100644 --- a/packages/block-editor/src/components/global-styles/color-panel.js +++ b/packages/block-editor/src/components/global-styles/color-panel.js @@ -19,7 +19,7 @@ import { Button, privateApis as componentsPrivateApis, } from '@wordpress/components'; -import { useCallback } from '@wordpress/element'; +import { useCallback, useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; /** @@ -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 ); @@ -208,6 +209,7 @@ function ColorPanelDropdown( { } ) { const currentTab = tabs.find( ( tab ) => tab.userValue !== undefined ); const { key: firstTabKey, ...firstTab } = tabs[ 0 ] ?? {}; + const colorGradientDropdownButtonRef = useRef( undefined ); return ( - - + <> + + { hasValue() && ( +