Complete Phase 1 implementation of YTDescGen: - Project setup: Vite 5 + React 18 + TypeScript strict + Tailwind CSS dark theme - Config layer: 7 video types, 10 genres, 7 platforms, rig/social fields - i18n: EN/VI/JA with separate UI and template namespaces + validation script - Core engine: title-builder, description-builder, tag-generator (pure TS, zero React) - 42 unit tests covering all engine functions - Zustand stores: editor + settings with localStorage persistence - UI: 6 primitives, 11 editor components, 4 output components, 3 layout components - Pages: Editor (form + quick preview) and Output (title/desc/tags + copy) - CI/CD: GitHub Actions for lint/typecheck/test/build + GitHub Pages deploy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import clsx from "clsx";
|
|
|
|
interface ToggleProps {
|
|
label: string;
|
|
checked: boolean;
|
|
onChange: (checked: boolean) => void;
|
|
className?: string;
|
|
}
|
|
|
|
export function Toggle({ label, checked, onChange, className }: ToggleProps) {
|
|
return (
|
|
<label className={clsx("flex cursor-pointer items-center gap-3", className)}>
|
|
<button
|
|
role="switch"
|
|
type="button"
|
|
aria-checked={checked}
|
|
onClick={() => onChange(!checked)}
|
|
className={clsx(
|
|
"relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50",
|
|
checked ? "bg-accent" : "bg-surface-3",
|
|
)}
|
|
>
|
|
<span
|
|
className={clsx(
|
|
"pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow-sm transition-transform",
|
|
checked ? "translate-x-5" : "translate-x-0",
|
|
)}
|
|
/>
|
|
</button>
|
|
<span className="text-sm text-text-primary">{label}</span>
|
|
</label>
|
|
);
|
|
}
|