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
92
src/ui/Hero.tsx
Normal file
92
src/ui/Hero.tsx
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import { useEffect, useRef, useState } from 'react';
|
||||
import type { Item } from '../plex/types';
|
||||
import { useSettings } from '../app/settings';
|
||||
import { itemMenu, openItem, playWithVersion } from '../app/actions';
|
||||
import { Backdrop } from './Backdrop';
|
||||
import { Facts, TitleArt } from './media';
|
||||
import { Button, IconButton } from './primitives';
|
||||
import { openMenu } from './overlays';
|
||||
import { episodeLabel } from '../app/format';
|
||||
|
||||
export interface Feature {
|
||||
item: Item;
|
||||
eyebrow: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cinematic feature at the top of Home and the Discover pages. Features
|
||||
* rotate every 12 seconds while the pointer is away, crossfading artwork
|
||||
* while the copy lifts out and rises into place.
|
||||
*/
|
||||
export function Hero({ features, variant = 'home' }: { features: Feature[]; variant?: 'home' | 'section' }) {
|
||||
const rotate = useSettings((s) => s.heroRotation);
|
||||
const reduced = useSettings((s) => s.reducedMotion);
|
||||
const [index, setIndex] = useState(0);
|
||||
const [hover, setHover] = useState(false);
|
||||
const [copyKey, setCopyKey] = useState(0);
|
||||
const root = useRef<HTMLElement>(null);
|
||||
const count = features.length;
|
||||
const feature = features[Math.min(index, count - 1)];
|
||||
|
||||
useEffect(() => {
|
||||
if (!rotate || reduced || count < 2 || hover) return;
|
||||
const t = setTimeout(() => go(index + 1), 12000);
|
||||
return () => clearTimeout(t);
|
||||
}, [index, rotate, reduced, count, hover]);
|
||||
|
||||
// Pause rotation when the hero is scrolled away.
|
||||
const [visible, setVisible] = useState(true);
|
||||
useEffect(() => {
|
||||
const el = root.current;
|
||||
if (!el) return;
|
||||
const io = new IntersectionObserver(([e]) => setVisible(e.intersectionRatio > 0.4), { threshold: [0, 0.4, 1] });
|
||||
io.observe(el);
|
||||
return () => io.disconnect();
|
||||
}, []);
|
||||
|
||||
const go = (i: number) => {
|
||||
if (!visible && i !== index) return;
|
||||
setIndex(((i % count) + count) % count);
|
||||
setCopyKey((k) => k + 1);
|
||||
};
|
||||
|
||||
if (!feature) return <section className={`hero ${variant} empty`} />;
|
||||
const item = feature.item;
|
||||
const resume = item.viewOffset > 0;
|
||||
const summary = item.summary || item.tagline;
|
||||
|
||||
return (
|
||||
<section ref={root} className={`hero ${variant}`} onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}>
|
||||
<Backdrop item={item} className="hero-backdrop" />
|
||||
<div className="hero-content" key={copyKey}>
|
||||
<div className="micro hero-eyebrow">{feature.eyebrow}</div>
|
||||
<TitleArt item={item} className="hero-title" maxWidth={variant === 'home' ? 420 : 380} maxHeight={variant === 'home' ? 128 : 108} />
|
||||
{item.type === 'episode' && (
|
||||
<div className="hero-episode">
|
||||
{episodeLabel(item)} · {item.title}
|
||||
</div>
|
||||
)}
|
||||
<Facts item={item} />
|
||||
{summary && <p className="hero-summary">{summary}</p>}
|
||||
<div className="actions hero-actions">
|
||||
<Button variant="primary" icon="play" onClick={() => playWithVersion(item)}>
|
||||
{resume ? 'Resume' : 'Play'}
|
||||
</Button>
|
||||
<Button variant="muted" icon="info" onClick={() => openItem(item.type === 'episode' ? { ...item, id: item.grandparentId || item.id } : item)}>
|
||||
More info
|
||||
</Button>
|
||||
<IconButton round icon="dots" label="More actions" onClick={(e) => openMenu(itemMenu(item), e.currentTarget)} />
|
||||
</div>
|
||||
</div>
|
||||
{count > 1 && (
|
||||
<div className="hero-dots" role="tablist" aria-label="Featured titles">
|
||||
{features.map((f, i) => (
|
||||
<button key={f.item.id} role="tab" aria-selected={i === index} aria-label={f.item.title} className={i === index ? 'active' : ''} onClick={() => go(i)}>
|
||||
{i === index && rotate && !reduced && !hover && visible && <i key={copyKey} className="hero-dot-progress" />}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue