diff --git a/src-web/components/EnvironmentActionsDropdown.tsx b/src-web/components/EnvironmentActionsDropdown.tsx index 83ed080a..200d6033 100644 --- a/src-web/components/EnvironmentActionsDropdown.tsx +++ b/src-web/components/EnvironmentActionsDropdown.tsx @@ -9,7 +9,7 @@ import type { ButtonProps } from './core/Button'; import type { DropdownItem } from './core/Dropdown'; import { Dropdown } from './core/Dropdown'; import { Icon } from './core/Icon'; -import { EnvironmentColorCircle } from './EnvironmentColorCircle'; +import { EnvironmentColorIndicator } from './EnvironmentColorIndicator'; import { EnvironmentEditDialog } from './EnvironmentEditDialog'; type Props = { @@ -39,7 +39,7 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo (e) => ({ key: e.id, label: e.name, - rightSlot: , + rightSlot: , leftSlot: e.id === activeEnvironment?.id ? : , onSelect: async () => { if (e.id !== activeEnvironment?.id) { @@ -82,7 +82,7 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo onClick={subEnvironments.length === 0 ? showEnvironmentDialog : undefined} {...buttonProps} > - + {activeEnvironment?.name ?? (hasBaseVars ? 'Environment' : 'No Environment')} diff --git a/src-web/components/EnvironmentColorCircle.tsx b/src-web/components/EnvironmentColorIndicator.tsx similarity index 94% rename from src-web/components/EnvironmentColorCircle.tsx rename to src-web/components/EnvironmentColorIndicator.tsx index e9f0c7b2..768e02ce 100644 --- a/src-web/components/EnvironmentColorCircle.tsx +++ b/src-web/components/EnvironmentColorIndicator.tsx @@ -2,7 +2,7 @@ import type { Environment } from '@yaakapp-internal/models'; import classNames from 'classnames'; import { showColorPicker } from '../lib/showColorPicker'; -export function EnvironmentColorCircle({ +export function EnvironmentColorIndicator({ environment, clickToEdit, }: { diff --git a/src-web/components/EnvironmentColorPicker.tsx b/src-web/components/EnvironmentColorPicker.tsx index e7c47643..b3c158a3 100644 --- a/src-web/components/EnvironmentColorPicker.tsx +++ b/src-web/components/EnvironmentColorPicker.tsx @@ -11,16 +11,22 @@ export function EnvironmentColorPicker({ }) { const [color, setColor] = useState(defaultColor); return ( -
+
{ + e.preventDefault(); + onChange(color); + }} + >
-
-
+ ); } diff --git a/src-web/components/EnvironmentEditDialog.tsx b/src-web/components/EnvironmentEditDialog.tsx index a6d7575e..c2987d17 100644 --- a/src-web/components/EnvironmentEditDialog.tsx +++ b/src-web/components/EnvironmentEditDialog.tsx @@ -36,7 +36,7 @@ import { PairOrBulkEditor } from './core/PairOrBulkEditor'; import { Separator } from './core/Separator'; import { SplitLayout } from './core/SplitLayout'; import { VStack } from './core/Stacks'; -import { EnvironmentColorCircle } from './EnvironmentColorCircle'; +import { EnvironmentColorIndicator } from './EnvironmentColorIndicator'; interface Props { initialEnvironment: Environment | null; @@ -239,7 +239,7 @@ const EnvironmentEditor = function ({ return ( - +
{selectedEnvironment?.name}
{isEncryptionEnabled ? ( promptToEncrypt ? ( @@ -347,7 +347,7 @@ function SidebarButton({ onContextMenu={handleContextMenu} rightSlot={rightSlot} > - + {children} {outerRightSlot} @@ -390,7 +390,7 @@ function SidebarButton({ ] : []) as DropdownItem[]), { - label: 'Set Color', + label: environment.color ? 'Change Color' : 'Assign Color', leftSlot: , hidden: environment.base, onSelect: async () => showColorPicker(environment), diff --git a/src-web/components/core/ColorPicker.tsx b/src-web/components/core/ColorPicker.tsx index 7fb0e9f2..441b4316 100644 --- a/src-web/components/core/ColorPicker.tsx +++ b/src-web/components/core/ColorPicker.tsx @@ -1,4 +1,3 @@ -import { useState } from 'react'; import { HexColorPicker } from 'react-colorful'; import { useRandomKey } from '../../hooks/useRandomKey'; import { PlainInput } from './PlainInput'; @@ -8,23 +7,16 @@ interface Props { color: string | null; } -export function ColorPicker({ onChange, color: defaultColor }: Props) { +export function ColorPicker({ onChange, color }: Props) { const [updateKey, regenerateKey] = useRandomKey(); - const [color, setColor] = useState(defaultColor); return ( -
{ - e.preventDefault(); - onChange(color); - }} - > +
{ - setColor(color.toUpperCase()); - regenerateKey(); + onChange(color); + regenerateKey(); // To force input to change }} /> setColor(c.toUpperCase())} + onChange={onChange} validate={(color) => color.match(/#[0-9a-fA-F]{6}$/) !== null} /> - +
); }