mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-04 13:39:32 +08:00
feat(settings): render preferences as a floating card
Settings used to replace the whole window: a fixed full-height shell with a 248px rail and sections drawn as bare hairlines. It now opens as a Claude-style preferences card — a scrimmed, rounded panel capped at 1080x820 (88dvh) with a 224px rail, and each section sits in its own bordered card so the page stays light without going full screen. Phones keep the full sheet because a floating card has no room there. The settings heading drops from the 30/32px feature-page title to a 20px card-scale heading via a local header instead of PageHeader, and the shared save/discard toolbar stays pinned inside the card.
This commit is contained in:
committed by
qiuqianyi66
parent
40d011c2fc
commit
a75e804e75
@@ -57,39 +57,57 @@ export default function SettingsMain({ children }: { children: React.ReactNode }
|
||||
)
|
||||
|
||||
return (
|
||||
// Settings is a floating preferences card, the way Claude's desktop
|
||||
// settings behaves: the app stays visible behind a scrim and the card keeps
|
||||
// its own rounded edge, so opening settings no longer replaces the whole
|
||||
// window. Phones have no room for a floating card and get the full sheet.
|
||||
<div
|
||||
className="fixed inset-0 flex h-dvh overflow-hidden bg-[var(--background)]"
|
||||
className="fixed inset-0 flex items-center justify-center overflow-hidden bg-[color-mix(in_srgb,var(--foreground)_18%,transparent)] p-0 md:p-6"
|
||||
data-settings-shell
|
||||
>
|
||||
<aside className="hidden w-[248px] shrink-0 flex-col border-r border-border/60 bg-[color-mix(in_srgb,var(--muted)_25%,var(--background))] md:flex">
|
||||
<div className="px-2.5 pb-1.5 pt-4">{returnButton}</div>
|
||||
<SettingsNav />
|
||||
</aside>
|
||||
<main className="flex min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<div className="flex h-14 shrink-0 items-center justify-between border-b border-border/50 px-3 md:hidden">
|
||||
{returnButton}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('Settings sections')}
|
||||
aria-expanded={mobileOpen}
|
||||
onClick={() => setMobileOpen(true)}
|
||||
className="rounded-md p-2 hover:bg-accent"
|
||||
<div
|
||||
data-settings-card
|
||||
className="flex h-dvh w-full min-w-0 flex-col overflow-hidden bg-[var(--background)] md:h-[min(820px,88dvh)] md:w-[min(1080px,94vw)] md:flex-row md:rounded-2xl md:border md:border-[color-mix(in_srgb,var(--border)_70%,transparent)] md:shadow-[0_28px_70px_-32px_rgba(0,0,0,0.45)]"
|
||||
>
|
||||
<aside className="hidden w-[224px] shrink-0 flex-col border-r border-[color-mix(in_srgb,var(--border)_55%,transparent)] bg-[color-mix(in_srgb,var(--muted)_18%,var(--background))] md:flex">
|
||||
<div className="flex items-center justify-between gap-1 px-3 pb-1 pt-3">
|
||||
<p className="truncate text-[13px] font-medium text-[var(--foreground)]">
|
||||
{t('Settings')}
|
||||
</p>
|
||||
{returnButton}
|
||||
</div>
|
||||
<SettingsNav />
|
||||
</aside>
|
||||
<main className="flex min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<div className="flex h-14 shrink-0 items-center justify-between border-b border-[color-mix(in_srgb,var(--border)_50%,transparent)] px-3 md:hidden">
|
||||
{returnButton}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('Settings sections')}
|
||||
aria-expanded={mobileOpen}
|
||||
onClick={() => setMobileOpen(true)}
|
||||
className="rounded-md p-2 hover:bg-accent"
|
||||
>
|
||||
<Menu size={20} />
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
ref={scroller}
|
||||
data-settings-scroll
|
||||
className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]"
|
||||
>
|
||||
<Menu size={20} />
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
ref={scroller}
|
||||
data-settings-scroll
|
||||
className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]"
|
||||
>
|
||||
<PageContainer ref={content} tabIndex={-1} className="pb-20 outline-none">
|
||||
<SettingsLoadStatusBanner />
|
||||
{children}
|
||||
</PageContainer>
|
||||
</div>
|
||||
<SettingsToolbar />
|
||||
</main>
|
||||
<PageContainer
|
||||
ref={content}
|
||||
tabIndex={-1}
|
||||
className="max-w-[780px] pb-16 pt-5 outline-none md:px-8 md:pt-7"
|
||||
>
|
||||
<SettingsLoadStatusBanner />
|
||||
{children}
|
||||
</PageContainer>
|
||||
</div>
|
||||
<SettingsToolbar />
|
||||
</main>
|
||||
</div>
|
||||
<Modal
|
||||
isOpen={mobileOpen}
|
||||
onClose={() => setMobileOpen(false)}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { PageHeader } from '@/components/layout/FeaturePage'
|
||||
import type {
|
||||
CatalogProfile,
|
||||
ServiceName,
|
||||
@@ -149,7 +148,7 @@ export function SettingRow({
|
||||
control: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col items-start justify-between gap-3 sm:flex-row sm:gap-6 border-t border-[color-mix(in_srgb,var(--border)_50%,transparent)] py-5 first:border-t-0">
|
||||
<div className="flex flex-col items-start justify-between gap-3 sm:flex-row sm:gap-6 border-t border-[color-mix(in_srgb,var(--border)_50%,transparent)] py-4 first:border-t-0">
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[14px] font-medium text-[var(--foreground)]">
|
||||
{title}
|
||||
@@ -166,6 +165,9 @@ export function SettingRow({
|
||||
}
|
||||
|
||||
// Page-level section group. Title + optional description, then children.
|
||||
// Settings renders as a floating preferences card (see SettingsMain), so each
|
||||
// section is its own card: one hairline-bordered surface with a quiet header,
|
||||
// and the rows inside keep dividing themselves with hairlines.
|
||||
export function SettingSection({
|
||||
title,
|
||||
description,
|
||||
@@ -176,33 +178,27 @@ export function SettingSection({
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<section className="mb-10">
|
||||
<header className="mb-3">
|
||||
<h2 className="text-[15px] font-semibold tracking-tight text-[var(--foreground)]">
|
||||
<section className="mb-4 rounded-xl border border-[color-mix(in_srgb,var(--border)_60%,transparent)] bg-[color-mix(in_srgb,var(--muted)_10%,var(--background))] px-4 md:px-5">
|
||||
<header className="pb-1 pt-3.5">
|
||||
<h2 className="text-[13.5px] font-semibold tracking-tight text-[var(--foreground)]">
|
||||
{title}
|
||||
</h2>
|
||||
{description && (
|
||||
<p className="mt-1 text-[13px] leading-relaxed text-[var(--muted-foreground)]">
|
||||
<p className="mt-1 text-[12.5px] leading-relaxed text-[var(--muted-foreground)]">
|
||||
{description}
|
||||
</p>
|
||||
)}
|
||||
</header>
|
||||
{/* A rule, not a box. The app divides with hairlines and whitespace —
|
||||
a bordered, tinted panel around rows that already separate
|
||||
themselves with hairlines was dividing the same content twice. The
|
||||
top rule is what tells a section where it starts, and it has to live
|
||||
here rather than on the first row because sections also hold custom
|
||||
content (theme tiles, previews) that draws no rule of its own. */}
|
||||
<div className="border-t border-[color-mix(in_srgb,var(--border)_60%,transparent)]">
|
||||
{children}
|
||||
</div>
|
||||
<div>{children}</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// Page heading shared across settings sub-pages. The global Save Draft / Apply
|
||||
// toolbar (which also shows where this module persists to) lives above this, so
|
||||
// each page just owns its title row.
|
||||
// each page just owns its title row. Settings is a compact preferences card,
|
||||
// not a feature page: the heading stays at card scale (20px) instead of the
|
||||
// 30/32px feature-page title, which is scoped to `.dt-page-title`.
|
||||
export function SettingsPageHeader({
|
||||
title,
|
||||
description,
|
||||
@@ -216,6 +212,32 @@ export function SettingsPageHeader({
|
||||
actions?: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<PageHeader title={title} description={description} action={actions} headingTour="tour-page-heading" />
|
||||
<header
|
||||
data-page-header
|
||||
data-level={1}
|
||||
className="mb-4 flex min-w-0 flex-col gap-3 sm:flex-row sm:items-end sm:justify-between"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<h1
|
||||
data-tour="tour-page-heading"
|
||||
className="text-[20px] font-semibold leading-tight tracking-[-0.02em] text-[var(--foreground)]"
|
||||
>
|
||||
{title}
|
||||
</h1>
|
||||
{description && (
|
||||
<p className="mt-1 max-w-2xl text-[12.5px] leading-relaxed text-[var(--muted-foreground)]">
|
||||
{description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{actions && (
|
||||
<div
|
||||
data-page-actions
|
||||
className="flex max-w-full shrink-0 flex-wrap items-center gap-2 [&>div]:max-w-full [&>div]:flex-wrap"
|
||||
>
|
||||
{actions}
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user