Merge pull request #238 from poli0981/feat/accessibility-pass

feat(a11y): contrast to AA, output language, page announcements, single-key shortcut switch, desktop zoom
This commit is contained in:
poli0981 authored and GitHub committed 2026-11-09 20:10:35 +07:00
commit 806201721c
47 files changed
+531 -80

No files matched your search

+2 -1
View File
@@ -1,11 +1,12 @@
{
"identifier": "default",
"description": "Default capabilities for YTDescGen. File access goes through the app's own name-only commands and native dialogs run from Rust, so the webview gets no dialog, fs or shell permissions.",
"description": "Default capabilities for YTDescGen. File access goes through the app's own name-only commands and native dialogs run from Rust, so the webview gets no dialog, fs or shell permissions. set-webview-zoom backs the Ctrl/Cmd +/- zoom polyfill Tauri injects on macOS and Linux (zoomHotkeysEnabled).",
"windows": [
"main"
],
"permissions": [
"core:default",
"core:webview:allow-set-webview-zoom",
"opener:default"
]
}
+1 -1
View File
@@ -1 +1 @@
{"default":{"identifier":"default","description":"Default capabilities for YTDescGen. File access goes through the app's own name-only commands and native dialogs run from Rust, so the webview gets no dialog, fs or shell permissions.","local":true,"windows":["main"],"permissions":["core:default","opener:default"]}}
{"default":{"identifier":"default","description":"Default capabilities for YTDescGen. File access goes through the app's own name-only commands and native dialogs run from Rust, so the webview gets no dialog, fs or shell permissions. set-webview-zoom backs the Ctrl/Cmd +/- zoom polyfill Tauri injects on macOS and Linux (zoomHotkeysEnabled).","local":true,"windows":["main"],"permissions":["core:default","core:webview:allow-set-webview-zoom","opener:default"]}}
+2 -1
View File
@@ -20,7 +20,8 @@
"resizable": true,
"maximizable": true,
"fullscreen": false,
"center": true
"center": true,
"zoomHotkeysEnabled": true
}
],
"security": {
+6 -2
View File
@@ -265,6 +265,7 @@ export function EndingsEditor() {
type="number"
min={1}
max={MAX_ENDINGS}
aria-label={t("editor.endings.rowNumberAria", { row: i + 1 })}
value={entry.number?.toString() ?? ""}
onChange={(e) => {
const v = e.target.value.trim();
@@ -275,6 +276,7 @@ export function EndingsEditor() {
<td className="px-2 py-1.5">
<Input
placeholder={t("editor.endings.namePlaceholder")}
aria-label={t("editor.endings.rowNameAria", { row: i + 1 })}
value={entry.name}
onChange={(e) => updateEnding(i, { name: e.target.value })}
/>
@@ -322,8 +324,8 @@ export function EndingsEditor() {
<thead className="bg-surface-2 text-text-muted text-xs uppercase">
<tr>
<th className="px-2 py-1.5 text-left">{t("editor.endings.videoLabel")}</th>
<th className="px-2 py-1.5 text-left">From</th>
<th className="px-2 py-1.5 text-left">To</th>
<th className="px-2 py-1.5 text-left">{t("editor.endings.fromLabel")}</th>
<th className="px-2 py-1.5 text-left">{t("editor.endings.toLabel")}</th>
</tr>
</thead>
<tbody>
@@ -335,6 +337,7 @@ export function EndingsEditor() {
type="number"
min={1}
max={count}
aria-label={t("editor.endings.rangeFromAria", { video: i + 1 })}
value={String(r.from)}
onChange={(e) => updateRange(i, { from: Number(e.target.value) || 1 })}
/>
@@ -344,6 +347,7 @@ export function EndingsEditor() {
type="number"
min={1}
max={count}
aria-label={t("editor.endings.rangeToAria", { video: i + 1 })}
value={String(r.to)}
onChange={(e) => updateRange(i, { to: Number(e.target.value) || 1 })}
/>
+1 -1
View File
@@ -39,7 +39,7 @@ export default function GenreList({
<Command.Input
autoFocus
placeholder={t("editor.genreSearchPlaceholder")}
className="text-text-primary placeholder:text-text-muted h-10 w-full bg-transparent text-sm outline-none"
className="text-text-primary placeholder:text-text-muted h-10 w-full bg-transparent text-sm outline-hidden"
/>
</div>
<Command.List className="max-h-72 scrollbar-thin overflow-y-auto p-1">
+2 -2
View File
@@ -77,14 +77,14 @@ export function GenreSelector() {
{genres.map((id) => (
<span
key={id}
className="bg-accent-muted text-accent inline-flex h-7 items-center gap-1 rounded-full pr-1 pl-2.5 text-xs font-medium"
className="bg-accent-muted text-accent inline-flex h-7 items-center gap-1 rounded-full pr-0.5 pl-2.5 text-xs font-medium"
>
{labelOf(id)}
<button
type="button"
onClick={() => toggle(id)}
aria-label={t("editor.genreRemove", { genre: labelOf(id) })}
className="hover:bg-accent/20 flex size-5 cursor-pointer items-center justify-center rounded-full"
className="hover:bg-accent/20 flex size-6 cursor-pointer items-center justify-center rounded-full pointer-coarse:size-7"
>
<X className="size-3" aria-hidden="true" />
</button>
+1 -1
View File
@@ -55,7 +55,7 @@ export default function GpuList({
<Command.Input
autoFocus
placeholder={t("editor.gpuSearch")}
className="text-text-primary placeholder:text-text-muted h-10 w-full bg-transparent text-sm outline-none"
className="text-text-primary placeholder:text-text-muted h-10 w-full bg-transparent text-sm outline-hidden"
/>
</div>
<Command.List className="max-h-80 scrollbar-thin overflow-y-auto p-1">
+7 -3
View File
@@ -33,6 +33,7 @@ export function LivePreview({
// Without a game name the engine still renders "— Gameplay No Commentary";
// show the prompt instead so nothing half-built can be copied.
const hasGame = useEditorStore((s) => s.gameName.trim() !== "");
const lang = useEditorStore((s) => s.language);
const output = hasGame ? generated : EMPTY_GENERATOR_OUTPUT;
const [tab, setTab] = useState<PreviewTab>("title");
@@ -73,7 +74,7 @@ export function LivePreview({
>
<TabPanel value="title" className="p-4">
{output.title ? (
<p className="text-text-primary text-[0.9375rem] leading-snug font-medium">
<p lang={lang} className="text-text-primary text-[0.9375rem] leading-snug font-medium">
{output.title}
</p>
) : (
@@ -82,7 +83,10 @@ export function LivePreview({
</TabPanel>
<TabPanel value="description" className="p-4">
{output.description ? (
<pre className="text-text-secondary max-h-[min(52dvh,32rem)] scrollbar-thin overflow-y-auto font-sans text-xs leading-relaxed whitespace-pre-wrap">
<pre
lang={lang}
className="text-text-secondary max-h-[min(52dvh,32rem)] scrollbar-thin overflow-y-auto font-sans text-xs leading-relaxed whitespace-pre-wrap"
>
{output.description}
</pre>
) : (
@@ -91,7 +95,7 @@ export function LivePreview({
</TabPanel>
<TabPanel value="tags" className="p-4">
{output.tags.length > 0 ? (
<div className="flex flex-wrap gap-1">
<div lang={lang} className="flex flex-wrap gap-1">
{output.tags.map((tag, i) => (
<span
key={i}
@@ -88,6 +88,7 @@ export function VietnameseDonateEditor() {
/>
{customMode && (
<Input
aria-label={t("editor.vnBankName")}
placeholder={t("editor.vnBankNamePlaceholder")}
value={vnBankName ?? ""}
onChange={(e) => store.set("vnBankName", e.target.value)}
+1 -1
View File
@@ -47,7 +47,7 @@ export function OfflineBanner() {
type="button"
onClick={() => setDismissed(true)}
aria-label={t("common.dismiss")}
className="text-text-muted hover:bg-surface-2 hover:text-text-primary flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors"
className="text-text-muted hover:bg-surface-2 hover:text-text-primary flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors pointer-coarse:size-9"
>
<X className="size-3.5" aria-hidden="true" />
</button>
+8 -2
View File
@@ -36,7 +36,10 @@ export function HistoryCard({ entry }: { entry: HistoryEntry }) {
<Icon className="size-4" aria-hidden />
</span>
<span className="min-w-0 flex-1">
<span className="text-text-primary block truncate text-sm font-medium">
<span
lang={entry.language}
className="text-text-primary block truncate text-sm font-medium"
>
{entry.title}
</span>
<span className="text-text-muted mt-0.5 block truncate text-xs">
@@ -75,7 +78,10 @@ export function HistoryCard({ entry }: { entry: HistoryEntry }) {
<CopyButton text={entry.description} label={t("output.copyDescription")} />
<CopyButton text={entry.tags} label={t("output.copyTags")} />
</div>
<pre className="bg-surface-0 border-border text-text-secondary max-h-56 scrollbar-thin overflow-y-auto rounded-lg border p-2.5 font-sans text-xs leading-relaxed whitespace-pre-wrap">
<pre
lang={entry.language}
className="bg-surface-0 border-border text-text-secondary max-h-56 scrollbar-thin overflow-y-auto rounded-lg border p-2.5 font-sans text-xs leading-relaxed whitespace-pre-wrap"
>
{entry.description}
</pre>
</div>
+3 -1
View File
@@ -5,6 +5,7 @@ import { Header } from "./Header";
import { Sidebar, NavList, NavFooterLinks } from "./Sidebar";
import { MobileNav } from "./MobileNav";
import { ScrollToTopButton } from "./ScrollToTopButton";
import { RouteAnnouncer } from "./RouteAnnouncer";
import { Drawer } from "@components/ui/Drawer";
import { useKeyboardShortcuts, type ShortcutHandlers } from "@hooks/use-keyboard-shortcuts";
import { useGlobalErrorHandler } from "@hooks/use-global-error-handler";
@@ -77,7 +78,7 @@ export function AppShell() {
e.preventDefault();
mainRef.current?.focus();
}}
className="bg-accent text-accent-fg rounded-control sr-only z-[60] px-3 py-2 text-sm font-medium focus:not-sr-only focus:fixed focus:top-2 focus:left-2"
className="bg-accent-solid text-accent-fg rounded-control sr-only z-[60] px-3 py-2 text-sm font-medium focus:not-sr-only focus:fixed focus:top-2 focus:left-2"
>
{t("nav.skipToContent")}
</a>
@@ -96,6 +97,7 @@ export function AppShell() {
<Outlet />
</main>
<ScrollToTopButton scrollRef={mainRef} />
<RouteAnnouncer />
</div>
<MobileNav onOpenMore={() => setMoreOpen(true)} moreActive={moreOpen} />
</div>
+1 -1
View File
@@ -98,7 +98,7 @@ function PaletteBody({
<Command.Input
autoFocus
placeholder={t("command.placeholder")}
className="text-text-primary placeholder:text-text-muted h-12 w-full bg-transparent text-sm outline-none"
className="text-text-primary placeholder:text-text-muted h-12 w-full bg-transparent text-sm outline-hidden"
/>
<Kbd>Esc</Kbd>
</div>
+54
View File
@@ -0,0 +1,54 @@
import { useEffect, useRef, useState } from "react";
import { useLocation } from "react-router-dom";
import { PAGE_TITLE_EVENT } from "@hooks/use-document-title";
/** A navigation whose page never names itself stops waiting after this long. */
const PENDING_MS = 5000;
/**
* Tells screen readers which page a navigation opened. A single-page app
* swaps the content without loading a page, so nothing is announced on its
* own. Focus stays where it was (on the link that was used), so keyboard users
* carry on from there.
*
* Every page names itself through useDocumentTitle, which fires
* PAGE_TITLE_EVENT — after the commit's effects, so a page rendered in the
* same commit as the path change is heard, and a lazy page is heard once its
* chunk arrives and it renders. A title change with no navigation behind it
* (switching the interface language) stays silent.
*/
export function RouteAnnouncer() {
const { pathname } = useLocation();
const [message, setMessage] = useState("");
const pending = useRef(false);
const lastPath = useRef(pathname);
useEffect(() => {
const onTitle = (event: Event) => {
if (!pending.current || !(event instanceof CustomEvent)) return;
if (typeof event.detail !== "string") return;
pending.current = false;
setMessage(event.detail);
};
window.addEventListener(PAGE_TITLE_EVENT, onTitle);
return () => window.removeEventListener(PAGE_TITLE_EVENT, onTitle);
}, []);
useEffect(() => {
// The first page is announced by the browser's own page load (and
// Strict Mode's second run of this effect must not count as a visit).
if (pathname === lastPath.current) return;
lastPath.current = pathname;
pending.current = true;
const timer = window.setTimeout(() => {
pending.current = false;
}, PENDING_MS);
return () => window.clearTimeout(timer);
}, [pathname]);
return (
<div role="status" aria-live="polite" aria-atomic="true" className="sr-only">
{message}
</div>
);
}
+2 -2
View File
@@ -79,14 +79,14 @@ export function LogEntryCard({ entry }: { entry: LogEntryType }) {
label={t("logs.copyEntry")}
size="icon-sm"
onClick={handleCopy}
className="size-7"
className="size-7 pointer-coarse:size-9"
>
<CopyStateIcon copied={copied} className="size-3.5" />
</IconButton>
<IconButton
label={t("logs.deleteEntry")}
size="icon-sm"
className="hover:text-danger size-7"
className="hover:text-danger size-7 pointer-coarse:size-9"
onClick={() => deleteEntry(entry.id)}
>
<Trash2 className="size-3.5" />
+1 -1
View File
@@ -98,7 +98,7 @@ export function OutputExtras() {
icon={MessageSquareText}
actions={<CopyButton text={templateText} label={t("output.copyPinnedCommentTemplate")} />}
>
<OutputText>{templateText}</OutputText>
<OutputText lang={input.language}>{templateText}</OutputText>
</OutputField>
)}
</div>
+14 -2
View File
@@ -24,10 +24,22 @@ export function OutputField({ title, icon: Icon, actions, children }: OutputFiel
);
}
/** Pre-formatted generated text, scrollable when long. */
export function OutputText({ children, tall }: { children: ReactNode; tall?: boolean }) {
/**
* Pre-formatted generated text, scrollable when long. `lang` is the language
* the text was generated in, so a screen reader reads it with that voice.
*/
export function OutputText({
children,
tall,
lang,
}: {
children: ReactNode;
tall?: boolean;
lang?: string;
}) {
return (
<pre
lang={lang}
className={
tall
? "bg-surface-0 border-border text-text-secondary max-h-[60dvh] scrollbar-thin overflow-y-auto rounded-lg border p-3 font-sans text-sm leading-relaxed whitespace-pre-wrap sm:max-h-[28rem]"
+21 -5
View File
@@ -1,12 +1,13 @@
import { useTranslation } from "react-i18next";
import { FileText, Tags, Type } from "lucide-react";
import { useGeneratedOutput } from "@hooks/use-generated-output";
import { useEditorStore } from "@store/editor-store";
import { useSettingsStore } from "@store/settings-store";
import { CopyButton } from "./CopyButton";
import { CharCounter } from "./CharCounter";
import { OutputField, OutputText } from "./OutputField";
import { YT_LIMITS } from "@engine/types";
import type { GeneratorOutput } from "@engine/types";
import type { GeneratorOutput, SupportedLanguage } from "@engine/types";
import type { OutputLimitStatus } from "@engine/limits";
import { useCopyGate } from "@hooks/use-copy-gate";
@@ -16,19 +17,26 @@ interface OutputPreviewProps {
status: OutputLimitStatus;
/** Strict Mode is blocking: nothing can be copied. */
strictBlocked?: boolean;
/** Language of `output` (the draft's output language when omitted). */
lang?: SupportedLanguage;
}
export function OutputPreview({
output: outputProp,
status,
strictBlocked = false,
lang: langProp,
}: OutputPreviewProps) {
const { t } = useTranslation("ui");
const gate = useCopyGate(status, strictBlocked);
const defaultOutput = useGeneratedOutput();
const showCharCount = useSettingsStore((s) => s.showCharCount);
const compactTagDisplay = useSettingsStore((s) => s.compactTagDisplay);
const draftLanguage = useEditorStore((s) => s.language);
const output = outputProp ?? defaultOutput;
// The cards' headings are interface text; only the generated text itself
// carries the output language.
const lang = langProp ?? draftLanguage;
return (
<div className="flex flex-col gap-4">
@@ -48,7 +56,10 @@ export function OutputPreview({
</>
}
>
<p className="bg-surface-0 border-border text-text-primary rounded-lg border p-3 text-[0.9375rem] font-medium">
<p
lang={lang}
className="bg-surface-0 border-border text-text-primary rounded-lg border p-3 text-[0.9375rem] font-medium"
>
{output.title || "…"}
</p>
</OutputField>
@@ -71,7 +82,9 @@ export function OutputPreview({
</>
}
>
<OutputText tall>{output.description || "…"}</OutputText>
<OutputText tall lang={lang}>
{output.description || "…"}
</OutputText>
</OutputField>
<OutputField
@@ -96,11 +109,14 @@ export function OutputPreview({
}
>
{compactTagDisplay ? (
<p className="bg-surface-0 border-border text-text-secondary rounded-lg border p-3 text-xs leading-relaxed">
<p
lang={lang}
className="bg-surface-0 border-border text-text-secondary rounded-lg border p-3 text-xs leading-relaxed"
>
{output.tagString}
</p>
) : (
<div className="flex flex-wrap gap-1.5">
<div lang={lang} className="flex flex-wrap gap-1.5">
{output.tags.map((tag, i) => (
<span
key={i}
+17 -4
View File
@@ -16,6 +16,8 @@ interface YouTubePreviewProps {
description: string;
channelName: string;
gameName: string;
/** Language the title and description were generated in. */
lang?: string;
}
/**
@@ -23,7 +25,13 @@ interface YouTubePreviewProps {
* search result and above the watch page's "…more". Most viewers never see
* anything past those points, so this is where the important words must go.
*/
export function YouTubePreview({ title, description, channelName, gameName }: YouTubePreviewProps) {
export function YouTubePreview({
title,
description,
channelName,
gameName,
lang,
}: YouTubePreviewProps) {
const { t } = useTranslation("ui");
const titleCut = title.length > SEARCH_TITLE_CHARS;
const descriptionCut = description.length > FOLD_DESCRIPTION_CHARS;
@@ -51,18 +59,23 @@ export function YouTubePreview({ title, description, channelName, gameName }: Yo
</span>
</div>
<div className="min-w-0 flex-1">
<p className="text-text-primary line-clamp-2 text-base leading-snug font-semibold">
<p
lang={lang}
className="text-text-primary line-clamp-2 text-base leading-snug font-semibold"
>
{title || "…"}
</p>
<p className="text-text-muted mt-1 text-xs">{channel}</p>
<p className="text-text-muted mt-2 line-clamp-2 text-xs leading-relaxed">{description}</p>
<p lang={lang} className="text-text-muted mt-2 line-clamp-2 text-xs leading-relaxed">
{description}
</p>
</div>
</div>
{/* Watch page, above "…more" */}
<div className="border-border bg-surface-0/60 mx-4 mb-4 rounded-xl border p-3">
<p className="text-text-secondary text-xs leading-relaxed whitespace-pre-line">
{fold || "…"}
<span lang={lang}>{fold || "…"}</span>
{descriptionCut && (
<span className="text-text-primary font-semibold">
{" "}
+1 -1
View File
@@ -58,7 +58,7 @@ export function Banner({
type="button"
onClick={onDismiss}
aria-label={dismissLabel}
className="-m-1 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md opacity-70 hover:opacity-100"
className="-m-1 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md opacity-70 hover:opacity-100 pointer-coarse:size-9"
>
<X className="size-3.5" aria-hidden="true" />
</button>
+2 -2
View File
@@ -17,13 +17,13 @@ export interface ButtonProps extends ComponentProps<"button"> {
}
const VARIANTS: Record<ButtonVariant, string> = {
primary: "bg-accent text-accent-fg shadow-sm hover:bg-accent-hover",
primary: "bg-accent-solid text-accent-fg shadow-sm hover:bg-accent-solid-hover",
brand: "bg-brand-gradient text-white shadow-sm hover:brightness-110",
secondary:
"border border-border bg-surface-2 text-text-primary hover:border-border-strong hover:bg-surface-3",
outline: "border border-border text-text-primary hover:bg-surface-2",
ghost: "text-text-secondary hover:bg-surface-2 hover:text-text-primary",
danger: "bg-danger text-white shadow-sm hover:brightness-110",
danger: "bg-danger-solid text-white shadow-sm hover:bg-danger-solid-hover",
};
const SIZES: Record<ButtonSize, string> = {
+1 -1
View File
@@ -63,7 +63,7 @@ export function Drawer({
{title}
</Dialog.Title>
<Dialog.Close
className="text-text-muted hover:bg-surface-2 hover:text-text-primary flex size-8 cursor-pointer items-center justify-center rounded-lg"
className="text-text-muted hover:bg-surface-2 hover:text-text-primary flex size-8 cursor-pointer items-center justify-center rounded-lg pointer-coarse:size-10"
aria-label={t("common.close")}
>
<X className="size-4" aria-hidden="true" />
+3 -1
View File
@@ -68,7 +68,9 @@ export const controlClasses = (invalid: boolean) =>
clsx(
"w-full min-w-0 rounded-control border bg-surface-1 px-3 text-text-primary",
"placeholder:text-text-muted transition-[border-color,box-shadow] duration-150",
"focus:outline-none focus-visible:outline-none focus:ring-3 focus:ring-accent/25",
// `outline-hidden`, not `outline-none`: Windows High Contrast drops the
// ring, and this keeps a transparent outline there that it paints instead.
"focus:outline-hidden focus-visible:outline-hidden focus:ring-3 focus:ring-accent/25",
"disabled:cursor-not-allowed disabled:opacity-55",
invalid
? "border-danger focus:border-danger"
+1 -1
View File
@@ -80,7 +80,7 @@ export function Modal({
)}
</div>
<Dialog.Close
className="text-text-muted hover:bg-surface-2 hover:text-text-primary -m-1.5 flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors"
className="text-text-muted hover:bg-surface-2 hover:text-text-primary -m-1.5 flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors pointer-coarse:size-10"
aria-label={t("common.close")}
>
<X className="size-4" aria-hidden="true" />
+10 -4
View File
@@ -1,6 +1,7 @@
import { useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { Search } from "lucide-react";
import { useSettingsStore } from "@store/settings-store";
import { Modal } from "./Modal";
import { ShortcutKeys, keyName } from "./Badge";
@@ -16,6 +17,8 @@ const SHORTCUTS = [
{ keys: ["mod", "shift", "C"], labelKey: "shortcuts.copyAll" },
{ keys: ["mod", "S"], labelKey: "shortcuts.saveToHistory" },
{ keys: ["mod", "B"], labelKey: "shortcuts.toggleSidebar" },
// sonner's hotkey: focuses the notifications while any are on screen.
{ keys: ["alt", "T"], labelKey: "shortcuts.notifications" },
{ keys: ["mod", "/"], labelKey: "shortcuts.help" },
{ keys: ["?"], labelKey: "shortcuts.help" },
{ keys: ["esc"], labelKey: "shortcuts.close" },
@@ -24,6 +27,7 @@ const SHORTCUTS = [
export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
const { t } = useTranslation("ui");
const [query, setQuery] = useState("");
const singleKey = useSettingsStore((s) => s.singleKeyShortcuts);
// The search box gets focus when the modal opens (through Radix, not an
// `autoFocus` attribute).
const searchRef = useRef<HTMLInputElement>(null);
@@ -34,14 +38,16 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
const activeQuery = open ? query : "";
const filtered = useMemo(() => {
// The bare `?` row goes when Settings turned single-key shortcuts off.
const available = singleKey ? SHORTCUTS : SHORTCUTS.filter((s) => s.keys[0] !== "?");
const trimmed = activeQuery.trim().toLowerCase();
if (!trimmed) return SHORTCUTS;
return SHORTCUTS.filter((s) => {
if (!trimmed) return available;
return available.filter((s) => {
const label = t(s.labelKey).toLowerCase();
const keys = s.keys.map(keyName).join(" ").toLowerCase();
return label.includes(trimmed) || keys.includes(trimmed);
});
}, [activeQuery, t]);
}, [activeQuery, singleKey, t]);
return (
<Modal
@@ -61,7 +67,7 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
onChange={(e) => setQuery(e.target.value)}
placeholder={t("shortcuts.searchPlaceholder")}
aria-label={t("shortcuts.searchPlaceholder")}
className="text-text-primary placeholder:text-text-muted w-full bg-transparent text-sm outline-none"
className="text-text-primary placeholder:text-text-muted w-full bg-transparent text-sm outline-hidden"
/>
</label>
{filtered.length === 0 ? (
+6 -1
View File
@@ -1,3 +1,4 @@
import { useTranslation } from "react-i18next";
import { Toaster as Sonner } from "sonner";
import { useSettingsStore } from "@store/settings-store";
@@ -8,21 +9,25 @@ import { useSettingsStore } from "@store/settings-store";
* floating elements.
*/
export function Toaster() {
const { t } = useTranslation("ui");
const theme = useSettingsStore((s) => s.theme);
return (
<Sonner
theme={theme}
position="bottom-center"
closeButton
// sonner's own labels are English ("Notifications alt+T", "Close toast").
customAriaLabel={t("common.notificationsRegion")}
// globals.css switches this at the md breakpoint, where the bar goes.
offset={{ bottom: "var(--toast-offset-bottom)" }}
mobileOffset={{ bottom: "var(--toast-offset-bottom)" }}
toastOptions={{
closeButtonAriaLabel: t("common.closeNotification"),
classNames: {
toast:
"!bg-surface-1 !border-border !text-text-primary !rounded-card !shadow-pop !font-sans",
description: "!text-text-secondary",
actionButton: "!bg-accent !text-accent-fg !rounded-lg !font-medium",
actionButton: "!bg-accent-solid !text-accent-fg !rounded-lg !font-medium",
cancelButton: "!bg-surface-2 !text-text-secondary !rounded-lg",
closeButton: "!bg-surface-2 !border-border !text-text-secondary",
},
+12
View File
@@ -1,5 +1,12 @@
import { useEffect } from "react";
/**
* Fired on `window` (detail: the page name) whenever a page sets its title.
* RouteAnnouncer reads it out after a navigation; restoring the previous title
* on unmount does not fire it, so a page being left is never announced.
*/
export const PAGE_TITLE_EVENT = "ytdescgen:page-title";
/**
* Sets `document.title` to `"<title> · YTDescGen"` for the lifetime of the
* component, and restores the previous title on unmount. Per-page titles
@@ -12,6 +19,11 @@ export function useDocumentTitle(title: string): void {
useEffect(() => {
const previous = document.title;
document.title = `${title} · YTDescGen`;
// A microtask, so listeners hear it after every effect of this commit has
// run — RouteAnnouncer marks the navigation in one of them.
queueMicrotask(() => {
window.dispatchEvent(new CustomEvent(PAGE_TITLE_EVENT, { detail: title }));
});
return () => {
document.title = previous;
};
+5 -1
View File
@@ -1,5 +1,6 @@
import { useEffect, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { useSettingsStore } from "@store/settings-store";
import { useOutputCopy } from "./use-output-copy";
import { useSaveToHistory } from "./use-save-to-history";
@@ -60,9 +61,12 @@ export function useKeyboardShortcuts(handlers: ShortcutHandlers) {
} else if (
// Bare `?` (Shift+/) opens the cheatsheet too. Skip when the
// user is typing into a form field — `?` is a legitimate
// character in titles, descriptions, and other inputs.
// character in titles, descriptions, and other inputs — and when
// Settings › Editor turned single-key shortcuts off (WCAG 2.1.4:
// speech input says "question mark" and opens a dialog otherwise).
e.key === "?" &&
!mod &&
useSettingsStore.getState().singleKeyShortcuts &&
!isEditableTarget(e.target)
) {
e.preventDefault();
+4 -4
View File
@@ -318,7 +318,7 @@
"editor.endings": [
"countLabel",
"videoCountLabel",
"videoLabel",
"videoLabel", "fromLabel", "toLabel", "rowNumberAria", "rowNameAria", "rangeFromAria", "rangeToAria",
"numberLabel",
"nameLabel",
"namePlaceholder",
@@ -740,7 +740,7 @@
"scrollToTop",
"exported",
"exportFailed",
"close",
"close", "notificationsRegion", "closeNotification",
"edit",
"loading"
],
@@ -967,7 +967,7 @@
"genrePlaylistsBadge",
"numberRange",
"themeDark",
"themeLight", "titleOrder", "titleOrderGameFirst", "titleOrderTypeFirst", "copyAllIncludesTags", "copyAllIncludesTagsHint", "hideScrollbars", "hideScrollbarsHint"
"themeLight", "titleOrder", "titleOrderGameFirst", "titleOrderTypeFirst", "copyAllIncludesTags", "copyAllIncludesTagsHint", "hideScrollbars", "hideScrollbarsHint", "singleKeyShortcuts", "singleKeyShortcutsHint"
],
"batch": [
"title",
@@ -1005,7 +1005,7 @@
"help",
"close",
"searchPlaceholder",
"noResults", "saveToHistory"
"noResults", "saveToHistory", "notifications"
],
"validation": [
"emailInvalid",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "Number of endings",
"videoCountLabel": "Number of videos",
"videoLabel": "Video",
"fromLabel": "From",
"toLabel": "To",
"rowNumberAria": "Ending {{row}}: number",
"rowNameAria": "Ending {{row}}: name",
"rangeFromAria": "Video {{video}}: from ending",
"rangeToAria": "Video {{video}}: to ending",
"numberLabel": "Number",
"nameLabel": "Name",
"namePlaceholder": "e.g. Best Ending",
@@ -880,6 +886,8 @@
"exported": "Exported",
"exportFailed": "Export failed",
"close": "Close",
"notificationsRegion": "Notifications (Alt+T)",
"closeNotification": "Close notification",
"edit": "Edit",
"loading": "Loading…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "Copy All includes the tags",
"copyAllIncludesTagsHint": "Title, description, then the tags — for pasting everything into a notes app in one go.",
"hideScrollbars": "Hide scrollbars",
"hideScrollbarsHint": "Removes every scrollbar in the app — the mouse wheel, touchpad, touch and keyboard still scroll."
"hideScrollbarsHint": "Removes every scrollbar in the app — the mouse wheel, touchpad, touch and keyboard still scroll.",
"singleKeyShortcuts": "Single-key shortcuts",
"singleKeyShortcutsHint": "? opens the shortcut list when you're not typing in a field. Turn this off if you use speech input or press keys by accident — Ctrl/⌘ + / still works."
},
"socialPost": {
"title": "Cross-Post Captions",
@@ -1226,7 +1236,8 @@
"close": "Close Modal",
"searchPlaceholder": "Search shortcuts",
"noResults": "No matching shortcuts",
"saveToHistory": "Save to History"
"saveToHistory": "Save to History",
"notifications": "Go to notifications"
},
"validation": {
"numberRequired": "Enter a number.",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "Número de finales",
"videoCountLabel": "Número de videos",
"videoLabel": "Video",
"fromLabel": "Desde",
"toLabel": "Hasta",
"rowNumberAria": "Final {{row}}: número",
"rowNameAria": "Final {{row}}: nombre",
"rangeFromAria": "Video {{video}}: desde el final",
"rangeToAria": "Video {{video}}: hasta el final",
"numberLabel": "Número",
"nameLabel": "Nombre",
"namePlaceholder": "ej. Mejor Final",
@@ -880,6 +886,8 @@
"exported": "Exportado",
"exportFailed": "Error al exportar",
"close": "Cerrar",
"notificationsRegion": "Notificaciones (Alt+T)",
"closeNotification": "Cerrar notificación",
"edit": "Editar",
"loading": "Cargando…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "Copiar todo incluye las etiquetas",
"copyAllIncludesTagsHint": "Título, descripción y luego las etiquetas, para pegarlo todo de una vez en una app de notas.",
"hideScrollbars": "Ocultar barras de desplazamiento",
"hideScrollbarsHint": "Quita todas las barras de desplazamiento de la app; la rueda del ratón, el touchpad, la pantalla táctil y el teclado siguen desplazando."
"hideScrollbarsHint": "Quita todas las barras de desplazamiento de la app; la rueda del ratón, el touchpad, la pantalla táctil y el teclado siguen desplazando.",
"singleKeyShortcuts": "Atajos de una tecla",
"singleKeyShortcutsHint": "? abre la lista de atajos cuando no estás escribiendo en un campo. Desactívalo si usas entrada por voz o pulsas teclas sin querer; Ctrl/⌘ + / sigue funcionando."
},
"socialPost": {
"title": "Publicaciones multiplataforma",
@@ -1226,7 +1236,8 @@
"close": "Cerrar",
"searchPlaceholder": "Buscar atajos",
"noResults": "No se encontraron atajos",
"saveToHistory": "Guardar en el historial"
"saveToHistory": "Guardar en el historial",
"notifications": "Ir a las notificaciones"
},
"validation": {
"numberRequired": "Introduce un número.",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "Jumlah ending",
"videoCountLabel": "Jumlah video",
"videoLabel": "Video",
"fromLabel": "Dari",
"toLabel": "Sampai",
"rowNumberAria": "Ending {{row}}: nomor",
"rowNameAria": "Ending {{row}}: nama",
"rangeFromAria": "Video {{video}}: dari ending",
"rangeToAria": "Video {{video}}: sampai ending",
"numberLabel": "Nomor",
"nameLabel": "Nama",
"namePlaceholder": "mis. Ending Terbaik",
@@ -880,6 +886,8 @@
"exported": "Diekspor",
"exportFailed": "Ekspor gagal",
"close": "Tutup",
"notificationsRegion": "Notifikasi (Alt+T)",
"closeNotification": "Tutup notifikasi",
"edit": "Edit",
"loading": "Memuat…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "Salin semua termasuk tag",
"copyAllIncludesTagsHint": "Judul, deskripsi, lalu tag — untuk menempel semuanya sekaligus ke aplikasi catatan.",
"hideScrollbars": "Sembunyikan scrollbar",
"hideScrollbarsHint": "Menyembunyikan semua scrollbar di aplikasi — roda mouse, touchpad, sentuhan, dan keyboard tetap bisa menggulir."
"hideScrollbarsHint": "Menyembunyikan semua scrollbar di aplikasi — roda mouse, touchpad, sentuhan, dan keyboard tetap bisa menggulir.",
"singleKeyShortcuts": "Pintasan satu tombol",
"singleKeyShortcutsHint": "? membuka daftar pintasan saat Anda tidak sedang mengetik di kolom. Matikan jika Anda memakai input suara atau sering salah tekan — Ctrl/⌘ + / tetap berfungsi."
},
"socialPost": {
"title": "Caption Lintas Platform",
@@ -1226,7 +1236,8 @@
"close": "Tutup Modal",
"searchPlaceholder": "Cari pintasan",
"noResults": "Tidak ada pintasan yang cocok",
"saveToHistory": "Simpan ke Riwayat"
"saveToHistory": "Simpan ke Riwayat",
"notifications": "Ke notifikasi"
},
"validation": {
"numberRequired": "Masukkan angka.",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "エンディング数",
"videoCountLabel": "動画数",
"videoLabel": "動画",
"fromLabel": "開始",
"toLabel": "終了",
"rowNumberAria": "エンディング {{row}}: 番号",
"rowNameAria": "エンディング {{row}}: 名前",
"rangeFromAria": "動画 {{video}}: 開始エンディング",
"rangeToAria": "動画 {{video}}: 終了エンディング",
"numberLabel": "番号",
"nameLabel": "名前",
"namePlaceholder": "例: ベストエンド",
@@ -880,6 +886,8 @@
"exported": "エクスポートしました",
"exportFailed": "エクスポートに失敗しました",
"close": "閉じる",
"notificationsRegion": "通知 (Alt+T)",
"closeNotification": "通知を閉じる",
"edit": "編集",
"loading": "読み込み中…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "「すべてコピー」にタグも含める",
"copyAllIncludesTagsHint": "タイトル、説明、タグの順。メモアプリにまとめて貼り付けるときに。",
"hideScrollbars": "スクロールバーを隠す",
"hideScrollbarsHint": "アプリ内のすべてのスクロールバーを非表示にします。マウスホイール、タッチパッド、タッチ操作、キーボードでのスクロールはそのまま使えます。"
"hideScrollbarsHint": "アプリ内のすべてのスクロールバーを非表示にします。マウスホイール、タッチパッド、タッチ操作、キーボードでのスクロールはそのまま使えます。",
"singleKeyShortcuts": "1 キーのショートカット",
"singleKeyShortcutsHint": "入力欄の外で ? を押すとショートカット一覧が開きます。音声入力を使う場合や誤って押してしまう場合はオフにしてください。Ctrl/⌘ + / は引き続き使えます。"
},
"socialPost": {
"title": "クロス投稿キャプション",
@@ -1226,7 +1236,8 @@
"close": "モーダルを閉じる",
"searchPlaceholder": "ショートカットを検索",
"noResults": "該当するショートカットはありません",
"saveToHistory": "履歴に保存"
"saveToHistory": "履歴に保存",
"notifications": "通知へ移動"
},
"validation": {
"numberRequired": "数値を入力してください。",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "엔딩 개수",
"videoCountLabel": "영상 개수",
"videoLabel": "영상",
"fromLabel": "시작",
"toLabel": "끝",
"rowNumberAria": "엔딩 {{row}}: 번호",
"rowNameAria": "엔딩 {{row}}: 이름",
"rangeFromAria": "영상 {{video}}: 시작 엔딩",
"rangeToAria": "영상 {{video}}: 끝 엔딩",
"numberLabel": "번호",
"nameLabel": "이름",
"namePlaceholder": "예: 베스트 엔딩",
@@ -880,6 +886,8 @@
"exported": "내보냈습니다",
"exportFailed": "내보내기 실패",
"close": "닫기",
"notificationsRegion": "알림 (Alt+T)",
"closeNotification": "알림 닫기",
"edit": "편집",
"loading": "불러오는 중…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "모두 복사에 태그 포함",
"copyAllIncludesTagsHint": "제목, 설명, 태그 순서로 — 메모 앱에 한 번에 붙여넣을 때 좋습니다.",
"hideScrollbars": "스크롤바 숨기기",
"hideScrollbarsHint": "앱의 모든 스크롤바를 숨깁니다. 마우스 휠, 터치패드, 터치, 키보드로는 계속 스크롤할 수 있습니다."
"hideScrollbarsHint": "앱의 모든 스크롤바를 숨깁니다. 마우스 휠, 터치패드, 터치, 키보드로는 계속 스크롤할 수 있습니다.",
"singleKeyShortcuts": "단일 키 단축키",
"singleKeyShortcutsHint": "입력란 밖에서 ?를 누르면 단축키 목록이 열립니다. 음성 입력을 사용하거나 실수로 키를 누르는 경우 끄세요. Ctrl/⌘ + /는 계속 작동합니다."
},
"socialPost": {
"title": "크로스포스트 캡션",
@@ -1226,7 +1236,8 @@
"close": "닫기",
"searchPlaceholder": "단축키 검색",
"noResults": "일치하는 단축키 없음",
"saveToHistory": "기록에 저장"
"saveToHistory": "기록에 저장",
"notifications": "알림으로 이동"
},
"validation": {
"numberRequired": "숫자를 입력하세요.",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "Número de finais",
"videoCountLabel": "Número de vídeos",
"videoLabel": "Vídeo",
"fromLabel": "De",
"toLabel": "Até",
"rowNumberAria": "Final {{row}}: número",
"rowNameAria": "Final {{row}}: nome",
"rangeFromAria": "Vídeo {{video}}: do final",
"rangeToAria": "Vídeo {{video}}: até o final",
"numberLabel": "Número",
"nameLabel": "Nome",
"namePlaceholder": "ex.: Melhor final",
@@ -880,6 +886,8 @@
"exported": "Exportado",
"exportFailed": "Falha ao exportar",
"close": "Fechar",
"notificationsRegion": "Notificações (Alt+T)",
"closeNotification": "Fechar notificação",
"edit": "Editar",
"loading": "Carregando…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "Copiar tudo inclui as tags",
"copyAllIncludesTagsHint": "Título, descrição e depois as tags — para colar tudo de uma vez num app de notas.",
"hideScrollbars": "Ocultar barras de rolagem",
"hideScrollbarsHint": "Remove todas as barras de rolagem do app — a roda do mouse, o touchpad, o toque e o teclado continuam rolando."
"hideScrollbarsHint": "Remove todas as barras de rolagem do app — a roda do mouse, o touchpad, o toque e o teclado continuam rolando.",
"singleKeyShortcuts": "Atalhos de uma tecla",
"singleKeyShortcutsHint": "? abre a lista de atalhos quando você não está digitando em um campo. Desative se usa entrada por voz ou aperta teclas sem querer — Ctrl/⌘ + / continua funcionando."
},
"socialPost": {
"title": "Legendas para outras redes",
@@ -1226,7 +1236,8 @@
"close": "Fechar modal",
"searchPlaceholder": "Buscar atalhos",
"noResults": "Nenhum atalho encontrado",
"saveToHistory": "Salvar no histórico"
"saveToHistory": "Salvar no histórico",
"notifications": "Ir para as notificações"
},
"validation": {
"numberRequired": "Digite um número.",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "Số lượng ending",
"videoCountLabel": "Số video",
"videoLabel": "Video",
"fromLabel": "Từ",
"toLabel": "Đến",
"rowNumberAria": "Ending {{row}}: số",
"rowNameAria": "Ending {{row}}: tên",
"rangeFromAria": "Video {{video}}: từ ending",
"rangeToAria": "Video {{video}}: đến ending",
"numberLabel": "Số",
"nameLabel": "Tên",
"namePlaceholder": "ví dụ: Best Ending",
@@ -880,6 +886,8 @@
"exported": "Đã xuất",
"exportFailed": "Xuất thất bại",
"close": "Đóng",
"notificationsRegion": "Thông báo (Alt+T)",
"closeNotification": "Đóng thông báo",
"edit": "Sửa",
"loading": "Đang tải…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "Sao chép tất cả kèm cả tag",
"copyAllIncludesTagsHint": "Tiêu đề, mô tả, rồi đến tag — để dán tất cả vào ứng dụng ghi chú một lần.",
"hideScrollbars": "Ẩn thanh cuộn",
"hideScrollbarsHint": "Ẩn mọi thanh cuộn trong ứng dụng — vẫn cuộn được bằng con lăn chuột, touchpad, cảm ứng và bàn phím."
"hideScrollbarsHint": "Ẩn mọi thanh cuộn trong ứng dụng — vẫn cuộn được bằng con lăn chuột, touchpad, cảm ứng và bàn phím.",
"singleKeyShortcuts": "Phím tắt một phím",
"singleKeyShortcutsHint": "Phím ? mở danh sách phím tắt khi bạn không gõ trong ô nhập. Tắt đi nếu bạn nhập bằng giọng nói hoặc hay bấm nhầm phím — Ctrl/⌘ + / vẫn hoạt động."
},
"socialPost": {
"title": "Bài đăng đa nền tảng",
@@ -1226,7 +1236,8 @@
"close": "Đóng",
"searchPlaceholder": "Tìm phím tắt",
"noResults": "Không có phím tắt phù hợp",
"saveToHistory": "Lưu vào lịch sử"
"saveToHistory": "Lưu vào lịch sử",
"notifications": "Đi tới thông báo"
},
"validation": {
"numberRequired": "Hãy nhập một số.",
+13 -2
View File
@@ -670,6 +670,12 @@
"countLabel": "结局数量",
"videoCountLabel": "视频数量",
"videoLabel": "视频",
"fromLabel": "从",
"toLabel": "到",
"rowNumberAria": "结局 {{row}}:编号",
"rowNameAria": "结局 {{row}}:名称",
"rangeFromAria": "视频 {{video}}:起始结局",
"rangeToAria": "视频 {{video}}:结束结局",
"numberLabel": "编号",
"nameLabel": "名称",
"namePlaceholder": "如:最佳结局",
@@ -880,6 +886,8 @@
"exported": "已导出",
"exportFailed": "导出失败",
"close": "关闭",
"notificationsRegion": "通知 (Alt+T)",
"closeNotification": "关闭通知",
"edit": "编辑",
"loading": "加载中…"
},
@@ -1179,7 +1187,9 @@
"copyAllIncludesTags": "“全部复制”包含标签",
"copyAllIncludesTagsHint": "依次为标题、描述、标签 —— 方便一次性粘贴到笔记应用。",
"hideScrollbars": "隐藏滚动条",
"hideScrollbarsHint": "隐藏应用中的所有滚动条 —— 鼠标滚轮、触控板、触摸和键盘仍可滚动。"
"hideScrollbarsHint": "隐藏应用中的所有滚动条 —— 鼠标滚轮、触控板、触摸和键盘仍可滚动。",
"singleKeyShortcuts": "单键快捷键",
"singleKeyShortcutsHint": "不在输入框中输入时,按 ? 打开快捷键列表。如果使用语音输入或容易误触按键,请关闭此项;Ctrl/⌘ + / 仍然可用。"
},
"socialPost": {
"title": "跨平台文案",
@@ -1226,7 +1236,8 @@
"close": "关闭",
"searchPlaceholder": "搜索快捷键",
"noResults": "未找到快捷键",
"saveToHistory": "保存到历史"
"saveToHistory": "保存到历史",
"notifications": "跳转到通知"
},
"validation": {
"numberRequired": "请输入一个数字。",
+8 -2
View File
@@ -279,10 +279,16 @@ export function BatchPage() {
/>
</div>
</div>
<p className="text-text-primary mb-2 text-sm font-medium">
<p
lang={lang.language}
className="text-text-primary mb-2 text-sm font-medium"
>
{lang.output.title}
</p>
<pre className="text-text-secondary mb-2 line-clamp-3 font-sans text-xs whitespace-pre-wrap">
<pre
lang={lang.language}
className="text-text-secondary mb-2 line-clamp-3 font-sans text-xs whitespace-pre-wrap"
>
{lang.output.description}
</pre>
{/* Batch showed a counter for the title only, so a row
+2
View File
@@ -244,6 +244,7 @@ export function OutputPage() {
{multilangOutputs[lang] && (
<OutputPreview
output={multilangOutputs[lang]}
lang={lang}
status={tabStatus}
strictBlocked={strictBlocked}
/>
@@ -258,6 +259,7 @@ export function OutputPage() {
<YouTubePreview
title={shownOutput.title}
description={shownOutput.description}
lang={isMultiLang ? activeTab : language}
channelName={channelName}
gameName={gameName}
/>
+13 -2
View File
@@ -80,11 +80,14 @@ function OutputBlock({
text,
copyLabel,
multiline,
lang,
}: {
label: string;
text: string;
copyLabel: string;
multiline?: boolean;
/** Language the text was generated in. */
lang: string;
}) {
return (
<section className="flex flex-col gap-1.5">
@@ -93,11 +96,16 @@ function OutputBlock({
<CopyButton text={text} label={copyLabel} />
</div>
{multiline ? (
<pre className="bg-surface-0 border-border text-text-secondary max-h-64 scrollbar-thin overflow-y-auto rounded-lg border p-2.5 font-sans text-xs leading-relaxed whitespace-pre-wrap">
<pre
lang={lang}
className="bg-surface-0 border-border text-text-secondary max-h-64 scrollbar-thin overflow-y-auto rounded-lg border p-2.5 font-sans text-xs leading-relaxed whitespace-pre-wrap"
>
{text || "…"}
</pre>
) : (
<p className="text-text-primary text-sm font-medium">{text || "…"}</p>
<p lang={lang} className="text-text-primary text-sm font-medium">
{text || "…"}
</p>
)}
</section>
);
@@ -270,18 +278,21 @@ export function PlaylistPage() {
label={t("output.title")}
text={output.title}
copyLabel={t("output.copyTitle")}
lang={language}
/>
<OutputBlock
label={t("output.description")}
text={output.description}
copyLabel={t("output.copyDescription")}
multiline
lang={language}
/>
<OutputBlock
label={t("playlist.pinnedComment")}
text={output.comment}
copyLabel={t("output.copyComment")}
multiline
lang={language}
/>
<Button
disabled={!output.title}
+6
View File
@@ -184,6 +184,12 @@ export function SettingsPage() {
checked={settings.copyAllIncludesTags}
onChange={(v) => settings.setSetting("copyAllIncludesTags", v)}
/>
<Toggle
label={t("settings.singleKeyShortcuts")}
description={t("settings.singleKeyShortcutsHint")}
checked={settings.singleKeyShortcuts}
onChange={(v) => settings.setSetting("singleKeyShortcuts", v)}
/>
</Accordion>
{/* Strict Mode is off by default: the app's whole premise is getting a
+9 -3
View File
@@ -317,7 +317,7 @@ export function SocialPage() {
{t("socialPost.trimmedHint", { count: activePost.droppedBlocks.length })}
</Banner>
)}
<OutputText>{activePost.text}</OutputText>
<OutputText lang={baseInput.language}>{activePost.text}</OutputText>
</div>
</OutputField>
)
@@ -348,7 +348,10 @@ export function SocialPage() {
limit={p.charLimit}
/>
</div>
<pre className="text-text-secondary font-sans text-xs break-words whitespace-pre-wrap">
<pre
lang={imported.language}
className="text-text-secondary font-sans text-xs break-words whitespace-pre-wrap"
>
{p.text}
</pre>
</div>
@@ -461,7 +464,10 @@ export function SocialPage() {
/>
</div>
</div>
<pre className="text-text-secondary max-h-24 scrollbar-thin overflow-y-auto font-sans text-xs break-words whitespace-pre-wrap">
<pre
lang={row.language}
className="text-text-secondary max-h-24 scrollbar-thin overflow-y-auto font-sans text-xs break-words whitespace-pre-wrap"
>
{post.text}
</pre>
</div>
+11
View File
@@ -22,6 +22,12 @@ export interface SettingsData {
* App's store subscription afterwards. Travels with backups, like `theme`.
*/
hideScrollbars: boolean;
/**
* v1.5.1: the bare `?` shortcut (the shortcut list). On by default; off
* leaves only Ctrl/⌘ + /, for speech input and stray key presses
* (WCAG 2.1.4). Travels with backups.
*/
singleKeyShortcuts: boolean;
showCharCount: boolean;
compactTagDisplay: boolean;
historyLimit: number;
@@ -185,6 +191,7 @@ export const initialSettings: SettingsData = {
defaultOutputLanguage: detectBrowserLanguage(),
theme: "dark",
hideScrollbars: false,
singleKeyShortcuts: true,
showCharCount: true,
compactTagDisplay: false,
historyLimit: 100,
@@ -351,6 +358,10 @@ export function healSettings(raw: unknown): SettingsData {
if (typeof incoming.hideScrollbars !== "boolean") {
incoming.hideScrollbars = initialSettings.hideScrollbars;
}
// v1.5.1: anything but a boolean keeps the shortcut on (the default).
if (typeof incoming.singleKeyShortcuts !== "boolean") {
incoming.singleKeyShortcuts = initialSettings.singleKeyShortcuts;
}
return { ...initialSettings, ...incoming } as SettingsData;
}
+3 -1
View File
@@ -104,7 +104,8 @@ export const useSettingsStore = create<SettingsState>()(
// on by a truthy string), and the accordion map is merged rather than
// replaced so sections added later still get their default.
// Later additive keys — v1.0.0's `copyAllIncludesTags`,
// `lastProfileId`, `lastPresetId` and v1.1.0's `hideScrollbars` — ride
// `lastProfileId`, `lastPresetId`, v1.1.0's `hideScrollbars` and v1.5.1's
// `singleKeyShortcuts` — ride
// the same back-fill and coercion without a bump, which also keeps a
// backup made by the newer build readable to the one before it.
version: SETTINGS_STORE_VERSION,
@@ -136,6 +137,7 @@ export function extractData(state: SettingsData): SettingsData {
defaultOutputLanguage: state.defaultOutputLanguage,
theme: state.theme,
hideScrollbars: state.hideScrollbars,
singleKeyShortcuts: state.singleKeyShortcuts,
showCharCount: state.showCharCount,
compactTagDisplay: state.compactTagDisplay,
historyLimit: state.historyLimit,
+29 -9
View File
@@ -34,12 +34,16 @@
--color-accent-hover: var(--accent-hover);
--color-accent-muted: var(--accent-muted);
--color-accent-fg: var(--accent-fg);
--color-accent-solid: var(--accent-solid);
--color-accent-solid-hover: var(--accent-solid-hover);
--color-brand-from: var(--brand-from);
--color-brand-to: var(--brand-to);
--color-success: var(--success);
--color-warning: var(--warning);
--color-danger: var(--danger);
--color-danger-solid: var(--danger-solid);
--color-danger-solid-hover: var(--danger-solid-hover);
--color-info: var(--info);
--color-donate: var(--donate);
@@ -114,20 +118,32 @@
--border: #25252f;
--border-strong: #363644;
/*
* Text and status colours keep WCAG AA (4.5:1) on every surface they sit
* on, and white keeps 4.5:1 on the *-solid fills that carry text (buttons).
* tests/styles/contrast.test.ts checks both themes — change a value here
* and it tells you whether the pair still passes.
*/
--text-primary: #ececf3;
--text-secondary: #a4a4b8;
--text-muted: #72728a;
--text-muted: #8a8aa1;
--accent: #7b6ef6;
--accent-hover: #9387f8;
--accent-muted: rgba(123, 110, 246, 0.16);
/* `accent` is text, outlines and small marks; filled controls with text on
them use `accent-solid`, which is darker so white stays readable. */
--accent: #8b80f8;
--accent-hover: #9d94f9;
--accent-muted: rgba(139, 128, 248, 0.16);
--accent-fg: #ffffff;
--accent-solid: #6557ee;
--accent-solid-hover: #5a4ce8;
--brand-from: #6366f1;
--brand-to: #a855f7;
--success: #34d399;
--warning: #fbbf24;
--danger: #f87171;
--danger-solid: #dc2626;
--danger-solid-hover: #b91c1c;
--info: #60a5fa;
--donate: #f472b6;
@@ -157,18 +173,22 @@
--text-primary: #15151d;
--text-secondary: #4a4a5c;
--text-muted: #7c7c90;
--text-muted: #66667a;
--accent: #5b4fe6;
--accent-hover: #6d62ee;
--accent-muted: rgba(91, 79, 230, 0.1);
--accent-fg: #ffffff;
--accent-solid: #5b4fe6;
--accent-solid-hover: #5246d8;
--success: #059669;
--warning: #b45309;
--danger: #dc2626;
--success: #047857;
--warning: #a3480a;
--danger: #c81e1e;
--danger-solid: #dc2626;
--danger-solid-hover: #b91c1c;
--info: #2563eb;
--donate: #db2777;
--donate: #be185d;
--shadow-card-value: 0 1px 2px rgba(20, 20, 40, 0.04), 0 8px 24px -18px rgba(20, 20, 40, 0.25);
--shadow-pop-value: 0 24px 60px -24px rgba(20, 20, 40, 0.35), 0 0 0 1px rgba(20, 20, 40, 0.06);
+19
View File
@@ -67,6 +67,7 @@ describe("healSettings", () => {
defaultOutputLanguage: "en" as const,
theme: "light" as const,
hideScrollbars: true,
singleKeyShortcuts: false,
showCharCount: false,
compactTagDisplay: true,
historyLimit: 50,
@@ -340,3 +341,21 @@ describe("healSettings — v1.1.0 hideScrollbars", () => {
expect(healSettings({ hideScrollbars: 1 }).hideScrollbars).toBe(false);
});
});
describe("healSettings — v1.5.1 singleKeyShortcuts", () => {
it("keeps the bare ? shortcut on when absent (older settings and backups)", () => {
expect(healSettings({ theme: "dark" }).singleKeyShortcuts).toBe(true);
expect(healSettings(null).singleKeyShortcuts).toBe(true);
});
it("keeps a real boolean", () => {
expect(healSettings({ singleKeyShortcuts: false }).singleKeyShortcuts).toBe(false);
expect(healSettings({ singleKeyShortcuts: true }).singleKeyShortcuts).toBe(true);
});
it("falls back to on for anything that is not a boolean", () => {
expect(healSettings({ singleKeyShortcuts: "no" }).singleKeyShortcuts).toBe(true);
expect(healSettings({ singleKeyShortcuts: 0 }).singleKeyShortcuts).toBe(true);
expect(healSettings({ singleKeyShortcuts: null }).singleKeyShortcuts).toBe(true);
});
});
+137
View File
@@ -0,0 +1,137 @@
import { readFileSync } from "fs";
import { resolve } from "path";
import { describe, expect, it } from "vitest";
/**
* WCAG 2.2 AA colour contrast for the design tokens in src/styles/globals.css
* (ACCESSIBILITY.md promises it): 4.5:1 for text, 3:1 for marks that are not
* text (a checkbox tick, a switch thumb). Change a token and this says which
* pair stopped passing.
*/
const CSS = readFileSync(resolve(import.meta.dirname, "../../src/styles/globals.css"), "utf8");
type Rgb = readonly [number, number, number];
/** The declarations of the first `<selector> { … }` rule that defines the palette. */
function paletteBlock(selector: string): string {
const rule = new RegExp(`(?:^|\\n)${selector.replace(".", "\\.")} \\{([^}]*)\\}`, "g");
for (const match of CSS.matchAll(rule)) {
const body = match[1] ?? "";
if (body.includes("--surface-0:")) return body;
}
throw new Error(`no palette rule for ${selector}`);
}
function hexTokens(body: string): Map<string, Rgb> {
const tokens = new Map<string, Rgb>();
for (const [, name, hex] of body.matchAll(/--([a-z0-9-]+):\s?#([0-9a-f]{6});/gi)) {
if (!name || !hex) continue;
tokens.set(
name,
[0, 2, 4].map((i) => Number.parseInt(hex.slice(i, i + 2), 16)) as unknown as Rgb,
);
}
return tokens;
}
function rgbaToken(body: string, name: string): { rgb: Rgb; alpha: number } {
const match = new RegExp(
`--${name}:\\s?rgba\\((\\d{1,3}), (\\d{1,3}), (\\d{1,3}), ([\\d.]{1,5})\\);`,
).exec(body);
if (!match) throw new Error(`no rgba token --${name}`);
return {
rgb: [Number(match[1]), Number(match[2]), Number(match[3])],
alpha: Number(match[4]),
};
}
function luminance([r, g, b]: Rgb): number {
const [lr, lg, lb] = [r, g, b].map((channel) => {
const c = channel / 255;
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
}) as [number, number, number];
return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb;
}
function contrast(a: Rgb, b: Rgb): number {
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];
return (hi + 0.05) / (lo + 0.05);
}
function over(top: { rgb: Rgb; alpha: number }, base: Rgb): Rgb {
return top.rgb.map((c, i) =>
Math.round(top.alpha * c + (1 - top.alpha) * (base[i] ?? 0)),
) as unknown as Rgb;
}
const darkBody = paletteBlock(":root");
const lightBody = paletteBlock(".light");
const dark = hexTokens(darkBody);
// The light theme overrides what it needs and inherits the rest.
const light = new Map([...dark, ...hexTokens(lightBody)]);
const THEMES = [
{ name: "dark", tokens: dark, body: darkBody },
{ name: "light", tokens: light, body: lightBody },
] as const;
const SURFACES = ["surface-0", "surface-1", "surface-2"] as const;
const TEXT_TOKENS = [
"text-primary",
"text-secondary",
"text-muted",
"accent",
"success",
"warning",
"danger",
"info",
"donate",
] as const;
function token(tokens: Map<string, Rgb>, name: string): Rgb {
const value = tokens.get(name);
if (!value) throw new Error(`missing token --${name}`);
return value;
}
describe.each(THEMES)("$name theme — WCAG AA contrast", ({ tokens, body }) => {
it.each(TEXT_TOKENS)("--%s reads at 4.5:1 on every surface text sits on", (name) => {
for (const surface of SURFACES) {
const ratio = contrast(token(tokens, name), token(tokens, surface));
expect(ratio, `--${name} on --${surface}`).toBeGreaterThanOrEqual(4.5);
}
});
it("--text-muted also reads at 4.5:1 on --surface-3 (hover rows, chips)", () => {
expect(
contrast(token(tokens, "text-muted"), token(tokens, "surface-3")),
).toBeGreaterThanOrEqual(4.5);
});
it.each(["accent-solid", "accent-solid-hover", "danger-solid", "danger-solid-hover"])(
"white text reads at 4.5:1 on --%s (filled buttons)",
(fill) => {
expect(contrast(token(tokens, "accent-fg"), token(tokens, fill))).toBeGreaterThanOrEqual(4.5);
expect(contrast([255, 255, 255], token(tokens, fill))).toBeGreaterThanOrEqual(4.5);
},
);
it("marks on --accent (checkbox tick, switch thumb) reach 3:1", () => {
expect(contrast(token(tokens, "accent-fg"), token(tokens, "accent"))).toBeGreaterThanOrEqual(3);
});
it("--accent text reads at 4.5:1 on its own tint (--accent-muted chips)", () => {
const tint = over(rgbaToken(body, "accent-muted"), token(tokens, "surface-1"));
expect(contrast(token(tokens, "accent"), tint)).toBeGreaterThanOrEqual(4.5);
});
});
describe("contrast()", () => {
it("matches the WCAG reference values", () => {
expect(contrast([0, 0, 0], [255, 255, 255])).toBeCloseTo(21, 5);
expect(contrast([255, 255, 255], [255, 255, 255])).toBe(1);
// #767676 on white is the classic 4.54:1.
expect(contrast([0x76, 0x76, 0x76], [255, 255, 255])).toBeCloseTo(4.54, 2);
});
});