A new, compact interface on Radix primitives, Motion, cmdk and sonner. Design system - Tokens for surfaces, text, accent and states in dark and light, used everywhere (no more hard-coded red/yellow/pink); Inter and JetBrains Mono self-hosted; compact controls that grow to 44px on touch screens. - Primitives rebuilt on Radix: Button, IconButton (cannot render without a name), Field/Input/Select/Textarea (labels wired to controls; the ten selects that shared id="type" are gone), Switch, Checkbox, Tabs, SegmentedControl, Accordion (closed content is inert), Dialog, AlertDialog, Sheet, Popover, Tooltip, Card, Badge, Banner, EmptyState, PageHeader, NumberField. - Animated icons (copy→check, sun↔moon, hover micro-motion on the nav) that follow the OS reduce-motion setting. App shell - Collapsible sidebar with grouped pages and a sliding active marker; top bar with the command palette, output/interface language, theme and donate; on phones a bottom bar with four pages plus "More". - Ctrl/⌘+K command palette: go anywhere, copy title/description/tags, apply a profile/preset/template, switch theme or languages. - Skip link, one h1 per page, <main> focusable; toasts no longer share a corner with three other floating elements. Pages - Editor: two columns with a sticky live preview (tabs, counters, copy) or a sheet on phones; sections reordered so video type and game come first; genres are a searchable picker instead of a wall of 42 chips; expand/collapse all; a button to the Output page. - Output: a YouTube preview (what search results and the "…more" fold show), language tabs, Copy All in the header (floating on phones). - Profiles/presets/templates share one card with Apply + Undo; History, Logs, Batch, Social, Playlist, Settings, About, Legal, the consent screen and the error pages all use the same primitives. Fixes - Ctrl/⌘+Shift+C ignored the YouTube limits and Strict Mode. - Number settings clamped on every keystroke; they now save on blur. - Hard-coded English on Playlist, Batch, Logs, Profiles and Settings. - Flags as language icons (Windows shows letters) → native name + code. - The consent screen could not change language or theme. - About: dead Discord invite removed; contact addresses by purpose. - Desktop window is resizable (1280×820, min 960×640). Initial load 262 KB gzip (budget 280): the command palette, the genre list and the Output page load on demand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.8 KiB
TypeScript
69 lines
2.8 KiB
TypeScript
import { useTranslation } from "react-i18next";
|
|
import { ListMusic } from "lucide-react";
|
|
import { Accordion } from "@components/ui/Accordion";
|
|
import { Badge } from "@components/ui/Badge";
|
|
import { ValidatedInput } from "@components/ui/ValidatedInput";
|
|
import { GENRES } from "@config/genres";
|
|
import { FIELD_LIMITS } from "@config/field-limits";
|
|
import { useSettingsStore } from "@store/settings-store";
|
|
import { validatePlaylistUrl } from "@utils/validation";
|
|
|
|
/**
|
|
* Per-genre YouTube playlist URLs, which the pinned-comment template uses to
|
|
* suggest a playlist matching the video's primary genre (v0.8 phase 2).
|
|
*
|
|
* Extracted from SettingsPage in v0.35.0. It renders one input per genre — 42
|
|
* of them — which made it both the tallest block on the page and a third of
|
|
* its source. It now ships collapsed by default, with a filled-count badge so
|
|
* the header still says something useful while closed.
|
|
*/
|
|
export function GenrePlaylistsSection() {
|
|
const { t } = useTranslation("ui");
|
|
const genrePlaylists = useSettingsStore((s) => s.genrePlaylists);
|
|
const setSetting = useSettingsStore((s) => s.setSetting);
|
|
const accordion = useSettingsStore((s) => s.settingsAccordionState);
|
|
const toggleAccordion = useSettingsStore((s) => s.toggleSettingsAccordion);
|
|
|
|
const filled = Object.values(genrePlaylists).filter((v) => v?.trim()).length;
|
|
|
|
return (
|
|
<Accordion
|
|
id="genrePlaylists"
|
|
icon={ListMusic}
|
|
title={t("settings.genrePlaylistsTitle")}
|
|
open={accordion.genrePlaylists ?? false}
|
|
onToggle={() => toggleAccordion("genrePlaylists")}
|
|
badge={<Badge>{t("settings.genrePlaylistsBadge", { filled, total: GENRES.length })}</Badge>}
|
|
>
|
|
<p className="text-text-muted text-xs">{t("settings.genrePlaylistsHelp")}</p>
|
|
<p className="text-text-muted text-xs">{t("settings.genrePlaylistsEmptyHint")}</p>
|
|
<div className="flex flex-col gap-2">
|
|
{GENRES.map((g) => (
|
|
<ValidatedInput
|
|
key={g.id}
|
|
label={t(g.labelKey)}
|
|
maxLength={FIELD_LIMITS.URL}
|
|
placeholder="https://www.youtube.com/playlist?list=..."
|
|
value={genrePlaylists[g.id] ?? ""}
|
|
onChange={(v) => {
|
|
const trimmed = v.trim();
|
|
if (trimmed) {
|
|
setSetting("genrePlaylists", { ...genrePlaylists, [g.id]: trimmed });
|
|
} else {
|
|
// Empty input → drop this genre's entry entirely so the map
|
|
// stays sparse. Filter pattern instead of `delete` satisfies
|
|
// @typescript-eslint/no-dynamic-delete.
|
|
setSetting(
|
|
"genrePlaylists",
|
|
Object.fromEntries(Object.entries(genrePlaylists).filter(([k]) => k !== g.id)),
|
|
);
|
|
}
|
|
}}
|
|
validate={validatePlaylistUrl}
|
|
/>
|
|
))}
|
|
</div>
|
|
</Accordion>
|
|
);
|
|
}
|