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 })} /> + + ); +}