Create Kaleido Desktop, a cinematic Plex client for Windows
Tauri 2 shell with a React/TypeScript interface and libmpv playback composed beneath the web view (DirectComposition on Windows). Shared code with per-OS platform modules and configs so macOS and Linux can follow. - Plex sign-in (browser, plex.tv/link or manual), server selection, Plex Home - Home, Movies and TV Shows (Discover, Library, Collections), search, people - Title pages with logos, ratings, cast, extras, seasons and episodes - Direct play with Plex conversion fallback, tracks, markers, autoplay - Metadata editing, artwork, fix match, refresh, analyze and deletion - Resumable offline downloads - App settings and Plex server administration with a live dashboard - Signed updater feed and Forgejo CI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
00d72e70f4
121 changed files with 25315 additions and 0 deletions
62
src/ui/Backdrop.tsx
Normal file
62
src/ui/Backdrop.tsx
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import { useEffect, useRef, useState } from 'react';
|
||||
import type { Item } from '../plex/types';
|
||||
import { useServer } from '../app/session';
|
||||
import { useSettings } from '../app/settings';
|
||||
import { art, washGradient } from '../app/format';
|
||||
|
||||
interface Layer {
|
||||
key: number;
|
||||
src: string;
|
||||
wash: string;
|
||||
ready: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artwork-led page background. The image sits top-right and fades into the
|
||||
* page toward its left and bottom edges; the UltraBlur colour wash tints the
|
||||
* page beneath. Changes crossfade; the outgoing layer stays until the new
|
||||
* image has decoded.
|
||||
*/
|
||||
export function Backdrop({ item, className = '', width = 1600, height = 900, wash: forceWash }: { item: Item | null | undefined; className?: string; width?: number; height?: number; wash?: Item['ultraBlur'] }) {
|
||||
const server = useServer();
|
||||
const colorWash = useSettings((s) => s.colorWash);
|
||||
const [layers, setLayers] = useState<Layer[]>([]);
|
||||
const counter = useRef(0);
|
||||
const path = item ? art.backdrop(item) : '';
|
||||
const src = path ? server.image(path, width, height) : '';
|
||||
const blur = forceWash ?? item?.ultraBlur ?? null;
|
||||
const wash = colorWash && blur ? washGradient(blur) : '';
|
||||
|
||||
useEffect(() => {
|
||||
if (!src && !wash) return;
|
||||
setLayers((prev) => {
|
||||
if (prev.length && prev[prev.length - 1].src === src) {
|
||||
// Same art, maybe new wash.
|
||||
return prev.map((l, i) => (i === prev.length - 1 ? { ...l, wash } : l));
|
||||
}
|
||||
return [...prev.slice(-1), { key: ++counter.current, src, wash, ready: !src }];
|
||||
});
|
||||
}, [src, wash]);
|
||||
|
||||
const onReady = (key: number) =>
|
||||
setLayers((prev) => {
|
||||
const idx = prev.findIndex((l) => l.key === key);
|
||||
if (idx < 0) return prev;
|
||||
const next = prev.map((l) => (l.key === key ? { ...l, ready: true } : l));
|
||||
// Drop older layers once the newest is visible (after its fade).
|
||||
setTimeout(() => setLayers((p) => (p.length > 1 && p[p.length - 1].key === key ? p.slice(-1) : p)), 700);
|
||||
return next;
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={`backdrop ${className}`} aria-hidden="true">
|
||||
{layers.map((l) => (
|
||||
<div key={l.key} className={`backdrop-layer${l.ready ? ' ready' : ''}`}>
|
||||
{l.wash && <div className="backdrop-wash" style={{ background: l.wash }} />}
|
||||
{l.src && <img className="backdrop-art" src={l.src} alt="" draggable={false} decoding="async" onLoad={() => onReady(l.key)} onError={() => onReady(l.key)} />}
|
||||
</div>
|
||||
))}
|
||||
<div className="backdrop-scrim" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue