Files
siftlode/frontend/src/modules/plex/PlexViewToggle.tsx
T
peter 4ef963b005 refactor(frontend): each page fills the floating header itself; the header knows no page
The header used to pick its pills by `page === …` and import five module controls, and Plex's
Discover/Browse toggle needed a context bridge to reach the sub-view that lives in PlexBrowse.
Now the header is an empty band: PageShell hands its root box out as a slot, a page portals its
own pills into it (PageHeader), and the palette's Jump-to pill shows where no page does
(PageHeaderDefault, rendered inside the page's Suspense so a loading page shows no stand-in).
Plex's toggles take the sub-view as a prop; PlexViewBridge and its context are gone, and with
them the header's five layer suppressions.

No visible change: every header pill's box measured identical against the previous build on eight
pages, in Hungarian and English.
2026-10-23 00:23:38 +02:00

30 lines
1.5 KiB
TypeScript

import { useTranslation } from "react-i18next";
import SegmentedToggle from "../../components/ui/SegmentedToggle";
import type { PlexViewControls } from "./plexSubUrl";
// The Discover ⟷ Browse switch, hosted in the header next to the library-scope pill (All/Movies/Shows).
// It reflects + drives PlexBrowse's top-level sub-view (`view`, from PlexHeader), and hides itself on
// the deeper views (a show/info/person page has no Discover/Browse choice).
export default function PlexViewToggle({ view: ctl }: { view: PlexViewControls }) {
const { t } = useTranslation();
// Only the two title-browse views host the Discover/Browse choice; deeper views (show/info/person/…)
// and the playlists/collections browse surfaces hide it.
if (ctl.kind !== "discover" && ctl.kind !== "grid") return null;
// The floating header wrapper is pointer-events-none (so clicks fall through its empty area to the
// content below); every interactive child must re-enable pointer events or it is click-dead — the
// sibling PlexScopeToggle does the same.
return (
<SegmentedToggle
size="md"
className="pointer-events-auto shrink-0"
ariaLabel={t("plex.view.label")}
options={[
{ value: "discover", label: t("plex.discover.tab") },
{ value: "grid", label: t("plex.view.browse") },
]}
value={ctl.kind === "discover" ? "discover" : "grid"}
onChange={(v) => ctl.open(v === "discover" ? { kind: "discover" } : { kind: "grid" })}
/>
);
}