From 8703121fd18f2581a24473b4c7bce6ec53579bc3 Mon Sep 17 00:00:00 2001 From: Jason Crist Date: Wed, 9 Nov 2022 12:07:14 -0700 Subject: [PATCH] Eliminate 'isEditing' flag for PaletteEdit component so that when color paletts are being edited they are always 'editable' --- packages/components/src/palette-edit/index.js | 184 ++++++------------ 1 file changed, 62 insertions(+), 122 deletions(-) diff --git a/packages/components/src/palette-edit/index.js b/packages/components/src/palette-edit/index.js index 0b52d309c03fa7..8a9dd77c495eec 100644 --- a/packages/components/src/palette-edit/index.js +++ b/packages/components/src/palette-edit/index.js @@ -23,8 +23,6 @@ import { FlexItem } from '../flex'; import { HStack } from '../h-stack'; import { ItemGroup } from '../item-group'; import { VStack } from '../v-stack'; -import GradientPicker from '../gradient-picker'; -import ColorPalette from '../color-palette'; import DropdownMenu from '../dropdown-menu'; import Popover from '../popover'; import { @@ -36,7 +34,6 @@ import { PaletteItem, NameContainer, NameInputControl, - DoneButton, RemoveButton, } from './styles'; import { NavigableMenu } from '../navigable-container'; @@ -304,10 +301,8 @@ export default function PaletteEdit( { } ) { const isGradient = !! gradients; const elements = isGradient ? gradients : colors; - const [ isEditing, setIsEditing ] = useState( false ); const [ editingElement, setEditingElement ] = useState( null ); const isAdding = - isEditing && editingElement && elements[ editingElement ] && ! elements[ editingElement ].slug; @@ -319,17 +314,6 @@ export default function PaletteEdit( { { paletteLabel } - { hasElements && isEditing && ( - { - setIsEditing( false ); - setEditingElement( null ); - } } - > - { __( 'Done' ) } - - ) } { ! canOnlyChangeValues && ( - ) } - { ! canOnlyChangeValues && ( - - ) } - { canReset && ( - - ) } - - - ) } - - ) } + { hasElements && ( ! canOnlyChangeValues || canReset ) && ( + + { ( { onClose } ) => ( + <> + + { ! canOnlyChangeValues && ( + + ) } + { canReset && ( + + ) } + + + ) } + + ) } { hasElements && ( - <> - { isEditing && ( - - ) } - { ! isEditing && - ( isGradient ? ( - {} } - clearable={ false } - disableCustomGradients={ true } - /> - ) : ( - {} } - clearable={ false } - disableCustomColors={ true } - /> - ) ) } - + ) } { ! hasElements && emptyMessage }