Added platform icons and fixed context menu scrolling

This commit is contained in:
patben8 committed 2026-09-25 15:23:39 +02:00
1 parent be80e572e5
commit f9497b391b
4 files changed
+147 -21

No files matched your search

+11 -1
View File
@@ -651,7 +651,12 @@ frontend at `http://localhost:5173`.
- Frontend: functional components, TanStack Query for fetching, Tailwind
utility classes with the `ink-*`/`well`/`accent`/`gold`/`mint`/`pink` tokens
and the material classes from `index.css` (see "Theme"). Icons come from
`lib/icons.tsx`, never emoji. Keep `api.ts` types aligned with `schemas.py`.
`lib/icons.tsx`, never emoji; a platform's own mark comes from
`lib/platformIcons.tsx` (`<PlatformIcon platform=…>` — single-colour marks
redrawn from each platform's app icon, masks keyed by `useId` since one page
can show a mark twice). That file is a lookup of display ASSETS by platform
id, not platform branching; an unknown id falls back to a generic mark, so a
new adapter needs no change there to appear. Keep `api.ts` types aligned with `schemas.py`.
## Theme — "dark liquid glass"
@@ -686,6 +691,11 @@ easy to break:
the first time a panel opens it. Small popovers anchored to a control inside a
scrolling list should open the shared `ContextMenu` instead (as the playlist
row's "Add to export" does) — a popover inside the list is clipped by it.
- **A `.glass` / `.glass-overlay` box must never be the element that scrolls.**
Its tint, blur and rim are pseudo-elements sized to the box, so they scroll
away with the first screenful and leave later content on bare background (the
column chooser's last items did). Give the glass frame `overflow-hidden` and
scroll an inner element — as every dialog and `ContextMenu` do.
- **The accent is `oklch(0.8 0.11 var(--accent-hue))`** — the cover's hue at a
FIXED lightness and chroma, so dark text on it keeps its contrast whatever is
loaded. `lib/ambient.ts` sets `--accent-hue` and `--amb-1..4` on `<html>`;
+41 -18
View File
@@ -1,8 +1,10 @@
import { useState } from 'react'
import { useState, type ReactNode } from 'react'
import { useMutation, useQuery } from '@tanstack/react-query'
import { api, type CollectionCandidate, type CollectionStatus, type PlatformOption } from '../api'
import { FileBrowser, useFsListing } from './FileBrowser'
import { browsePrompt, platformAvailability } from '../lib/platformCopy'
import { Icon } from '../lib/icons'
import { PlatformIcon } from '../lib/platformIcons'
/**
* Choose a library to open, in two steps: WHICH PLATFORM, then which library.
@@ -35,13 +37,16 @@ function formatWhen(sec: number | null): string {
function OptionCard({
icon,
lit,
title,
subtitle,
disabled,
busy,
onClick,
}: {
icon: string
icon: ReactNode
/** A small lit dot on the icon tile: "something is here". */
lit?: boolean
title: string
subtitle: string
disabled?: boolean
@@ -52,14 +57,24 @@ function OptionCard({
<button
disabled={disabled || busy}
onClick={onClick}
className="flex w-full items-center gap-3 rounded-lg border border-line bg-ink-850 px-4 py-3 text-left transition-colors hover:border-accent hover:bg-ink-800 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-line disabled:hover:bg-ink-850"
className="btn-glass group flex w-full items-center gap-3.5 rounded-2xl px-3 py-3 text-left disabled:cursor-not-allowed disabled:opacity-40"
>
<span className="text-xl">{icon}</span>
<span className="well relative flex h-11 w-11 shrink-0 items-center justify-center rounded-xl text-text">
{icon}
{lit && (
<span className="absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full bg-mint shadow-[0_0_8px_var(--color-mint)] ring-2 ring-[rgb(12_14_24)]" />
)}
</span>
<div className="min-w-0 flex-1">
<div className="text-sm font-medium text-text">{title}</div>
<div className="text-sm font-semibold text-text">{title}</div>
<div className="truncate text-xs text-faint">{subtitle}</div>
</div>
<span className="text-faint">›</span>
<Icon
name="chevronRight"
size={14}
strokeWidth={2.2}
className="text-faint transition-colors group-hover:text-text"
/>
</button>
)
}
@@ -124,6 +139,11 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
<div className="glass flex h-[600px] w-full max-w-2xl flex-col overflow-hidden">
{/* Header */}
<div className="flex items-center gap-3 border-b border-line px-5 py-4">
{platform && (
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-ink-800 text-text">
<PlatformIcon platform={platform.platform} size={22} />
</span>
)}
<div className="min-w-0 flex-1">
<div className="text-[15px] font-semibold tracking-tight">
{platform ? `Select your ${platform.name} library` : 'Select your DJ platform'}
@@ -133,23 +153,25 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
{step === 'browse' && (
<button
onClick={() => setStep('library')}
className="rounded-md px-2.5 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
className="flex items-center gap-1 rounded-full px-3 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
>
‹ Back
<Icon name="chevronLeft" size={13} strokeWidth={2.2} />
Back
</button>
)}
{step === 'library' && (
<button
onClick={goPlatform}
className="rounded-md px-2.5 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
className="flex items-center gap-1 rounded-full px-3 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
>
‹ Platforms
<Icon name="chevronLeft" size={13} strokeWidth={2.2} />
Platforms
</button>
)}
{onCancel && (
<button
onClick={onCancel}
className="rounded-md px-2.5 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
className="rounded-full px-3 py-1.5 text-sm text-muted hover:bg-ink-800 hover:text-text"
>
Cancel
</button>
@@ -166,7 +188,8 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
{platforms.data?.map((p) => (
<OptionCard
key={p.platform}
icon={p.removable ? '⬒' : p.found > 0 ? '●' : '○'}
icon={<PlatformIcon platform={p.platform} size={26} />}
lit={p.found > 0}
title={p.name}
subtitle={platformAvailability(p)}
onClick={() => {
@@ -180,7 +203,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
/* ---- Step 2: which library of that platform ---- */
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-5">
<OptionCard
icon="✨"
icon={<Icon name="sparkle" size={20} />}
title="Automatic"
subtitle={
auto
@@ -196,7 +219,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
onClick={() => auto && open.mutate(auto.path)}
/>
<OptionCard
icon="🕘"
icon={<Icon name="history" size={20} />}
title="Open last library"
subtitle={
recent
@@ -210,7 +233,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
onClick={() => recent && open.mutate(recent.path)}
/>
<OptionCard
icon="📂"
icon={<Icon name="folderOpen" size={20} />}
title="Find library manually"
subtitle={
picksDirectory
@@ -234,7 +257,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
key={c.path}
disabled={open.isPending}
onClick={() => open.mutate(c.path)}
className="flex w-full items-center gap-2 rounded-md border border-line bg-ink-850 px-3 py-2 text-left text-sm text-muted hover:border-accent hover:text-text disabled:opacity-40"
className="btn-glass flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-muted hover:text-text disabled:opacity-40"
>
<span className="truncate">{c.label}</span>
<span className="ml-auto shrink-0 text-[11px] text-faint">
@@ -247,7 +270,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
)}
{openError && (
<div className="rounded-md border border-pink/40 bg-ink-850 px-3 py-2 text-xs text-pink">
<div className="rounded-xl bg-pink/10 px-3 py-2 text-xs text-pink shadow-[inset_0_0_0_1px_rgb(255_122_154/0.35)]">
{openError}
</div>
)}
@@ -286,7 +309,7 @@ export function CollectionPicker({ onOpened, onCancel }: Props) {
{/* Manual path + errors */}
<div className="border-t border-line px-4 py-3">
{openError && (
<div className="mb-2 rounded-md border border-pink/40 bg-ink-850 px-3 py-2 text-xs text-pink">
<div className="mb-2 rounded-xl bg-pink/10 px-3 py-2 text-xs text-pink shadow-[inset_0_0_0_1px_rgb(255_122_154/0.35)]">
{openError}
</div>
)}
+15 -2
View File
@@ -21,6 +21,9 @@ interface Props {
const SUBMENU_WIDTH = 240
const SUBMENU_MAX_HEIGHT = 288
// A long menu (the header's column chooser lists every column) scrolls rather
// than running the height of the window.
const MENU_MAX_HEIGHT = 400
// Lightweight fixed-position menu. Closes on outside click, scroll, or Escape.
export function ContextMenu({ x, y, items, onClose }: Props) {
@@ -67,7 +70,11 @@ export function ContextMenu({ x, y, items, onClose }: Props) {
className="min-w-[160px]"
style={(() => {
const top = Math.min(y, window.innerHeight - 100)
return { top, left: Math.min(x, window.innerWidth - 180), maxHeight: window.innerHeight - top - 8 }
return {
top,
left: Math.min(x, window.innerWidth - 180),
maxHeight: Math.min(MENU_MAX_HEIGHT, window.innerHeight - top - 8),
}
})()}
/>
</div>,
@@ -102,10 +109,15 @@ function MenuPanel({
return (
<>
{/* The glass (tint, blur, rim) is painted by pseudo-elements of THIS box,
so it must not be the one that scrolls: its ::before/::after would
scroll away with the first screenful of items and leave the rest on
bare background. The frame stays put; the inner list scrolls. */}
<div
className={`glass-overlay fixed z-[70] overflow-y-auto rounded-2xl p-1.5 ${className}`}
className={`glass-overlay fixed z-[70] flex flex-col overflow-hidden rounded-2xl ${className}`}
style={style}
>
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-1.5">
{items.map((item, i) => {
if ('separator' in item) {
return <div key={i} className="mx-2 my-1 border-t border-line" />
@@ -182,6 +194,7 @@ function MenuPanel({
)
})}
</div>
</div>
{open && openItem && 'submenu' in openItem && (
<MenuPanel items={openItem.submenu} onClose={onClose} style={open.style} />
)}
+80
View File
@@ -0,0 +1,80 @@
// The DJ platforms' marks, for the collection picker and anywhere else a
// library's platform is named. Redrawn as geometry from each platform's app icon
// (not traced), single-colour via `currentColor` so they take the theme's text
// colour; the square app-icon backgrounds are left to whatever tile holds them.
//
// These are the platforms' trademarks, used to say which platform is which.
//
// A lookup of display ASSETS keyed by platform id — not behaviour branching on
// the platform, which components must never do. An unknown id falls back to a
// generic mark, so a new adapter shows up without touching this file.
import { useId } from 'react'
import { Icon } from './icons'
type Mark = (props: { mask: string }) => React.ReactElement
const MARKS: Record<string, Mark> = {
// An outer ring around a disk cut by an X, with a hole at the centre.
traktor: ({ mask }) => (
<>
<mask id={mask}>
<rect width="100" height="100" fill="#fff" />
<path d="M82.2 26.05L14.36 68.44L17.8 73.95L85.64 31.56Z" fill="#000" />
<path d="M85.64 68.44L17.8 26.05L14.36 31.56L82.2 73.95Z" fill="#000" />
<path d="M38 50a12 12 0 1 0 24 0a12 12 0 1 0 -24 0Z" fill="#000" />
</mask>
<path d="M5 50a45 45 0 1 0 90 0a45 45 0 1 0 -90 0ZM13 50a37 37 0 1 0 74 0a37 37 0 1 0 -74 0Z" fillRule="evenodd" />
<path d="M19.5 50a30.5 30.5 0 1 0 61 0a30.5 30.5 0 1 0 -61 0Z" mask={`url(#${mask})`} />
</>
),
// A cube split into three faces by a Y of spokes that meet in a ring.
rekordbox: ({ mask }) => (
<>
<mask id={mask}>
<rect width="100" height="100" fill="#fff" />
<path d="M51.88 46.75L10.31 22.75L6.56 29.25L48.12 53.25Z" fill="#000" />
<path d="M51.88 53.25L93.44 29.25L89.69 22.75L48.12 46.75Z" fill="#000" />
<path d="M46.25 50L46.25 98L53.75 98L53.75 50Z" fill="#000" />
<path d="M29 50a21 21 0 1 0 42 0a21 21 0 1 0 -42 0Z" fill="#000" />
<path d="M38 50a12 12 0 1 0 24 0a12 12 0 1 0 -24 0Z" fill="#fff" />
</mask>
<path
d="M50 9L85.51 29.5L85.51 70.5L50 91L14.49 70.5L14.49 29.5Z"
stroke="currentColor"
strokeWidth="5"
strokeLinejoin="round"
mask={`url(#${mask})`}
/>
</>
),
// A "C": a solid arc breaking into blades that thin toward three o'clock.
// Fewer, wider blades than the original, so they stay distinct at 16 px.
onelibrary: () => <path d="M44.29 9.4A41 41 0 1 0 58.52 90.1L55.41 75.43A26 26 0 1 1 46.38 24.25ZM61.58 89.33A41 41 0 0 0 66.41 87.57L61.23 75.71A28.05 28.05 0 0 1 57.92 76.91ZM70.13 85.72A41 41 0 0 0 74.45 82.92L67.45 73.5A29.27 29.27 0 0 1 64.37 75.5ZM77.65 80.28A41 41 0 0 0 81.22 76.57L73.09 69.65A30.32 30.32 0 0 1 70.44 72.39ZM83.75 73.28A41 41 0 0 0 86.4 68.87L77.65 64.33A31.14 31.14 0 0 1 75.63 67.68ZM88.12 65.09A41 41 0 0 0 89.71 60.2L80.71 57.89A31.71 31.71 0 0 1 79.48 61.67ZM90.54 56.13A41 41 0 0 0 90.99 51L81.97 50.78A31.98 31.98 0 0 1 81.62 54.78ZM90.88 46.85A41 41 0 0 0 90.16 41.76L81.29 43.58A31.94 31.94 0 0 1 81.85 47.55ZM89.12 37.74A41 41 0 0 0 87.28 32.93L78.73 36.84A31.6 31.6 0 0 1 80.16 40.55ZM85.36 29.25A41 41 0 0 0 82.48 24.98L74.54 31.1A30.97 30.97 0 0 1 76.72 34.33ZM79.79 21.83A41 41 0 0 0 76.02 18.32L69.1 26.75A30.09 30.09 0 0 1 71.86 29.32ZM72.69 15.85A41 41 0 0 0 68.23 13.28L62.89 24.02A29 29 0 0 1 66.05 25.85ZM64.43 11.62A41 41 0 0 0 59.5 10.12L56.43 23A27.75 27.75 0 0 1 59.77 24.02ZM55.42 9.36A41 41 0 0 0 50.29 9L50.18 23.58A26.42 26.42 0 0 1 53.49 23.81Z" />,
}
export function PlatformIcon({
platform,
size = 20,
className,
}: {
platform: string
size?: number
className?: string
}) {
// Masks are addressed by id, and one page can show the same mark twice.
const mask = `pm-${useId().replace(/:/g, '')}`
const Mark = MARKS[platform]
if (!Mark) return <Icon name="music" size={size} className={className} />
return (
<svg
width={size}
height={size}
viewBox="0 0 100 100"
fill="currentColor"
aria-hidden
className={className}
>
<Mark mask={mask} />
</svg>
)
}