From 46ba48402e248bd8c9a5902477e099db14248f66 Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:52 +0530 Subject: [PATCH] feat: add project colour field --- app/components/projects/form/color-field.tsx | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/components/projects/form/color-field.tsx diff --git a/app/components/projects/form/color-field.tsx b/app/components/projects/form/color-field.tsx new file mode 100644 index 0000000..37d2ab8 --- /dev/null +++ b/app/components/projects/form/color-field.tsx @@ -0,0 +1,24 @@ +import { useFormContext, useWatch } from 'react-hook-form'; +import { ColorPicker } from '~/components/ui/color-picker'; +import { Field } from '~/components/ui/field'; +import type { ProjectFormValues } from '~/schemas/projects/project-form'; +import type { ColorPreset } from '~/types/project'; + +interface ColorFieldProps { + name: 'brandColor' | 'buttonTextColor'; + label: string; + presets: ColorPreset[]; +} + +// A project form colour bound straight to one form value +export function ColorField({ name, label, presets }: ColorFieldProps) { + const { control, setValue, formState } = useFormContext(); + const value = useWatch({ control, name }); + const id = `project-${name}`; + + return ( + + setValue(name, hex, { shouldDirty: true })} /> + + ); +}