Files
youtube-generator/src/components/editor/CommunityEditor.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

119 lines
4.4 KiB
TypeScript

import { useTranslation } from "react-i18next";
import { ValidatedInput } from "@components/ui/ValidatedInput";
import { useEditorStore } from "@store/editor-store";
import {
validateMessengerUrl,
validateZaloGroupUrl,
validateSignalGroupUrl,
validateInstagramInviteUrl,
validateFacebookGroupUrl,
} from "@utils/validation";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Community invite links. A single section for "join the chat" links that
* feed the description's "💬 COMMUNITY" block:
*
* - Messenger community (`https://m.me/ch/<id>`), Signal group
* (`https://signal.group/#<id>`), Instagram group chat
* (`https://www.instagram.com/j/<id>` or `https://ig.me/j/<id>`), and
* Facebook Group (`https://facebook.com/groups/<id>`) — all shown for
* every output language (v0.32.0 Messenger; v0.33.0 the rest, with
* Facebook Group moved here from the Social section).
* - Zalo group (`https://zalo.me/g/<code>`) — Zalo is a Vietnam-audience
* app, so the input only appears (and the description line only renders)
* when the output language is Vietnamese. A value entered while in
* Vietnamese is preserved if the creator later switches language.
*
* Every input hard-rejects malformed links via {@link ValidatedInput}, so a
* bad URL never reaches the generated description.
*/
export function CommunityEditor() {
const { t } = useTranslation("ui");
const messengerCommunityLink = useEditorStore((s) => s.messengerCommunityLink);
const signalGroupLink = useEditorStore((s) => s.signalGroupLink);
const instagramGroupLink = useEditorStore((s) => s.instagramGroupLink);
const facebookGroupLink = useEditorStore((s) => s.facebookGroupLink);
const zaloGroupLink = useEditorStore((s) => s.zaloGroupLink);
const language = useEditorStore((s) => s.language);
const setField = useEditorStore((s) => s.set);
const isVi = language === "vi";
return (
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-1">
<span className="text-text-primary text-sm font-semibold">{t("editor.community")}</span>
<p className="text-text-muted text-xs">{t("editor.communityHelp")}</p>
</div>
<ValidatedInput
fieldId="messengerCommunityLink"
labelKey="editor.messengerCommunityLink"
label={t("editor.messengerCommunityLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.messengerCommunityLinkPlaceholder")}
value={messengerCommunityLink}
onChange={(v) => setField("messengerCommunityLink", v)}
validate={validateMessengerUrl}
inputMode="url"
autoComplete="off"
/>
<ValidatedInput
fieldId="signalGroupLink"
labelKey="editor.signalGroupLink"
label={t("editor.signalGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.signalGroupLinkPlaceholder")}
value={signalGroupLink}
onChange={(v) => setField("signalGroupLink", v)}
validate={validateSignalGroupUrl}
inputMode="url"
autoComplete="off"
/>
<ValidatedInput
fieldId="instagramGroupLink"
labelKey="editor.instagramGroupLink"
label={t("editor.instagramGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.instagramGroupLinkPlaceholder")}
value={instagramGroupLink}
onChange={(v) => setField("instagramGroupLink", v)}
validate={validateInstagramInviteUrl}
inputMode="url"
autoComplete="off"
/>
<ValidatedInput
fieldId="facebookGroupLink"
labelKey="editor.facebookGroupLink"
label={t("editor.facebookGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.facebookGroupLinkPlaceholder")}
value={facebookGroupLink}
onChange={(v) => setField("facebookGroupLink", v)}
validate={validateFacebookGroupUrl}
inputMode="url"
autoComplete="off"
/>
{isVi && (
<ValidatedInput
fieldId="zaloGroupLink"
labelKey="editor.zaloGroupLink"
label={t("editor.zaloGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.zaloGroupLinkPlaceholder")}
value={zaloGroupLink}
onChange={(v) => setField("zaloGroupLink", v)}
validate={validateZaloGroupUrl}
inputMode="url"
autoComplete="off"
/>
)}
</div>
);
}