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
126
src/app/TopBar.tsx
Normal file
126
src/app/TopBar.tsx
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { navigate, topLevel, useRouter } from './router';
|
||||
import { useSession } from './session';
|
||||
import { useSettings } from './settings';
|
||||
import { Icon } from '../ui/Icon';
|
||||
import { KaleidoMark } from '../ui/primitives';
|
||||
import { openMenu, type MenuItem } from '../ui/overlays';
|
||||
import { isNative, win } from '../platform/native';
|
||||
import { useDownloads } from '../downloads/store';
|
||||
import { useHomeUsers } from './useHomeUsers';
|
||||
|
||||
const NAV = [
|
||||
{ id: 'home', label: 'Home', route: { name: 'home' } as const },
|
||||
{ id: 'movies', label: 'Movies', route: { name: 'section', kind: 'movie', tab: 'discover' } as const },
|
||||
{ id: 'shows', label: 'TV Shows', route: { name: 'section', kind: 'show', tab: 'discover' } as const },
|
||||
{ id: 'downloads', label: 'Downloads', route: { name: 'downloads' } as const },
|
||||
];
|
||||
|
||||
function WindowControls() {
|
||||
const [maximized, setMaximized] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!isNative) return;
|
||||
let off: (() => void) | undefined;
|
||||
const sync = () => win.isMaximized().then(setMaximized);
|
||||
sync();
|
||||
win.onResized(sync).then((u) => (off = u));
|
||||
return () => off?.();
|
||||
}, []);
|
||||
if (!isNative) return null;
|
||||
return (
|
||||
<div className="window-controls">
|
||||
<button aria-label="Minimize" onClick={() => win.minimize()}>
|
||||
<Icon name="minimize" size={15} strokeWidth={1.4} />
|
||||
</button>
|
||||
<button aria-label={maximized ? 'Restore' : 'Maximize'} onClick={() => win.toggleMaximize()}>
|
||||
<Icon name={maximized ? 'restore' : 'maximize'} size={13} strokeWidth={1.4} />
|
||||
</button>
|
||||
<button aria-label="Close" className="close" onClick={() => win.close()}>
|
||||
<Icon name="x" size={15} strokeWidth={1.4} />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Avatar() {
|
||||
const user = useSession((s) => s.user);
|
||||
const server = useSession((s) => s.server);
|
||||
const connection = useSession((s) => s.connection);
|
||||
const showServerPicker = useSession((s) => s.showServerPicker);
|
||||
const signOut = useSession((s) => s.signOut);
|
||||
const home = useHomeUsers();
|
||||
const initial = (user?.title || server?.name || 'K').slice(0, 1).toUpperCase();
|
||||
const menu = (el: HTMLElement) => {
|
||||
const items: MenuItem[] = [
|
||||
{ heading: user ? user.title : 'Kaleido' },
|
||||
{
|
||||
label: server ? `${server.name}` : 'No server',
|
||||
hint: connection ? (connection.relay ? 'Relay' : connection.local ? 'Local' : 'Remote') : '',
|
||||
icon: 'server',
|
||||
onSelect: showServerPicker,
|
||||
},
|
||||
];
|
||||
if (home.users.length > 1) {
|
||||
items.push({
|
||||
label: 'Switch profile',
|
||||
icon: 'users',
|
||||
submenu: home.users.map((u) => ({ label: u.title, checked: u.uuid === user?.uuid, onSelect: () => home.switchTo(u) })),
|
||||
});
|
||||
}
|
||||
items.push(
|
||||
{ divider: true },
|
||||
{ label: 'Settings', icon: 'settings', onSelect: () => navigate({ name: 'settings', mode: 'app', tab: 'general' }) },
|
||||
);
|
||||
if (server?.owned) items.push({ label: 'Server dashboard', icon: 'activity', onSelect: () => navigate({ name: 'settings', mode: 'server', tab: 'dashboard' }) });
|
||||
items.push({ divider: true }, { label: 'Sign out', icon: 'logout', onSelect: signOut });
|
||||
openMenu(items, el, { align: 'end', minWidth: 250 });
|
||||
};
|
||||
return (
|
||||
<button className="avatar-btn" aria-label="Account" onClick={(e) => menu(e.currentTarget)}>
|
||||
{user?.thumb ? <img src={user.thumb} alt="" draggable={false} /> : <span>{initial}</span>}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export function TopBar({ solid }: { solid: boolean }) {
|
||||
const current = useRouter((s) => s.current.route);
|
||||
const canBack = useRouter((s) => s.index > 0);
|
||||
const back = useRouter((s) => s.back);
|
||||
const active = topLevel(current);
|
||||
const activeDownloads = useDownloads((s) => s.items.filter((d) => d.status === 'downloading' || d.status === 'queued').length);
|
||||
const startPage = useSettings((s) => s.startPage);
|
||||
void startPage;
|
||||
const showBack = canBack && !active;
|
||||
|
||||
return (
|
||||
<header className={`topbar${solid ? ' solid' : ''}`} data-tauri-drag-region>
|
||||
<div className="topbar-left" data-tauri-drag-region>
|
||||
<button className={`nav-back${showBack ? ' show' : ''}`} aria-label="Back" onClick={back} tabIndex={showBack ? 0 : -1}>
|
||||
<Icon name="arrowLeft" size={19} />
|
||||
</button>
|
||||
<button className="brand" onClick={() => navigate({ name: 'home' })} aria-label="Kaleido home">
|
||||
<KaleidoMark size={24} />
|
||||
<span>KALEIDO</span>
|
||||
</button>
|
||||
<nav className="primary-nav" aria-label="Main navigation" data-tauri-drag-region>
|
||||
{NAV.map((n) => (
|
||||
<button key={n.id} className={`nav-item${active === n.id ? ' active' : ''}`} onClick={() => navigate(n.route)}>
|
||||
{n.label}
|
||||
{n.id === 'downloads' && activeDownloads > 0 && <span className="nav-count">{activeDownloads}</span>}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
<div className="topbar-right" data-tauri-drag-region>
|
||||
<button className={`icon-btn${active === 'search' ? ' on' : ''}`} aria-label="Search" title="Search (Ctrl+K)" onClick={() => navigate({ name: 'search' })}>
|
||||
<Icon name="search" size={19} />
|
||||
</button>
|
||||
<button className={`icon-btn${active === 'settings' ? ' on' : ''}`} aria-label="Settings" title="Settings" onClick={() => navigate({ name: 'settings', mode: 'app', tab: 'general' })}>
|
||||
<Icon name="settings" size={19} />
|
||||
</button>
|
||||
<Avatar />
|
||||
<WindowControls />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue