feat(webui): refine appearance and add custom reading sizes
This commit is contained in:
1 parent
b048cf44f7
commit
ef8271b2c0
38 files changed
+1148
-213
No files matched your search
@@ -46,16 +46,17 @@ import { RuntimeConfigSettings } from "@/components/settings/system/RuntimeConfi
|
||||
import { RuntimeSettings } from "@/components/settings/system/RuntimeSettings";
|
||||
import type { SettingsController } from "@/components/settings/useSettingsController";
|
||||
import type { SendAttachment, SendOptions } from "@/hooks/useNanobotStream";
|
||||
import type { ThemePreference } from "@/hooks/useTheme";
|
||||
import type { ChatSummary, SessionAutomationJob, SkillSummary } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface SettingsPageProps {
|
||||
registerExitGuard?: (guard: SettingsExitGuard | null) => void;
|
||||
controller: SettingsController;
|
||||
theme: "light" | "dark";
|
||||
themePreference: ThemePreference;
|
||||
showSidebar: boolean;
|
||||
mainNavigationExpanded: boolean;
|
||||
onToggleTheme: () => void;
|
||||
onChangeTheme: (value: ThemePreference) => void;
|
||||
onBackToChat: () => void;
|
||||
skills: SkillSummary[];
|
||||
skillsLoading: boolean;
|
||||
@@ -76,10 +77,10 @@ interface SettingsPageProps {
|
||||
export function SettingsPage({
|
||||
registerExitGuard,
|
||||
controller,
|
||||
theme,
|
||||
themePreference,
|
||||
showSidebar,
|
||||
mainNavigationExpanded,
|
||||
onToggleTheme,
|
||||
onChangeTheme,
|
||||
onBackToChat,
|
||||
skills,
|
||||
skillsLoading,
|
||||
@@ -272,8 +273,8 @@ export function SettingsPage({
|
||||
case "appearance":
|
||||
return (
|
||||
<AppearanceSettings
|
||||
theme={theme}
|
||||
onToggleTheme={onToggleTheme}
|
||||
themePreference={themePreference}
|
||||
onChangeTheme={onChangeTheme}
|
||||
localPrefs={localPrefs}
|
||||
onChangeLocalPrefs={setLocalPrefs}
|
||||
/>
|
||||
|
||||
@@ -2,18 +2,19 @@ import { SettingsPage } from "@/components/settings/SettingsPage";
|
||||
import type { SettingsExitGuard, SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { useSettingsController } from "@/components/settings/useSettingsController";
|
||||
import type { SendAttachment, SendOptions } from "@/hooks/useNanobotStream";
|
||||
import type { ThemePreference } from "@/hooks/useTheme";
|
||||
import type { ChatSummary, SettingsPayload, SkillSummary } from "@/lib/types";
|
||||
|
||||
export type { SettingsSectionKey } from "@/components/settings/contracts";
|
||||
|
||||
interface SettingsViewProps {
|
||||
registerExitGuard?: (guard: SettingsExitGuard | null) => void;
|
||||
theme: "light" | "dark";
|
||||
themePreference: ThemePreference;
|
||||
initialSection?: SettingsSectionKey;
|
||||
initialSettings?: SettingsPayload | null;
|
||||
showSidebar?: boolean;
|
||||
mainNavigationExpanded?: boolean;
|
||||
onToggleTheme: () => void;
|
||||
onChangeTheme: (value: ThemePreference) => void;
|
||||
onBackToChat: () => void;
|
||||
onModelNameChange: (modelName: string | null) => void;
|
||||
onSettingsChange?: (payload: SettingsPayload) => void;
|
||||
@@ -38,12 +39,12 @@ interface SettingsViewProps {
|
||||
|
||||
export function SettingsView({
|
||||
registerExitGuard,
|
||||
theme,
|
||||
themePreference,
|
||||
initialSection = "overview",
|
||||
initialSettings = null,
|
||||
showSidebar = true,
|
||||
mainNavigationExpanded = false,
|
||||
onToggleTheme,
|
||||
onChangeTheme,
|
||||
onBackToChat,
|
||||
onModelNameChange,
|
||||
onSettingsChange,
|
||||
@@ -74,10 +75,10 @@ export function SettingsView({
|
||||
<SettingsPage
|
||||
registerExitGuard={registerExitGuard}
|
||||
controller={controller}
|
||||
theme={theme}
|
||||
themePreference={themePreference}
|
||||
showSidebar={showSidebar}
|
||||
mainNavigationExpanded={mainNavigationExpanded}
|
||||
onToggleTheme={onToggleTheme}
|
||||
onChangeTheme={onChangeTheme}
|
||||
onBackToChat={onBackToChat}
|
||||
skills={skills}
|
||||
skillsLoading={skillsLoading}
|
||||
|
||||
@@ -1,129 +1,108 @@
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useId, type Dispatch, type SetStateAction } from "react";
|
||||
import { Check, Monitor, Moon, Sun } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
|
||||
import { SettingsGroup, SettingsRow, SettingsSectionTitle } from "@/components/settings/shared/SettingsControls";
|
||||
import { ToggleButton } from "@/components/ui/toggle-button";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import type { ThemePreference } from "@/hooks/useTheme";
|
||||
import type { FileEditDisplayMode, LocalActivityMode, LocalPreferences } from "@/lib/local-preferences";
|
||||
import { ReadingSettings } from "./ReadingSettings";
|
||||
import "./appearance-settings.css";
|
||||
|
||||
export function AppearanceSettingsView({
|
||||
theme,
|
||||
onToggleTheme,
|
||||
localPrefs,
|
||||
onChangeLocalPrefs,
|
||||
}: {
|
||||
theme: "light" | "dark";
|
||||
onToggleTheme: () => void;
|
||||
export function AppearanceSettingsView({ themePreference, onChangeTheme, localPrefs, onChangeLocalPrefs }: {
|
||||
themePreference: ThemePreference;
|
||||
onChangeTheme: (preference: ThemePreference) => void;
|
||||
localPrefs: LocalPreferences;
|
||||
onChangeLocalPrefs: Dispatch<SetStateAction<LocalPreferences>>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
<section>
|
||||
<SettingsSectionTitle>{t("settings.sections.interface")}</SettingsSectionTitle>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.rows.theme")}>
|
||||
<SegmentedControl
|
||||
value={theme}
|
||||
ariaLabel={t("settings.rows.theme")}
|
||||
className="bg-muted p-0.5"
|
||||
itemClassName="px-3"
|
||||
options={[
|
||||
{ value: "light", label: t("settings.values.light") },
|
||||
{ value: "dark", label: t("settings.values.dark") },
|
||||
]}
|
||||
onChange={(nextTheme) => {
|
||||
if (nextTheme !== theme) onToggleTheme();
|
||||
}}
|
||||
/>
|
||||
</SettingsRow>
|
||||
const themeId = useId();
|
||||
const themes = [
|
||||
{ value: "system", label: t("settings.appearance.system"), icon: Monitor },
|
||||
{ value: "light", label: t("settings.values.light"), icon: Sun },
|
||||
{ value: "dark", label: t("settings.values.dark"), icon: Moon },
|
||||
] as const;
|
||||
const editHelp = { summary: "summaryHelp", diff: "diffHelp", collapsed_diff: "collapsedHelp" } as const;
|
||||
|
||||
<SettingsRow title={t("settings.rows.language")}>
|
||||
<LanguageSwitcher />
|
||||
return <div className="settings-stack appearance-page">
|
||||
<section>
|
||||
<SettingsSectionTitle>{t("settings.rows.theme")}</SettingsSectionTitle>
|
||||
<fieldset>
|
||||
<legend className="sr-only">{t("settings.rows.theme")}</legend>
|
||||
<div className="appearance-theme-grid">
|
||||
{themes.map(({ value, label, icon: Icon }) => <label key={value} className="appearance-theme-option">
|
||||
<input className="appearance-theme-input" type="radio" name={themeId} value={value}
|
||||
checked={themePreference === value} onChange={() => onChangeTheme(value)} />
|
||||
<span className="appearance-theme-card">
|
||||
<span className="appearance-theme-miniature" data-mode={value} aria-hidden>
|
||||
<span className="appearance-mini-sidebar"><span /><span /><span /></span>
|
||||
<span className="appearance-mini-main"><span /><span /><span /><span /></span>
|
||||
</span>
|
||||
<span className="appearance-theme-label text-ui-label">
|
||||
<span className="flex min-w-0 items-center gap-1.5"><Icon className="h-3.5 w-3.5 shrink-0" aria-hidden /><span>{label}</span></span>
|
||||
<Check className="appearance-theme-check h-3.5 w-3.5 shrink-0" aria-hidden />
|
||||
</span>
|
||||
</span>
|
||||
</label>)}
|
||||
</div>
|
||||
</fieldset>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<SettingsSectionTitle>{t("settings.appearance.reading")}</SettingsSectionTitle>
|
||||
<ReadingSettings preferences={localPrefs} onChange={onChangeLocalPrefs} />
|
||||
<div className="mt-2">
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.rows.codeWrap")} description={t("settings.help.codeWrap")}>
|
||||
<ToggleButton checked={localPrefs.codeWrap}
|
||||
onChange={(codeWrap) => onChangeLocalPrefs((previous) => ({ ...previous, codeWrap }))}
|
||||
ariaLabel={t("settings.rows.codeWrap")}
|
||||
label={t(localPrefs.codeWrap ? "settings.values.on" : "settings.values.off")} />
|
||||
</SettingsRow>
|
||||
</SettingsGroup>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<SettingsSectionTitle>{tx("settings.sections.localPreferences", "Local preferences")}</SettingsSectionTitle>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.rows.readingTextSize")}>
|
||||
<SegmentedControl
|
||||
value={localPrefs.readingTextSize}
|
||||
mode="radio"
|
||||
ariaLabel={t("settings.rows.readingTextSize")}
|
||||
className="w-36 [@media(pointer:coarse)]:w-40"
|
||||
itemClassName="flex flex-1 basis-0 items-center justify-center !overflow-visible px-0 after:absolute after:inset-x-0 after:top-1/2 after:h-11 after:-translate-y-1/2 after:content-['']"
|
||||
options={([
|
||||
["small", "text-[12px]"],
|
||||
["standard", "text-[16px]"],
|
||||
["large", "text-[20px]"],
|
||||
] as const).map(([value, size]) => ({
|
||||
value,
|
||||
label: <span aria-hidden className={size}>A</span>,
|
||||
ariaLabel: t(`settings.readingTextSize.${value}`),
|
||||
tooltip: t(`settings.readingTextSize.${value}`),
|
||||
}))}
|
||||
onChange={(readingTextSize) =>
|
||||
onChangeLocalPrefs((prev) => ({ ...prev, readingTextSize }))
|
||||
}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<SettingsRow title={tx("settings.rows.activityMode", "Activity detail")}>
|
||||
<SegmentedControl
|
||||
value={localPrefs.activityMode}
|
||||
<section>
|
||||
<SettingsSectionTitle>{t("settings.appearance.process")}</SettingsSectionTitle>
|
||||
<p className="appearance-setting-help">{t("settings.appearance.processHelp")}</p>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.rows.activityMode")}>
|
||||
<SegmentedControl<LocalActivityMode> value={localPrefs.activityMode}
|
||||
ariaLabel={t("settings.rows.activityMode")}
|
||||
options={[{ value: "auto", label: t("settings.values.auto") }, { value: "expanded", label: t("settings.values.expanded") }]}
|
||||
onChange={(activityMode) => onChangeLocalPrefs((previous) => ({ ...previous, activityMode }))} />
|
||||
</SettingsRow>
|
||||
<p className="appearance-setting-help">{t(`settings.appearance.${localPrefs.activityMode === "auto" ? "autoHelp" : "expandedHelp"}`)}</p>
|
||||
<div className="settings-group-divider">
|
||||
<SettingsRow title={t("settings.rows.fileEditDisplay")}>
|
||||
<SegmentedControl<FileEditDisplayMode> value={localPrefs.fileEditDisplayMode}
|
||||
ariaLabel={t("settings.rows.fileEditDisplay")}
|
||||
options={[
|
||||
{ value: "auto", label: tx("settings.values.auto", "Auto") },
|
||||
{ value: "expanded", label: tx("settings.values.expanded", "Expanded") },
|
||||
{ value: "summary", label: t("settings.values.summary") },
|
||||
{ value: "diff", label: t("settings.values.diff") },
|
||||
{ value: "collapsed_diff", label: t("settings.values.collapsedDiff") },
|
||||
]}
|
||||
onChange={(activityMode) =>
|
||||
onChangeLocalPrefs((prev) => ({ ...prev, activityMode: activityMode as LocalActivityMode }))
|
||||
}
|
||||
/>
|
||||
onChange={(fileEditDisplayMode) => onChangeLocalPrefs((previous) => ({ ...previous, fileEditDisplayMode }))} />
|
||||
</SettingsRow>
|
||||
<SettingsRow title={tx("settings.rows.fileEditDisplay", "File edit display")}>
|
||||
<SegmentedControl
|
||||
value={localPrefs.fileEditDisplayMode}
|
||||
options={[
|
||||
{ value: "summary", label: tx("settings.values.summary", "Summary") },
|
||||
{ value: "diff", label: tx("settings.values.diff", "Diff") },
|
||||
{ value: "collapsed_diff", label: tx("settings.values.collapsedDiff", "Collapsed diff") },
|
||||
]}
|
||||
onChange={(fileEditDisplayMode) =>
|
||||
onChangeLocalPrefs((prev) => ({
|
||||
...prev,
|
||||
fileEditDisplayMode: fileEditDisplayMode as FileEditDisplayMode,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<SettingsRow title={tx("settings.rows.codeWrap", "Code wrapping")}>
|
||||
<ToggleButton
|
||||
checked={localPrefs.codeWrap}
|
||||
onChange={(codeWrap) => onChangeLocalPrefs((prev) => ({ ...prev, codeWrap }))}
|
||||
ariaLabel={tx("settings.rows.codeWrap", "Code wrapping")}
|
||||
label={localPrefs.codeWrap ? tx("settings.values.on", "On") : tx("settings.values.off", "Off")}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<SettingsRow
|
||||
title={tx("settings.rows.brandLogos", "Brand logos")}
|
||||
description={tx(
|
||||
"settings.legal.thirdPartyBrands",
|
||||
"Product names, logos, and brands are property of their respective owners. Use is for identification only and does not imply endorsement.",
|
||||
)}
|
||||
>
|
||||
<ToggleButton
|
||||
checked={localPrefs.brandLogos}
|
||||
onChange={(brandLogos) => onChangeLocalPrefs((prev) => ({ ...prev, brandLogos }))}
|
||||
ariaLabel={tx("settings.rows.brandLogos", "Brand logos")}
|
||||
label={localPrefs.brandLogos ? tx("settings.values.on", "On") : tx("settings.values.off", "Off")}
|
||||
/>
|
||||
</SettingsRow>
|
||||
</SettingsGroup>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
<p className="appearance-setting-help">{t(`settings.appearance.${editHelp[localPrefs.fileEditDisplayMode]}`)}</p>
|
||||
</div>
|
||||
</SettingsGroup>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<SettingsSectionTitle>{t("settings.sections.interface")}</SettingsSectionTitle>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.rows.language")}><LanguageSwitcher /></SettingsRow>
|
||||
<SettingsRow title={t("settings.rows.brandLogos")} description={t("settings.legal.thirdPartyBrands")}>
|
||||
<ToggleButton checked={localPrefs.brandLogos}
|
||||
onChange={(brandLogos) => onChangeLocalPrefs((previous) => ({ ...previous, brandLogos }))}
|
||||
ariaLabel={t("settings.rows.brandLogos")}
|
||||
label={t(localPrefs.brandLogos ? "settings.values.on" : "settings.values.off")} />
|
||||
</SettingsRow>
|
||||
</SettingsGroup>
|
||||
</section>
|
||||
</div>;
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
} from "@/components/settings/shared/SettingsControls";
|
||||
import { TokenUsageCard } from "@/components/settings/TokenUsageCard";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import type { ThemePreference } from "@/hooks/useTheme";
|
||||
import type {
|
||||
LocalPreferences,
|
||||
} from "@/lib/local-preferences";
|
||||
@@ -172,13 +173,13 @@ function VersionCheckRow({ currentVersion, currentCommit, onRequestUpdate, hasPe
|
||||
channelError={channelError} onChangeChannel={changeChannel} />;
|
||||
}
|
||||
|
||||
export function AppearanceSettings({ theme, onToggleTheme, localPrefs, onChangeLocalPrefs }: {
|
||||
theme: "light" | "dark";
|
||||
onToggleTheme: () => void;
|
||||
export function AppearanceSettings({ themePreference, onChangeTheme, localPrefs, onChangeLocalPrefs }: {
|
||||
themePreference: ThemePreference;
|
||||
onChangeTheme: (value: ThemePreference) => void;
|
||||
localPrefs: LocalPreferences;
|
||||
onChangeLocalPrefs: Dispatch<SetStateAction<LocalPreferences>>;
|
||||
}) {
|
||||
return <AppearanceSettingsView theme={theme} onToggleTheme={onToggleTheme}
|
||||
return <AppearanceSettingsView themePreference={themePreference} onChangeTheme={onChangeTheme}
|
||||
localPrefs={localPrefs} onChangeLocalPrefs={onChangeLocalPrefs} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
import { useEffect, useId, useRef, useState, type CSSProperties, type Dispatch, type SetStateAction } from "react";
|
||||
import { ArrowUp } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { MarkdownText } from "@/components/MarkdownText";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { MAX_READING_SIZE, MIN_READING_SIZE, type LocalPreferences, type ReadingTextSize } from "@/lib/local-preferences";
|
||||
|
||||
export function ReadingSettings({ preferences, onChange }: {
|
||||
preferences: LocalPreferences;
|
||||
onChange: Dispatch<SetStateAction<LocalPreferences>>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const id = useId();
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const custom = preferences.readingTextSize === "custom";
|
||||
const [draft, setDraft] = useState(String(preferences.customReadingTextSize));
|
||||
const [hintOpen, setHintOpen] = useState(false);
|
||||
const [showError, setShowError] = useState(false);
|
||||
const hint = t(showError ? "settings.appearance.customInvalid" : "settings.appearance.customRange", {
|
||||
min: MIN_READING_SIZE, max: MAX_READING_SIZE, size: preferences.customReadingTextSize,
|
||||
});
|
||||
useEffect(() => {
|
||||
setDraft(String(preferences.customReadingTextSize));
|
||||
setShowError(false);
|
||||
// A preset selected in another tab ends an unfinished custom edit.
|
||||
if (!custom) {
|
||||
setHintOpen(false);
|
||||
if (document.activeElement === inputRef.current) inputRef.current?.blur();
|
||||
}
|
||||
}, [preferences.customReadingTextSize, custom]);
|
||||
|
||||
const commitDraft = () => {
|
||||
if (!custom) return true;
|
||||
const value = draft.trim() ? Number(draft) : preferences.customReadingTextSize;
|
||||
// Native number inputs expose unfinished values such as "-" as an empty string.
|
||||
if (inputRef.current?.validity.badInput || !Number.isInteger(value) || value < MIN_READING_SIZE || value > MAX_READING_SIZE) {
|
||||
setShowError(true);
|
||||
setHintOpen(true);
|
||||
return false;
|
||||
}
|
||||
setDraft(String(value));
|
||||
setShowError(false);
|
||||
setHintOpen(false);
|
||||
onChange((previous) => ({ ...previous, customReadingTextSize: value }));
|
||||
return true;
|
||||
};
|
||||
|
||||
return <div className="appearance-reading-card">
|
||||
<div className="appearance-reading-controls">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<span className="text-control-label" id={`${id}-label`}>{t("settings.rows.readingTextSize")}</span>
|
||||
<div className="appearance-size-options">
|
||||
<SegmentedControl<ReadingTextSize>
|
||||
mode="radio"
|
||||
value={preferences.readingTextSize}
|
||||
ariaLabel={t("settings.rows.readingTextSize")}
|
||||
className="appearance-size-presets gap-0 p-0.5"
|
||||
itemClassName="flex items-center justify-center p-0"
|
||||
options={([
|
||||
["small", "text-[12px]"], ["standard", "text-[16px]"], ["large", "text-[20px]"],
|
||||
] as const).map(([value, size]) => ({
|
||||
value,
|
||||
label: <span aria-hidden className={size}>A</span>,
|
||||
ariaLabel: t(`settings.readingTextSize.${value}`),
|
||||
tooltip: t(`settings.readingTextSize.${value}`),
|
||||
}))}
|
||||
onChange={(readingTextSize) => onChange((previous) => ({ ...previous, readingTextSize }))}
|
||||
/>
|
||||
<TooltipProvider>
|
||||
<Tooltip open={hintOpen} onOpenChange={(open) => {
|
||||
// Keep guidance visible while typing, including pointer/touch focus.
|
||||
if (open || document.activeElement !== inputRef.current) setHintOpen(open);
|
||||
}}>
|
||||
<TooltipTrigger asChild>
|
||||
<label className="appearance-custom-option" htmlFor={`${id}-custom`} data-selected={custom} data-invalid={showError}>
|
||||
<span className="appearance-custom-label">{t("settings.appearance.custom")}</span>
|
||||
<span className="appearance-custom-value">
|
||||
<Input ref={inputRef} id={`${id}-custom`} type="number" inputMode="numeric" min={MIN_READING_SIZE} max={MAX_READING_SIZE} step={1}
|
||||
className="appearance-size-input h-[calc(var(--appearance-preset-size)-16px)] w-[3ch] border-0 bg-transparent p-0 text-right text-ui-label tabular-nums focus-visible:ring-0"
|
||||
aria-label={t("settings.appearance.customSize")}
|
||||
aria-describedby={`${id}-range`}
|
||||
aria-invalid={showError || undefined}
|
||||
value={draft}
|
||||
onFocus={(event) => {
|
||||
event.currentTarget.select();
|
||||
setHintOpen(true);
|
||||
if (!custom) onChange((previous) => ({ ...previous, readingTextSize: "custom" }));
|
||||
}}
|
||||
onChange={(event) => {
|
||||
const next = event.currentTarget.value;
|
||||
setDraft(next);
|
||||
setShowError(false);
|
||||
const value = Number(next);
|
||||
if (next.trim() && Number.isInteger(value) && value >= MIN_READING_SIZE && value <= MAX_READING_SIZE) {
|
||||
onChange((previous) => ({ ...previous, readingTextSize: "custom", customReadingTextSize: value }));
|
||||
}
|
||||
}}
|
||||
onBlur={(event) => {
|
||||
if (!commitDraft()) event.preventDefault();
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter") event.currentTarget.blur();
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setDraft(String(preferences.customReadingTextSize));
|
||||
setShowError(false);
|
||||
setHintOpen(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span aria-hidden className="text-caption text-muted-foreground">px</span>
|
||||
</span>
|
||||
</label>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" align="end" sideOffset={10}
|
||||
className={`max-w-[min(20rem,calc(100vw-2rem))] whitespace-pre-line leading-relaxed ${showError ? "text-destructive" : ""}`}>
|
||||
{hint}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
</div>
|
||||
</div>
|
||||
<p className="mt-2 text-caption text-muted-foreground">{t("settings.appearance.readingHelp")}</p>
|
||||
<span className="sr-only" id={`${id}-range`} aria-live="polite">{hint}</span>
|
||||
</div>
|
||||
<div className="reading-typography appearance-reading-preview"
|
||||
data-reading-text-size={preferences.readingTextSize}
|
||||
style={{ "--custom-reading-size": `${preferences.customReadingTextSize}px` } as CSSProperties}>
|
||||
<div className="mb-4 flex items-center justify-between gap-3 text-caption text-muted-foreground">
|
||||
<span className="inline-flex items-center gap-2 font-medium text-foreground">
|
||||
<img src="/brand/nanobot_mark.svg" className="h-5 w-5" alt="" />nanobot
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5"><span className="h-1.5 w-1.5 rounded-full bg-emerald-600/70 dark:bg-emerald-400/70" />{t("settings.appearance.preview")}</span>
|
||||
</div>
|
||||
<div data-reading-preview-content>
|
||||
<MarkdownText>{t("settings.appearance.previewText")}</MarkdownText>
|
||||
<div className="mt-4 overflow-x-auto rounded-control bg-muted/60 px-4 py-3">
|
||||
<code className={`block font-mono text-code ${preferences.codeWrap ? "whitespace-pre-wrap break-words" : "whitespace-pre"}`}><span className="text-[color:var(--code-keyword)]">const</span>{' idea = '}<span className="text-[color:var(--code-string)]">{'"Hello, nanobot."'}</span>;</code>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 flex items-center gap-3 rounded-control border border-border/65 px-4 py-3 text-muted-foreground/80" aria-hidden>
|
||||
<span className="min-w-0 flex-1 text-composer">{t("settings.appearance.previewPlaceholder")}</span>
|
||||
<span className="flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-foreground text-background"><ArrowUp className="h-4 w-4" /></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
.appearance-page { --settings-module-gap: 28px; --appearance-panel-inset: 8px; --appearance-preset-size: 36px; --appearance-control-height: calc(var(--appearance-preset-size) + 4px); container: appearance / inline-size; }
|
||||
.appearance-page > section { min-width: 0; }
|
||||
.appearance-theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
|
||||
.appearance-theme-option { position: relative; min-width: 0; cursor: pointer; }
|
||||
.appearance-theme-input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
|
||||
.appearance-theme-card { --appearance-theme-inset: 8px; display: block; padding: var(--appearance-theme-inset); border: 1px solid hsl(var(--border)); border-radius: var(--radius-panel); background: hsl(var(--settings-surface)); transition: border-color 160ms ease, box-shadow 160ms ease; }
|
||||
.appearance-theme-option input:checked + .appearance-theme-card { border-color: hsl(var(--foreground) / 0.6); box-shadow: 0 0 0 1px hsl(var(--foreground) / 0.15); }
|
||||
.appearance-theme-option input:focus-visible + .appearance-theme-card { outline: 2px solid hsl(var(--ring) / 0.65); outline-offset: 3px; }
|
||||
.appearance-theme-check { opacity: 0; }
|
||||
.appearance-theme-option input:checked + .appearance-theme-card .appearance-theme-check { opacity: 1; }
|
||||
.appearance-theme-label { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 8px 4px 2px; min-height: 36px; }
|
||||
/* Nested surfaces follow the outer curve minus their actual inset, including the border. */
|
||||
.appearance-theme-miniature { --mini-paper: #fff; --mini-sidebar: #f1f0ec; --mini-line: #dad9d5; display: flex; height: 84px; overflow: hidden; border-radius: calc(var(--radius-panel) - var(--appearance-theme-inset) - 1px); background: var(--mini-paper); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04); }
|
||||
.appearance-theme-miniature[data-mode="dark"] { --mini-paper: #303030; --mini-sidebar: #383838; --mini-line: #656565; }
|
||||
.appearance-theme-miniature[data-mode="system"] { --mini-paper: linear-gradient(110deg, #fff 50%, #303030 50%); --mini-sidebar: #f1f0ec; --mini-line: #969590; }
|
||||
.appearance-mini-sidebar { width: 24%; display: flex; flex-direction: column; gap: 6px; padding: 11px 7px; background: var(--mini-sidebar); }
|
||||
.appearance-mini-sidebar::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: #d7834c; margin-bottom: 6px; }
|
||||
.appearance-mini-sidebar span { height: 3px; border-radius: 3px; background: var(--mini-line); }
|
||||
.appearance-mini-main { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; gap: 5px; padding: 16px 12px 10px; }
|
||||
.appearance-mini-main span { height: 3px; width: 80%; border-radius: 3px; background: var(--mini-line); }
|
||||
.appearance-mini-main span:first-child { width: 46%; height: 5px; margin-bottom: 4px; }
|
||||
.appearance-mini-main span:last-child { width: 100%; height: 13px; margin-top: auto; border: 1px solid var(--mini-line); background: transparent; border-radius: 5px; }
|
||||
.appearance-reading-card { overflow: hidden; border-radius: var(--radius-panel); background: hsl(var(--settings-surface)); }
|
||||
.appearance-reading-controls { padding: 20px var(--settings-inset, 16px); }
|
||||
.appearance-size-options { display: flex; align-items: center; gap: 12px; max-width: 100%; }
|
||||
.appearance-size-presets { flex: 0 0 auto; }
|
||||
.appearance-size-presets button { width: var(--appearance-preset-size); height: var(--appearance-preset-size); flex: 0 0 var(--appearance-preset-size); }
|
||||
.appearance-custom-option { position: relative; display: flex; flex: 0 1 auto; align-items: center; justify-content: center; gap: 8px; min-width: 0; height: var(--appearance-control-height); padding: 0 14px; border: 1px solid hsl(var(--border)); border-radius: var(--radius-pill); corner-shape: round; color: hsl(var(--muted-foreground)); background: hsl(var(--background) / 0.55); cursor: text; transition: border-color 160ms ease, background-color 160ms ease; }
|
||||
.appearance-custom-option[data-selected="true"] { color: hsl(var(--foreground)); border-color: hsl(var(--foreground) / 0.6); background: hsl(var(--background)); }
|
||||
.appearance-custom-option:has(input:focus-visible) { outline: 2px solid hsl(var(--ring) / 0.65); outline-offset: 3px; }
|
||||
.appearance-custom-option[data-invalid="true"] { border-color: hsl(var(--destructive)); outline-color: hsl(var(--destructive)); }
|
||||
.appearance-custom-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 16px; }
|
||||
.appearance-custom-value { display: flex; flex-shrink: 0; align-items: baseline; gap: 1px; min-width: 0; }
|
||||
@media (pointer: coarse) {
|
||||
.appearance-page { --appearance-preset-size: 44px; }
|
||||
}
|
||||
@media (hover: hover) {
|
||||
.appearance-theme-option:hover .appearance-theme-card { border-color: hsl(var(--foreground) / 0.6); }
|
||||
.appearance-custom-option:hover:not([data-selected="true"]):not([data-invalid="true"]) { border-color: hsl(var(--muted-foreground) / 0.55); background: hsl(var(--background) / 0.85); }
|
||||
}
|
||||
.appearance-size-input { appearance: textfield; -moz-appearance: textfield; }
|
||||
.appearance-size-input::-webkit-inner-spin-button, .appearance-size-input::-webkit-outer-spin-button { appearance: none; margin: 0; }
|
||||
.appearance-reading-preview { margin: 0 var(--appearance-panel-inset) var(--appearance-panel-inset); padding: 20px 16px; border: 1px solid hsl(var(--border) / 0.65); border-radius: calc(var(--radius-panel) - var(--appearance-panel-inset)); background: hsl(var(--background)); }
|
||||
.appearance-reading-preview .markdown-content > :first-child { margin-top: 0; }
|
||||
.appearance-reading-preview .markdown-content > :last-child { margin-bottom: 0; }
|
||||
.appearance-setting-help { padding: 0 var(--settings-inset, 16px) 12px; font-size: 12px; line-height: 1.6; color: hsl(var(--muted-foreground)); }
|
||||
.appearance-page .settings-section-title { margin-bottom: 12px; }
|
||||
.appearance-page .settings-row { border-radius: 0; }
|
||||
.appearance-page .settings-group-divider { border-top: 1px solid hsl(var(--border) / 0.65); }
|
||||
@container appearance (max-width: 420px) {
|
||||
.appearance-theme-grid { gap: 8px; }
|
||||
.appearance-theme-card { --appearance-theme-inset: 6px; }
|
||||
.appearance-theme-miniature { height: 70px; }
|
||||
.appearance-theme-label { padding-inline: 0; font-size: 12px; }
|
||||
.appearance-mini-main { padding-inline: 8px; }
|
||||
.appearance-size-options { width: 100%; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
|
||||
.appearance-custom-option { flex: 0 0 auto; flex-direction: column; gap: 0; min-width: 80px; padding: 2px 10px; }
|
||||
.appearance-custom-label { flex-shrink: 0; font-size: 11px; line-height: 12px; }
|
||||
.appearance-reading-controls { padding-top: 16px; }
|
||||
}
|
||||
@container appearance (max-width: 360px) {
|
||||
.appearance-theme-label > span > svg { display: none; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.appearance-theme-card, .appearance-custom-option { transition: none; }
|
||||
}
|
||||
@@ -1160,7 +1160,7 @@ export function ThreadComposer({
|
||||
// keyboard still get the newline-on-Enter behavior.
|
||||
const hasCoarsePointer = useMediaQuery("(pointer: coarse)");
|
||||
const mobileWorkspaceControls = useMediaQuery("(max-width: 639px)");
|
||||
const { readingTextSize } = useLocalPreferences();
|
||||
const { readingTextSize, customReadingTextSize } = useLocalPreferences();
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const mentionOverlayRef = useRef<HTMLDivElement>(null);
|
||||
const formRef = useRef<HTMLFormElement>(null);
|
||||
@@ -1846,7 +1846,7 @@ export function ThreadComposer({
|
||||
// The parent projects typography tokens in its layout effect; measure after it.
|
||||
const input = textareaRef.current;
|
||||
if (input) autosizeTextarea(input);
|
||||
}, [readingTextSize]);
|
||||
}, [readingTextSize, customReadingTextSize]);
|
||||
|
||||
// Runs before paint so switching sessions never flashes stale draft text.
|
||||
useLayoutEffect(() => {
|
||||
|
||||
Reference in new issue
Block a user