"use client"; import type { ReactNode } from "react"; import { useRef, useState } from "react"; import { FloatingIndicator, Stack, TextInput, UnstyledButton } from "@mantine/core"; import type { UrlTemplateMode } from "@homarr/definitions"; import { useI18n } from "@homarr/translation/client"; import { useOnboardingSounds } from "./use-onboarding-sounds"; import classes from "./onboarding-studio.module.css"; interface FloatingControlProps { value: T; onChange: (value: T) => void; options: readonly { value: T; label: ReactNode }[]; ariaLabel: string; } export const OnboardingFloatingControl = ({ value, onChange, options, ariaLabel, }: FloatingControlProps) => { const [rootRef, setRootRef] = useState(null); const controlRefs = useRef>({}); const sounds = useOnboardingSounds(); return (
{options.map((option) => { const selected = value === option.value; return ( { controlRefs.current[option.value] = node; }} type="button" className={classes.floatingControl} data-active={selected} aria-pressed={selected} onClick={() => { sounds.click(); onChange(option.value); }} > {option.label} ); })}
); }; interface ServiceUrlTemplateProps { serverOrigin: string; onServerOriginChange: (value: string) => void; mode: UrlTemplateMode; onModeChange: (value: UrlTemplateMode) => void; readOnly?: boolean; required?: boolean; } export const ServiceUrlTemplate = ({ serverOrigin, onServerOriginChange, mode, onModeChange, readOnly, required, }: ServiceUrlTemplateProps) => { const t = useI18n("common.serviceUrlTemplate"); return ( onServerOriginChange(event.currentTarget.value)} readOnly={readOnly} required={required} withAsterisk={required} /> ); };