fix(webui): move appearance help to hints and smooth theme preview
This commit is contained in:
1 parent
01a1ef5370
commit
9270137d65
4 files changed
+44
-11
No files matched your search
@@ -78,12 +78,42 @@ for (const narrow of [false, true]) {
|
||||
await checkbox.click();
|
||||
await expect(checkbox).toHaveAttribute("aria-checked", "false");
|
||||
await page.getByRole("button", { name: "折叠修改", exact: true }).click();
|
||||
await expect(page.getByText("默认收起代码差异,需要时点开。", { exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "修改预览", exact: true }).click();
|
||||
await expect(page.getByRole("tooltip")).toHaveText("默认收起代码差异,需要时点开。");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.locator("main").evaluate((element) => element.scrollTo(0, 0));
|
||||
await page.screenshot({ path: info.outputPath("appearance.png") });
|
||||
});
|
||||
}
|
||||
|
||||
test("appearance explanations open on demand and follow the selected display modes", async ({ page }) => {
|
||||
await page.goto("/browser/fixture.html?case=appearance");
|
||||
const explanations = [
|
||||
["Reading text size", "Adjust messages, code and the composer—not navigation."],
|
||||
["Activity display", "Choose how much detail appears as nanobot works."],
|
||||
["Activity details", "Show progress while working; keep finished work compact."],
|
||||
["Edit preview", "Show changed files and line counts."],
|
||||
];
|
||||
for (const [label, description] of explanations) {
|
||||
await expect(page.getByText(description, { exact: true })).toBeHidden();
|
||||
await page.getByRole("button", { name: label, exact: true }).hover();
|
||||
await expect(page.getByRole("tooltip")).toHaveText(description);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(page.getByRole("tooltip")).toBeHidden();
|
||||
}
|
||||
|
||||
await page.getByRole("button", { name: "Expanded", exact: true }).click();
|
||||
const activity = page.getByRole("button", { name: "Activity details", exact: true });
|
||||
await activity.focus();
|
||||
await expect(page.getByRole("tooltip")).toHaveText("Keep activity details expanded by default.");
|
||||
await activity.press("Escape");
|
||||
await expect(page.getByRole("tooltip")).toBeHidden();
|
||||
await page.getByRole("button", { name: "Diff", exact: true }).click();
|
||||
const edits = page.getByRole("button", { name: "Edit preview", exact: true });
|
||||
await edits.focus();
|
||||
await expect(page.getByRole("tooltip")).toHaveText("Show code changes directly in the conversation.");
|
||||
});
|
||||
|
||||
test("changing a custom size reflows an existing composer and its mention layer", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto("/browser/fixture.html?case=typography");
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
|
||||
import { SettingsGroup, SettingsRow, SettingsSectionTitle } from "@/components/settings/shared/SettingsControls";
|
||||
import { SettingsHint } from "@/components/settings/shared/SettingsHint";
|
||||
import { ToggleButton } from "@/components/ui/toggle-button";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import type { ThemePreference } from "@/hooks/useTheme";
|
||||
@@ -66,18 +67,20 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<SettingsSectionTitle>{t("settings.appearance.process")}</SettingsSectionTitle>
|
||||
<p className="appearance-setting-help">{t("settings.appearance.processHelp")}</p>
|
||||
<SettingsSectionTitle>
|
||||
<SettingsHint description={t("settings.appearance.processHelp")}>{t("settings.appearance.process")}</SettingsHint>
|
||||
</SettingsSectionTitle>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.rows.activityMode")}>
|
||||
<SettingsRow title={t("settings.rows.activityMode")}
|
||||
description={t(`settings.appearance.${localPrefs.activityMode === "auto" ? "autoHelp" : "expandedHelp"}`)}>
|
||||
<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")}>
|
||||
<SettingsRow title={t("settings.rows.fileEditDisplay")}
|
||||
description={t(`settings.appearance.${editHelp[localPrefs.fileEditDisplayMode]}`)}>
|
||||
<SegmentedControl<FileEditDisplayMode> value={localPrefs.fileEditDisplayMode}
|
||||
ariaLabel={t("settings.rows.fileEditDisplay")}
|
||||
options={[
|
||||
@@ -87,7 +90,6 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr
|
||||
]}
|
||||
onChange={(fileEditDisplayMode) => onChangeLocalPrefs((previous) => ({ ...previous, fileEditDisplayMode }))} />
|
||||
</SettingsRow>
|
||||
<p className="appearance-setting-help">{t(`settings.appearance.${editHelp[localPrefs.fileEditDisplayMode]}`)}</p>
|
||||
</div>
|
||||
</SettingsGroup>
|
||||
</section>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ArrowUp } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { MarkdownText } from "@/components/MarkdownText";
|
||||
import { SettingsHint } from "@/components/settings/shared/SettingsHint";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
@@ -51,7 +52,9 @@ export function ReadingSettings({ preferences, onChange }: {
|
||||
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>
|
||||
<span className="text-control-label" id={`${id}-label`}>
|
||||
<SettingsHint description={t("settings.appearance.readingHelp")}>{t("settings.rows.readingTextSize")}</SettingsHint>
|
||||
</span>
|
||||
<div className="appearance-size-options">
|
||||
<SegmentedControl<ReadingTextSize>
|
||||
mode="radio"
|
||||
@@ -124,7 +127,6 @@ export function ReadingSettings({ preferences, onChange }: {
|
||||
</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"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/* 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-theme-miniature[data-mode="system"] { --mini-paper: linear-gradient(110deg, #fff calc(50% - 0.5px), #303030 calc(50% + 0.5px)); --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); }
|
||||
@@ -43,7 +43,6 @@
|
||||
.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); }
|
||||
|
||||
Reference in new issue
Block a user