Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
improvement: add v3 color picker and update brand color selection
Scott Wilsonab89b63cb3ab
diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex a981676478..f2281b5b37 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -99,6 +99,7 @@"randexp": "^0.5.3","react": "^18.3.1","react-code-input": "^3.10.1",+ "react-colorful": "^5.6.1","react-complex-tree": "^2.6.1","react-day-picker": "^9.13.0","react-dom": "^18.3.1",@@ -15316,6 +15317,16 @@"object-assign": "^4.1.1"}},+ "node_modules/react-colorful": {+ "version": "5.6.1",+ "resolved": "https://registry.npmjs.org/react-colorful/-/react-colorful-5.6.1.tgz",+ "integrity": "sha512-1exovf0uGTGyq5mXQT0zgQ80uvj2PCwvF8zY1RN9/vbJVSjSo3fsB/4L3ObbF7u70NduSiK4xu4Y6q1MHoUGEw==",+ "license": "MIT",+ "peerDependencies": {+ "react": ">=16.8.0",+ "react-dom": ">=16.8.0"+ }+ },"node_modules/react-complex-tree": {"version": "2.6.1","resolved": "https://registry.npmjs.org/react-complex-tree/-/react-complex-tree-2.6.1.tgz",diff --git a/frontend/package.json b/frontend/package.jsonindex 6c0f98a6fc..5f81e53b9a 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -127,6 +127,7 @@"randexp": "^0.5.3","react": "^18.3.1","react-code-input": "^3.10.1",+ "react-colorful": "^5.6.1","react-complex-tree": "^2.6.1","react-day-picker": "^9.13.0","react-dom": "^18.3.1",diff --git a/frontend/src/components/v3/generic/ColorPicker/ColorPicker.css b/frontend/src/components/v3/generic/ColorPicker/ColorPicker.cssnew file mode 100644index 0000000000..2544dad090--- /dev/null+++ b/frontend/src/components/v3/generic/ColorPicker/ColorPicker.css@@ -0,0 +1,22 @@+.react-colorful {+ height: 160px !important;+ gap: 8px;+}++.react-colorful__saturation {+ border-radius: 6px !important;+ border: 1px solid var(--color-border) !important;+}++.react-colorful__hue {+ height: 10px !important;+ border-radius: 5px !important;+}++.react-colorful__saturation-pointer,+.react-colorful__hue-pointer {+ width: 16px !important;+ height: 16px !important;+ border: 2px solid white !important;+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2) !important;+}diff --git a/frontend/src/components/v3/generic/ColorPicker/ColorPicker.tsx b/frontend/src/components/v3/generic/ColorPicker/ColorPicker.tsxnew file mode 100644index 0000000000..0d04bdcccd--- /dev/null+++ b/frontend/src/components/v3/generic/ColorPicker/ColorPicker.tsx@@ -0,0 +1,89 @@+import { forwardRef, useCallback, useEffect, useState } from "react";+import { HexColorPicker } from "react-colorful";++import { cn } from "../../utils";+import { Input } from "../Input";+import { Popover, PopoverContent, PopoverTrigger } from "../Popover";++import "./ColorPicker.css";++type ColorPickerProps = {+ value?: string;+ onChange?: (color: string) => void;+ disabled?: boolean;+ placeholder?: string;+ isError?: boolean;+ className?: string;+};++const ColorPicker = forwardRef<HTMLInputElement, ColorPickerProps>(+ ({ value = "", onChange, disabled, placeholder = "#000000", isError, className }, ref) => {+ const [localColor, setLocalColor] = useState(value);++ useEffect(() => {+ setLocalColor(value);+ }, [value]);++ const handlePickerChange = useCallback(+ (color: string) => {+ setLocalColor(color);+ onChange?.(color);+ },+ [onChange]+ );++ const handleInputChange = useCallback(+ (e: React.ChangeEvent<HTMLInputElement>) => {+ const newValue = e.target.value;+ setLocalColor(newValue);+ onChange?.(newValue);+ },+ [onChange]+ );++ const isValidHex = /^#[0-9A-Fa-f]{6}$/.test(localColor);++ return (+ <div className={cn("flex items-center gap-2", className)}>+ <Input+ ref={ref}+ value={localColor}+ onChange={handleInputChange}+ placeholder={placeholder}+ disabled={disabled}+ isError={isError}+ className="flex-1 font-mono"+ />+ <Popover>+ <PopoverTrigger asChild disabled={disabled}>+ <button+ type="button"+ className={cn(+ "size-9 shrink-0 cursor-pointer rounded-md border border-border shadow-xs transition-colors",+ "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",+ "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",+ !isValidHex && "bg-container"+ )}+ style={{+ backgroundColor: isValidHex ? localColor : undefined+ }}+ disabled={disabled}+ aria-label="Pick a color"+ />+ </PopoverTrigger>+ <PopoverContent className="w-[220px] p-3" align="end">+ <HexColorPicker+ color={isValidHex ? localColor : "#000000"}+ onChange={handlePickerChange}+ className="!w-full"+ />+ </PopoverContent>+ </Popover>+ </div>+ );+ }+);++ColorPicker.displayName = "ColorPicker";++export { ColorPicker };diff --git a/frontend/src/components/v3/generic/ColorPicker/index.ts b/frontend/src/components/v3/generic/ColorPicker/index.tsnew file mode 100644index 0000000000..999e14d70a--- /dev/null+++ b/frontend/src/components/v3/generic/ColorPicker/index.ts@@ -0,0 +1 @@+export * from "./ColorPicker";diff --git a/frontend/src/components/v3/generic/index.ts b/frontend/src/components/v3/generic/index.tsindex 34e5e445cb..56819c8556 100644--- a/frontend/src/components/v3/generic/index.ts+++ b/frontend/src/components/v3/generic/index.ts@@ -7,6 +7,7 @@ export * from "./Button";export * from "./ButtonGroup";export * from "./Calendar";export * from "./Card";+export * from "./ColorPicker";export * from "./Checkbox";export * from "./Command";export * from "./DataGrid";diff --git a/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsx b/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsxindex 0477ef4d65..bcf7d86213 100644--- a/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsx+++ b/frontend/src/pages/organization/SecretSharingPage/components/SecretSharingSettings/SecretSharingBrandingSection.tsx@@ -1,7 +1,7 @@import { useEffect, useRef, useState } from "react";import { Controller, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { LockIcon, Trash2, UploadIcon } from "lucide-react";+import { InfoIcon, LockIcon, Trash2, UploadIcon } from "lucide-react";import { z } from "zod";import { createNotification } from "@app/components/notifications";@@ -23,10 +23,10 @@ import {CardDescription,CardHeader,CardTitle,+ ColorPicker,Field,FieldError,FieldLabel,- Input,Skeleton,Tooltip,TooltipContent,@@ -375,31 +375,20 @@ export const SecretSharingBrandingSection = () => {Primary Color<Tooltip><TooltipTrigger asChild>- <span className="cursor-help text-muted">?</span>+ <InfoIcon className="text-muted" /></TooltipTrigger><TooltipContent className="max-w-xs">Background color for the page (hex format, e.g., #82cec0)</TooltipContent></Tooltip></FieldLabel>- <div className="flex items-center gap-2">- <Input- {...field}- placeholder="#0e1014"- disabled={!isAllowed}- className="flex-1"- isError={Boolean(error)}- />- <div- className="size-9 shrink-0 rounded border border-border"- style={{- backgroundColor:- field.value && hexColorRegex.test(field.value)- ? field.value- : "#0e1014"- }}- />- </div>+ <ColorPicker+ value={field.value}+ onChange={field.onChange}+ placeholder="#0e1014"+ disabled={!isAllowed}+ isError={Boolean(error)}+ />{error && <FieldError>{error.message}</FieldError>}</Field>)}@@ -413,31 +402,20 @@ export const SecretSharingBrandingSection = () => {Secondary Color<Tooltip><TooltipTrigger asChild>- <span className="cursor-help text-muted">?</span>+ <InfoIcon className="text-muted" /></TooltipTrigger><TooltipContent className="max-w-xs">Panel and component background color (hex format, e.g., #14211e)</TooltipContent></Tooltip></FieldLabel>- <div className="flex items-center gap-2">- <Input- {...field}- placeholder="#1e1f22"- disabled={!isAllowed}- className="flex-1"- isError={Boolean(error)}- />- <div- className="size-9 shrink-0 rounded border border-border"- style={{- backgroundColor:- field.value && hexColorRegex.test(field.value)- ? field.value- : "#1e1f22"- }}- />- </div>+ <ColorPicker+ value={field.value}+ onChange={field.onChange}+ placeholder="#1e1f22"+ disabled={!isAllowed}+ isError={Boolean(error)}+ />{error && <FieldError>{error.message}</FieldError>}</Field>)}