"use client"; import dynamic from "next/dynamic"; import type { CSSProperties } from "react"; import { CONTENT_FONT_SCALES, CONTENT_LINE_SPACING, type ContentFontScale, type ContentLineSpacing, } from "@/lib/learning-display"; import { useTranslation } from "react-i18next"; import type { CodeBlockThemeId } from "@/components/common/code-block-themes"; import { CODE_BLOCK_THEME_OPTIONS } from "@/components/common/code-block-themes"; import { Toggle } from "@/components/settings/Toggle"; import { useUiSettings } from "@/features/settings/store"; import { ThemePreviewCard } from "@/components/settings/ThemePreviewCard"; import { SettingRow, SettingSection, SettingsPageHeader, selectClass, selectOptionClass, } from "@/components/settings/shared"; const CODE_BLOCK_PREVIEW_SNIPPET = `def fibonacci(n): """Generate the first n Fibonacci numbers.""" a, b = 0, 1 result = [] for _ in range(n): result.append(a) a, b = b, a + b return result # Build a deliberately long summary so the wrapping preference is easy to see summary = f"First twenty Fibonacci values rendered with the selected syntax theme, line-number setting, and wrapping preference: {', '.join(str(value) for value in fibonacci(20))}" print(summary) `; const RichCodeBlockPreview = dynamic( () => import("@/components/common/RichCodeBlock"), { ssr: false }, ); export default function AppearanceSettingsPage() { const { t } = useTranslation(); const { theme, contentFontScale, contentLineSpacing, updateContentFontScale, updateContentLineSpacing, resetLearningText, codeBlockTheme, codeBlockShowLineNumbers, codeBlockWrapLongLines, updateTheme, updateCodeBlockTheme, updateCodeBlockShowLineNumbers, updateCodeBlockWrapLongLines, } = useUiSettings(); // All code-block values come straight from the settings context (backed by // AppShellContext, the single source of truth), so the toggles reflect the // current preference without any local mirror state. const handleShowLineNumbersChange = (next: boolean) => { void updateCodeBlockShowLineNumbers(next); }; const handleWrapLongLinesChange = (next: boolean) => { void updateCodeBlockWrapLongLines(next); }; return (
{/* Order is intentional: System (follow the OS; the default for a new browser) → Default (pure-white neutral; theme id "snow" kept for stored preferences) → warm-light Cream → warm-dark Dark → cool-dark Glass. */}
{( [ { id: "system", label: t("System") }, { id: "snow", label: t("Default") }, { id: "light", label: t("Cream") }, { id: "dark", label: t("Dark") }, { id: "glass", label: t("Glass") }, ] as const ).map(({ id, label }) => ( ))}

{t("System follows the device's light or dark appearance.")}{" "} {t( "Default is a clean pure-white theme with a blue accent. Cream is warm and paper-like with a terracotta accent. Dark keeps Cream's warmth on near-black. Glass adds translucent purple panels on a deep gradient.", )}

void updateContentFontScale( Number(event.target.value) as ContentFontScale, ) } className={selectClass} > {CONTENT_FONT_SCALES.map((scale) => ( ))} } /> void updateContentLineSpacing( event.target.value as ContentLineSpacing, ) } className={selectClass} > } />
{t("Learning text preview")}

Learning starts with a question. Explore an idea, connect it to what you know, and explain it in your own words.

学习从一个问题开始。探索新的想法,将它与已有的知识联系起来,再用自己的语言解释。

{t("Preview")}

{t("Updates live as you change the settings below.")}

void updateCodeBlockTheme( event.target.value as CodeBlockThemeId, ) } className={`${selectClass} min-w-[220px] pr-8`} > {CODE_BLOCK_THEME_OPTIONS.map((option) => ( ))} } /> } /> } />
); }