Skip to content

Commit ae774aa

Browse files
committed
feat(web): polish settings page chrome
1 parent f059572 commit ae774aa

4 files changed

Lines changed: 38 additions & 67 deletions

File tree

packages/web/src/features/settings/components/settings-page.test.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ describe("SettingsPage", () => {
938938
expect(routerMocks.navigate).toHaveBeenCalledWith("/");
939939
});
940940

941-
it("renders a dedicated desktop header with the active section pill", async () => {
941+
it("renders a compact desktop header with only the settings title", async () => {
942942
const sendCommand = vi.fn().mockResolvedValue({});
943943
const store = createConnectedStore(sendCommand);
944944

@@ -948,16 +948,18 @@ describe("SettingsPage", () => {
948948
const mobileHeader = document.querySelector(
949949
".settings-header .mobile-page-header"
950950
) as HTMLElement | null;
951-
const sectionPill = document.querySelector(
952-
".settings-header__section-pill"
953-
) as HTMLElement | null;
951+
const headerCopy = document.querySelector(".settings-header__copy") as HTMLElement | null;
954952

955953
expect(desktopHeader).not.toBeNull();
956954
expect(mobileHeader).toBeNull();
957955
expect(screen.getByRole("heading", { name: "设置" })).toBeInTheDocument();
958-
expect(within(desktopHeader as HTMLElement).getByText("Coder Studio")).toBeInTheDocument();
959-
expect(sectionPill).not.toBeNull();
960-
expect(within(sectionPill as HTMLElement).getByText("通用")).toBeInTheDocument();
956+
expect(
957+
within(desktopHeader as HTMLElement).getByRole("button", { name: "返回" })
958+
).toBeInTheDocument();
959+
expect(headerCopy).not.toBeNull();
960+
expect(within(headerCopy as HTMLElement).queryByText("Coder Studio")).toBeNull();
961+
expect(within(headerCopy as HTMLElement).queryByText("设置已自动保存")).toBeNull();
962+
expect(document.querySelector(".settings-header__section-pill")).toBeNull();
961963
});
962964

963965
it("renders a mobile category list and returns from detail content to the settings root", async () => {

packages/web/src/features/settings/components/settings-page.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -550,19 +550,7 @@ export function SettingsPage() {
550550
<span>{t("action.back")}</span>
551551
</button>
552552
<div className="settings-header__copy">
553-
<div className="page-kicker settings-header__kicker">{t("app.name")}</div>
554553
<h1 className="page-title settings-header__title">{t("settings.title")}</h1>
555-
<p className="settings-header__summary meta-text">
556-
<span>{t(activeSectionMeta.labelKey)}</span>
557-
<span className="settings-header__summary-separator" aria-hidden="true">
558-
559-
</span>
560-
<span>{t("settings.autosave_hint")}</span>
561-
</p>
562-
</div>
563-
<div className="settings-header__section-pill">
564-
<ThemedIcon semantic={activeSectionMeta.iconSemantic} size={14} />
565-
<span>{t(activeSectionMeta.labelKey)}</span>
566554
</div>
567555
</div>
568556
)}

packages/web/src/styles/components.css

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -713,63 +713,39 @@
713713
}
714714

715715
.settings-header {
716-
padding: var(--sp-2) var(--sp-4);
716+
padding: var(--sp-1) var(--sp-4);
717717
background: var(--bg-surface);
718718
border-bottom: 1px solid var(--border);
719719
}
720720

721721
.settings-header__desktop {
722-
width: min(100%, calc(240px + var(--desktop-content-max-width) + (var(--sp-6) * 2)));
723-
margin: 0 auto;
722+
width: 100%;
723+
margin: 0;
724724
display: flex;
725725
align-items: center;
726-
gap: var(--sp-4);
726+
justify-content: flex-start;
727+
gap: var(--sp-3);
727728
}
728729

729730
.settings-header__back {
730731
flex-shrink: 0;
732+
min-height: 30px;
733+
font-size: var(--text-xs);
731734
}
732735

733736
.settings-header__copy {
734737
min-width: 0;
735738
display: flex;
736-
flex: 1;
739+
flex: 0 1 auto;
737740
flex-direction: column;
738-
gap: var(--sp-1);
741+
justify-content: flex-start;
742+
gap: 0;
739743
}
740744

741-
.settings-header__kicker,
742-
.settings-header__title,
743-
.settings-header__summary {
745+
.settings-header__title {
744746
margin: 0;
745-
}
746-
747-
.settings-header__summary {
748-
display: flex;
749-
flex-wrap: wrap;
750-
align-items: center;
751-
gap: var(--sp-2);
752-
color: var(--text-secondary);
753-
}
754-
755-
.settings-header__summary-separator {
756-
color: var(--text-tertiary);
757-
}
758-
759-
.settings-header__section-pill {
760-
display: inline-flex;
761-
align-items: center;
762-
gap: var(--sp-2);
763-
flex-shrink: 0;
764-
margin-left: auto;
765-
padding: var(--sp-2) var(--sp-3);
766-
background: var(--bg-panel);
767-
border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
768-
border-radius: var(--radius-full);
769-
color: var(--text-primary);
770-
font-size: var(--text-sm);
771-
font-weight: var(--font-medium);
772-
box-shadow: var(--shadow-sm);
747+
font-size: 18px;
748+
line-height: 1.05;
773749
}
774750

775751
.settings-body {
@@ -845,6 +821,8 @@
845821
.settings-content--fill-height {
846822
display: flex;
847823
flex-direction: column;
824+
align-items: center;
825+
justify-content: center;
848826
}
849827

850828
.settings-content-surface {

packages/web/src/styles/components.theme.test.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,12 @@ describe("components.css theme-sensitive surfaces", () => {
555555
const settingsPage = getLastRuleBlock(".settings-page");
556556
const baseSettingsHeader = getRuleBlocksFrom(stylesheet, ".settings-header")[0];
557557
const desktopSettingsHeader = getLastRuleBlock(".settings-header__desktop");
558-
const desktopSettingsSummary = getLastRuleBlock(".settings-header__summary");
559-
const desktopSettingsSectionPill = getLastRuleBlock(".settings-header__section-pill");
558+
const desktopSettingsCopy = getLastRuleBlock(".settings-header__copy");
559+
const desktopSettingsTitle = getLastRuleBlock(".settings-header__title");
560560
const settingsBody = getLastRuleBlock(".settings-body");
561561
const settingsSidebar = getLastRuleBlock(".settings-sidebar");
562562
const settingsContent = getLastRuleBlock(".settings-content");
563+
const settingsContentFillHeight = getLastRuleBlock(".settings-content--fill-height");
563564
const settingsNavItem = getLastRuleBlock(".settings-nav-item");
564565
const settingsNavItemHover = getLastRuleBlock(".settings-nav-item:hover");
565566
const settingsNavItemActive = getLastRuleBlock(".settings-nav-item-active");
@@ -581,16 +582,17 @@ describe("components.css theme-sensitive surfaces", () => {
581582
expect(settingsPage).toContain("background: var(--bg-page)");
582583
expect(baseSettingsHeader).toContain("background: var(--bg-surface)");
583584
expect(baseSettingsHeader).toContain("border-bottom: 1px solid var(--border)");
584-
expect(baseSettingsHeader).toContain("padding: var(--sp-2) var(--sp-4)");
585-
expect(desktopSettingsHeader).toContain(
586-
"width: min(100%, calc(240px + var(--desktop-content-max-width) + (var(--sp-6) * 2)))"
587-
);
588-
expect(desktopSettingsHeader).toContain("margin: 0 auto");
585+
expect(baseSettingsHeader).toContain("padding: var(--sp-1) var(--sp-4)");
586+
expect(desktopSettingsHeader).toContain("width: 100%");
587+
expect(desktopSettingsHeader).toContain("margin: 0");
589588
expect(desktopSettingsHeader).toContain("display: flex");
590-
expect(desktopSettingsSummary).toContain("color: var(--text-secondary)");
591-
expect(desktopSettingsSectionPill).toContain("background: var(--bg-panel)");
592-
expect(desktopSettingsSectionPill).toContain("border: 1px solid");
593-
expect(desktopSettingsSectionPill).toContain("border-radius: var(--radius-full)");
589+
expect(desktopSettingsHeader).toContain("align-items: center");
590+
expect(desktopSettingsHeader).toContain("justify-content: flex-start");
591+
expect(desktopSettingsCopy).toContain("justify-content: flex-start");
592+
expect(desktopSettingsCopy).toContain("flex: 0 1 auto");
593+
expect(desktopSettingsCopy).toContain("gap: 0");
594+
expect(desktopSettingsTitle).toContain("font-size: 18px");
595+
expect(desktopSettingsTitle).toContain("line-height: 1.05");
594596
expect(settingsBody).toContain("align-items: stretch");
595597
expect(settingsBody).toContain("background: var(--bg-page)");
596598
expect(settingsSidebar).toContain("background: var(--bg-panel)");
@@ -600,6 +602,7 @@ describe("components.css theme-sensitive surfaces", () => {
600602
expect(settingsContent).toContain("justify-content: center");
601603
expect(settingsContent).toContain("padding: var(--sp-6)");
602604
expect(settingsContent).toContain("background: var(--bg-page)");
605+
expect(settingsContentFillHeight).toContain("justify-content: center");
603606
expect(settingsNavItem).toContain("min-height: 40px");
604607
expect(settingsNavItem).toContain("border: 1px solid transparent");
605608
expect(settingsNavItem).toContain("border-radius: var(--radius-md)");

0 commit comments

Comments
 (0)