import { FloatingCardView } from "@/components/popout/FloatingCard"; import { FloatingView } from "@/components/popout/FloatingView"; import { useFloatingRouter } from "@/hooks/useFloatingRouter"; import { useSettings } from "@/state/settings"; import { useTranslation } from "react-i18next"; import { ChangeEventHandler, useEffect, useRef } from "react"; import { Icon, Icons } from "@/components/Icon"; export type SliderProps = { label: string; min: number; max: number; step: number; value: number; valueDisplay?: string; onChange: ChangeEventHandler; }; export function Slider(props: SliderProps) { const ref = useRef(null); useEffect(() => { const e = ref.current as HTMLInputElement; e.style.setProperty("--value", e.value); e.style.setProperty("--min", e.min === "" ? "0" : e.min); e.style.setProperty("--max", e.max === "" ? "100" : e.max); e.addEventListener("input", () => e.style.setProperty("--value", e.value)); }, [ref]); return (
{props.valueDisplay ?? props.value}
); } export function CaptionSettingsPopout(props: { router: ReturnType; prefix: string; }) { // For now, won't add label texts to language files since options are prone to change const { t } = useTranslation(); const { captionSettings, setCaptionBackgroundColor, setCaptionColor, setCaptionDelay, setCaptionFontSize, } = useSettings(); const colors = ["#ffffff", "#00ffff", "#ffff00"]; return ( props.router.navigate("/captions")} /> setCaptionDelay(e.target.valueAsNumber)} /> setCaptionFontSize(e.target.valueAsNumber)} /> setCaptionBackgroundColor( `${captionSettings.style.backgroundColor.substring( 0, 7 )}${e.target.valueAsNumber.toString(16)}` ) } />
{colors.map((color) => (
setCaptionColor(color)} >
))}
); }