Both players get a scissors in their control row (Plex: the control row; YouTube: the actions and the docked bar), `c`, and `[` / `]` to mark at the playhead. The clip panel lives in the player, so the watched video is the preview: an overview of the whole item and a zoomed strip around the selection whose ends are sliders (arrows step a tenth, Shift a second), Start / End fields with nudges and "to the playhead", the length, a looping Play selection, a name, Cut. Escape closes the panel before the player and the focus goes back to the scissors. A cut is a toast with a Downloads link plus the usual Ready notification. - ui/RangeTrack + RulerTicks: the shared, domain-free time track (regions, keyboard-steppable handles with a 1.5rem hit area, a playhead, a background slot, over a window of the item). The Downloads editor's cuts moved onto it, so they are keyboard-steppable now. - lib/clipRange holds the marking rules (1 s to 10 min, the server's), lib/timecode the editing timecode the editor's private tc/parseTc became. - keymap: a symbol typed through AltGr answers its bare-symbol row - on the HU layout `[` is AltGr+F, which arrives as Ctrl+Alt; letter and Mod rows still never match Ctrl+Alt. - The YouTube stage sits in a wrapper with the panel, so the maximised stage's blur escape matches at any depth. - media-scope: fields on the always-dark player chrome read white in a light theme too.
138 lines
4.0 KiB
TypeScript
138 lines
4.0 KiB
TypeScript
import { type ReactNode, type Ref } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { RotateCcw } from "lucide-react";
|
|
import { IconButton } from "./ui/IconButton";
|
|
import { Slider as Range, CheckRow } from "./ui/NativeControls";
|
|
import { formatDecimal, formatUnit } from "../lib/format";
|
|
|
|
// --- 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,
|
|
seconds,
|
|
onChange,
|
|
onReset,
|
|
}: {
|
|
label: string;
|
|
value: number;
|
|
min: number;
|
|
max: number;
|
|
step: number;
|
|
/** A symbol after the number ("%", "px"). */
|
|
suffix?: string;
|
|
/** The value is seconds: named in the UI language's unit ("0.5 sec" / "0,5 mp"). */
|
|
seconds?: boolean;
|
|
onChange: (v: number) => void;
|
|
onReset?: () => void;
|
|
}) {
|
|
const { t, i18n } = useTranslation();
|
|
const lang = i18n.language;
|
|
const shown = seconds
|
|
? formatUnit(value, "second", lang)
|
|
: `${formatDecimal(value, lang, 1, 0)}${suffix ?? ""}`;
|
|
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">{shown}</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}
|
|
aria-label={label}
|
|
onChange={(v) => onChange(v)}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
export function Toggle({
|
|
label,
|
|
checked,
|
|
onChange,
|
|
}: {
|
|
label: string;
|
|
checked: boolean;
|
|
onChange: (v: boolean) => void;
|
|
}) {
|
|
// The whole row toggles and grows to 44 on touch (CheckRow); the box sits at the row's end.
|
|
return (
|
|
<CheckRow
|
|
checked={checked}
|
|
onChange={onChange}
|
|
className="w-full flex-row-reverse justify-between px-1 py-1.5 text-[0.75rem] text-white/80"
|
|
>
|
|
{label}
|
|
</CheckRow>
|
|
);
|
|
}
|
|
|
|
// 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",
|
|
buttonRef,
|
|
children,
|
|
}: {
|
|
label: string;
|
|
onClick: () => void;
|
|
disabled?: boolean;
|
|
buttonRef?: Ref<HTMLButtonElement>;
|
|
// 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 (seen by the owner).
|
|
return (
|
|
<div className="relative flex group/ctrl">
|
|
<IconButton
|
|
ref={buttonRef}
|
|
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>
|
|
);
|
|
}
|