From c647e18af7baca596f1875e66579878c1f9f3e42 Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:52 +0530 Subject: [PATCH] feat: add button style fields to the project form --- .../projects/form/button-style-fields.tsx | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 app/components/projects/form/button-style-fields.tsx diff --git a/app/components/projects/form/button-style-fields.tsx b/app/components/projects/form/button-style-fields.tsx new file mode 100644 index 0000000..8e3cd8c --- /dev/null +++ b/app/components/projects/form/button-style-fields.tsx @@ -0,0 +1,58 @@ +import { useFormContext, useWatch } from 'react-hook-form'; +import { Field } from '~/components/ui/field'; +import { Input } from '~/components/ui/input'; +import { SegmentedControl } from '~/components/ui/segmented-control'; +import { ButtonCustomFields } from '~/components/projects/form/button-custom-fields'; +import { ColorField } from '~/components/projects/form/color-field'; +import { AR_BUTTON_LABEL } from '~/data/ar-viewer/constants'; +import { BRAND_COLORS, BUTTON_LABEL_MAX, BUTTON_SIZE_OPTIONS, BUTTON_SIZES, BUTTON_TEXT_COLORS } from '~/data/projects/constants'; +import type { ProjectFormValues } from '~/schemas/projects/project-form'; +import type { ButtonSize } from '~/types/project'; + +// The client's "View in your space" button: colour, text colour, label and size +export function ButtonStyleFields() { + const { register, control, setValue, formState } = useFormContext(); + const [size, custom] = useWatch({ control, name: ['arPage.buttonSize', 'arPage.buttonCustom'] }); + + // Custom starts from the preset that was selected, so the button doesn't jump + const changeSize = (next: ButtonSize) => { + if (next === 'custom' && size !== 'custom') { + const preset = BUTTON_SIZES[size === 'full' ? 'md' : size]; + setValue('arPage.buttonCustom', { ...custom, height: preset.height, paddingX: preset.paddingX, radius: preset.height / 2, width: null }, { shouldDirty: true }); + } + setValue('arPage.buttonSize', next, { shouldDirty: true }); + }; + + return ( + <> + + + + + + + + + {size === 'custom' && } + + ); +}