Files
poli0981andClaude Opus 5.5 a2715f9c69 feat(ui): redesign — design system, app shell, command palette, every page
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>
2026-09-30 20:42:43 +07:00

79 lines
2.6 KiB
TypeScript

import { useEffect, useState, type RefObject } from "react";
import { useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { AnimatePresence, m } from "motion/react";
import { ArrowUp } from "lucide-react";
interface ScrollToTopButtonProps {
/**
* The scrollable container to watch and scroll back to the top. React 19
* types `useRef<T>(null)` as `RefObject<T | null>` — the ref genuinely is
* null before the element mounts.
*/
scrollRef: RefObject<HTMLElement | null>;
}
/** Scroll distance (px) past which the button appears. */
const SHOW_AFTER_PX = 600;
/**
* Floating "back to top" button in the bottom-left corner of the page area
* (bottom-right is where pages keep their primary actions and toasts). It
* appears once `<main>` is scrolled past {@link SHOW_AFTER_PX}.
*/
export function ScrollToTopButton({ scrollRef }: ScrollToTopButtonProps) {
const { t } = useTranslation("ui");
const location = useLocation();
const [visible, setVisible] = useState(false);
useEffect(() => {
const el = scrollRef.current;
if (!el) return;
let ticking = false;
const update = () => {
setVisible(el.scrollTop > SHOW_AFTER_PX);
ticking = false;
};
const onScroll = () => {
if (ticking) return;
ticking = true;
requestAnimationFrame(update);
};
// Re-evaluate on mount and whenever the route changes — the same
// <main> persists across pages.
update();
el.addEventListener("scroll", onScroll, { passive: true });
return () => el.removeEventListener("scroll", onScroll);
}, [scrollRef, location.pathname]);
function scrollToTop() {
const el = scrollRef.current;
if (!el) return;
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
el.scrollTo({ top: 0, behavior: reduceMotion ? "auto" : "smooth" });
el.focus({ preventScroll: true });
}
return (
<AnimatePresence>
{visible && (
<m.button
type="button"
onClick={scrollToTop}
aria-label={t("common.scrollToTop")}
initial={{ opacity: 0, y: 8, scale: 0.9 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 8, scale: 0.9 }}
transition={{ duration: 0.16 }}
whileHover={{ y: -2 }}
className="border-border bg-surface-1/90 text-text-secondary hover:text-text-primary shadow-pop absolute bottom-4 left-4 z-20 flex size-10 cursor-pointer items-center justify-center rounded-full border backdrop-blur-md"
>
<ArrowUp className="size-4" aria-hidden="true" />
</m.button>
)}
</AnimatePresence>
);
}