From 480a39169e069cf9d1acde69ff733616136140f8 Mon Sep 17 00:00:00 2001 From: Jonas Carlsen Date: Tue, 8 Oct 2024 14:24:23 +0200 Subject: [PATCH] refactor: remove remaining RadioButtonGroup from ndla/forms --- .../components/ImageMetaData.tsx | 74 ++++++++++--------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/containers/ImageUploader/components/ImageMetaData.tsx b/src/containers/ImageUploader/components/ImageMetaData.tsx index ab4216c7c7..25aec10626 100644 --- a/src/containers/ImageUploader/components/ImageMetaData.tsx +++ b/src/containers/ImageUploader/components/ImageMetaData.tsx @@ -6,13 +6,22 @@ * */ -import { FieldInputProps, FieldProps } from "formik"; +import { FieldProps } from "formik"; import { useTranslation } from "react-i18next"; -import { Label, Legend, RadioButtonGroup, RadioButtonItem } from "@ndla/forms"; +import { + FieldRoot, + RadioGroupItem, + RadioGroupItemControl, + RadioGroupItemHiddenInput, + RadioGroupItemText, + RadioGroupLabel, + RadioGroupRoot, +} from "@ndla/primitives"; +import { styled } from "@ndla/styled-system/jsx"; import AsyncSearchTags from "../../../components/Dropdown/asyncDropdown/AsyncSearchTags"; -import { RadioButtonWrapper, FieldsetRow, StyledFormControl } from "../../../components/Form/styles"; import { FormField } from "../../../components/FormField"; import FormikField from "../../../components/FormikField"; +import { FormContent } from "../../../components/FormikForm"; import { fetchSearchTags } from "../../../modules/image/imageApi"; interface Props { @@ -20,10 +29,21 @@ interface Props { imageLanguage?: string; } +const RadioGroupItemWrapper = styled("div", { + base: { + display: "flex", + gap: "xsmall", + flexWrap: "wrap", + }, +}); + +const options = ["yes", "not-applicable", "no", "not-set"]; +const defaultValue = "not-set"; + const ImageMetaData = ({ imageTags, imageLanguage }: Props) => { const { t } = useTranslation(); return ( - <> + {({ field, form }: FieldProps) => ( { )} - {({ field }: { field: FieldInputProps }) => { - const options = ["yes", "not-applicable", "no", "not-set"]; - const defaultValue = "not-set"; + {({ field, helpers }) => { return ( - - - field.onChange({ - target: { - name: field.name, - value: value, - }, - }) - } - orientation="horizontal" - defaultValue={field.value ?? defaultValue} - asChild + + helpers.setValue(details.value)} > - - - {t("form.modelReleased.description")} - + {t("form.modelReleased.description")} + {options.map((option) => ( - - - - + + + {t(`form.modelReleased.${option}`)} + + ))} - - - + + + ); }} - + ); };