diff --git a/app/features/sendouq-settings/components/PreferenceRadioGroup.tsx b/app/features/sendouq-settings/components/PreferenceRadioGroup.tsx new file mode 100644 index 000000000..8430c17c2 --- /dev/null +++ b/app/features/sendouq-settings/components/PreferenceRadioGroup.tsx @@ -0,0 +1,87 @@ +import clsx from "clsx"; +import { Radio, RadioGroup } from "react-aria-components"; +import { useTranslation } from "react-i18next"; +import type { Preference } from "~/db/tables"; +import { preferenceEmojiUrl } from "~/utils/urls"; + +export function PreferenceRadioGroup({ + preference, + onPreferenceChange, + "aria-label": ariaLabel, +}: { + preference?: Preference; + onPreferenceChange: (preference: Preference & "NEUTRAL") => void; + "aria-label": string; +}) { + const { t } = useTranslation(["q"]); + + return ( + + onPreferenceChange(newPreference as Preference & "NEUTRAL") + } + className="stack horizontal xs" + aria-label={ariaLabel} + orientation="horizontal" + > + + {({ isSelected, isHovered, isFocusVisible }) => ( + + Avoid emoji + {t("q:settings.maps.avoid")} + + )} + + + {({ isSelected, isHovered, isFocusVisible }) => ( + + Neutral emoji + {t("q:settings.maps.neutral")} + + )} + + + {({ isSelected, isHovered, isFocusVisible }) => ( + + Prefer emoji + {t("q:settings.maps.prefer")} + + )} + + + ); +} diff --git a/app/features/sendouq-settings/routes/q.settings.tsx b/app/features/sendouq-settings/routes/q.settings.tsx index 64d13fbe2..8ab812338 100644 --- a/app/features/sendouq-settings/routes/q.settings.tsx +++ b/app/features/sendouq-settings/routes/q.settings.tsx @@ -1,11 +1,9 @@ -import { RadioGroup } from "@headlessui/react"; import type { ActionFunctionArgs, LoaderFunctionArgs, MetaFunction, } from "@remix-run/node"; import { useFetcher, useLoaderData } from "@remix-run/react"; -import clsx from "clsx"; import * as React from "react"; import { useState } from "react"; import { useTranslation } from "react-i18next"; @@ -45,7 +43,6 @@ import { SENDOUQ_PAGE, SENDOUQ_SETTINGS_PAGE, navIconUrl, - preferenceEmojiUrl, soundPath, } from "~/utils/urls"; import { BANNED_MAPS } from "../banned-maps"; @@ -58,6 +55,7 @@ import { settingsActionSchema } from "../q-settings-schemas.server"; import "../q-settings.css"; import { SendouSwitch } from "~/components/elements/Switch"; import { metaTags } from "~/utils/remix"; +import { PreferenceRadioGroup } from "../components/PreferenceRadioGroup"; export const handle: SendouRouteHandle = { i18n: ["q"], @@ -262,6 +260,7 @@ function MapPicker() { preference, }) } + aria-label={`Select preference towards ${modeShort}`} /> ); @@ -321,78 +320,6 @@ function MapPicker() { ); } -function PreferenceRadioGroup({ - preference, - onPreferenceChange, -}: { - preference?: Preference; - onPreferenceChange: (preference: Preference & "NEUTRAL") => void; -}) { - const { t } = useTranslation(["q"]); - - return ( - - onPreferenceChange(newPreference as Preference & "NEUTRAL") - } - className="stack horizontal xs" - > - - {({ checked }) => ( - - Avoid emoji - {t("q:settings.maps.avoid")} - - )} - - - {({ checked }) => ( - - Neutral emoji - {t("q:settings.maps.neutral")} - - )} - - - {({ checked }) => ( - - Prefer emoji - {t("q:settings.maps.prefer")} - - )} - - - ); -} - function VoiceChat() { const { t } = useTranslation(["common", "q"]); const fetcher = useFetcher();