Files
siftlode/frontend/src/components/plexPlayerControls.tsx
T
peter 89e65ca331 feat(design): players on touch and the C5 control set, restart on the card (E28 S3f2)
Plex player: a finger's tap on the picture only shows or hides the controls,
the hide timer starts with playback, a double-tap on a side third skips 10 s,
the seek bar is a 2.75rem touch-none hit area with its head shown on touch.
The row is play/pause, Back by position, Next only with a next item, mute,
time, tracks, a fixed ⋯ (settings, media info, stats, shortcuts, download)
and fullscreen; Stop, Restart and the ±10 s buttons are gone.

A started card shows the video card's Continue + Restart pair (one shared
MediaResumeButtons, beside the picture's button), and its menu lists the
restart; the player opens that item at 0 (fromStart). YouTube modal: the
description opens from an ⓘ, the queue arrows sit inside the screen.
2026-09-27 02:12:54 +02:00

118 lines
3.5 KiB
TypeScript

import { type ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { RotateCcw } from "lucide-react";
import { IconButton } from "./ui/IconButton";
import { Slider as Range, Checkbox } from "./ui/NativeControls";
// --- settings-panel building blocks ------------------------------------------------------------
export function PanelHead({ children }: { children: ReactNode }) {
return (
<div className="px-1 pt-2 pb-1 text-2xs uppercase tracking-wide text-white/50">{children}</div>
);
}
export function Slider({
label,
value,
min,
max,
step,
suffix,
onChange,
onReset,
}: {
label: string;
value: number;
min: number;
max: number;
step: number;
suffix?: string;
onChange: (v: number) => void;
onReset?: () => void;
}) {
const { t } = useTranslation();
return (
<div className="px-1 py-1">
<div className="mb-1 flex items-center justify-between text-[0.75rem] text-white/80">
<span>{label}</span>
<span className="flex items-center gap-1.5">
<span className="tabular-nums text-white/60">
{Number.isInteger(value) ? value : value.toFixed(1)}
{suffix ?? ""}
</span>
{onReset && (
<IconButton
variant="overlay"
onClick={onReset}
label={t("common.resetNamed", { name: label })}
className="-my-1.5"
>
<RotateCcw className="size-3.5!" />
</IconButton>
)}
</span>
</div>
<Range min={min} max={max} step={step} value={value} onChange={(v) => onChange(v)} />
</div>
);
}
export function Toggle({
label,
checked,
onChange,
}: {
label: string;
checked: boolean;
onChange: (v: boolean) => void;
}) {
return (
<label className="flex cursor-pointer items-center justify-between px-1 py-1.5">
<span className="text-[0.75rem] text-white/80">{label}</span>
<Checkbox checked={checked} onChange={onChange} />
</label>
);
}
// A control button with a tooltip that opens ABOVE it (so it never clips off the bottom of the
// viewport, unlike a native title tooltip on the bottom control bar).
export function Ctrl({
label,
onClick,
disabled,
align = "center",
children,
}: {
label: string;
onClick: () => void;
disabled?: boolean;
// Tooltip horizontal anchor: "start"/"end" for edge buttons so it doesn't clip off the viewport.
align?: "start" | "center" | "end";
children: ReactNode;
}) {
const pos =
align === "start" ? "left-0" : align === "end" ? "right-0" : "left-1/2 -translate-x-1/2";
// `will-change-[opacity]` keeps each tooltip on its own compositor layer from the start. Without it
// the browser promotes a tooltip only while its fade runs, and inside the player's scale(1.25)
// the neighbouring glyphs got re-layered with it: every button in the row shimmered as the
// pointer crossed one (owner, E28 audit).
return (
<div className="relative flex group/ctrl">
<IconButton
variant="overlay"
size="player"
round
noTitle
onClick={onClick}
disabled={disabled}
label={label}
>
{children}
</IconButton>
<span
className={`pointer-events-none absolute bottom-full ${pos} mb-2 whitespace-nowrap rounded-sm bg-black/90 px-2 py-1 text-2xs text-white opacity-0 will-change-[opacity] transition group-hover/ctrl:opacity-100`}
>
{label}
</span>
</div>
);
}