Files
youtube-generator/src/components/layout/MobileNav.tsx
T
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.7 KiB
TypeScript

import { NavLink, useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { m } from "motion/react";
import { Ellipsis } from "lucide-react";
import clsx from "clsx";
import { MOBILE_PRIMARY_PATHS, NAV_ITEMS } from "@config/navigation";
import { HoverIcon, hoverParent } from "@components/icons/animated";
const PRIMARY = NAV_ITEMS.filter((item) => MOBILE_PRIMARY_PATHS.includes(item.to));
/**
* Bottom tab bar below `md`: the four pages a phone user needs most, plus
* "More" for the rest (the navigation sheet). Replaces the hamburger-only
* drawer, which hid every page behind a tap. It is the last row of the shell's
* column rather than `position: fixed`, so the page area ends above it and
* nothing sticky inside a page can slide underneath.
*/
export function MobileNav({
onOpenMore,
moreActive,
}: {
onOpenMore: () => void;
moreActive: boolean;
}) {
const { t } = useTranslation("ui");
const { pathname } = useLocation();
const onPrimaryPage = PRIMARY.some((item) =>
item.to === "/" ? pathname === "/" : pathname.startsWith(item.to),
);
const cell =
"relative flex h-14 flex-1 flex-col items-center justify-center gap-0.5 text-[0.6875rem] font-medium";
return (
<nav
aria-label={t("nav.main")}
className="border-border bg-surface-1 safe-bottom shrink-0 border-t md:hidden"
>
<div className="flex">
{PRIMARY.map((item) => (
<NavLink
key={item.to}
to={item.to}
end={item.to === "/"}
className={({ isActive }) => clsx(cell, isActive ? "text-accent" : "text-text-muted")}
>
{({ isActive }) => (
<m.span {...hoverParent} className="flex flex-col items-center gap-0.5">
{isActive && (
<m.span
layoutId="nav-active-mobile"
className="bg-accent absolute top-0 h-0.5 w-8 rounded-full"
aria-hidden="true"
/>
)}
<HoverIcon icon={item.icon} motion={item.motion} className="size-5" />
<span className="max-w-full truncate px-1">{t(item.labelKey)}</span>
</m.span>
)}
</NavLink>
))}
<button
type="button"
onClick={onOpenMore}
aria-expanded={moreActive}
className={clsx(
cell,
"cursor-pointer",
!onPrimaryPage || moreActive ? "text-accent" : "text-text-muted",
)}
>
<Ellipsis className="size-5" aria-hidden="true" />
<span>{t("nav.more")}</span>
</button>
</div>
</nav>
);
}