Skip to content

World's first open-source enterprise world model.

The remaining pages on one scale, and the baseline goes (#365)

WaylandYange04158f068f7
diff --git a/web/DESIGN.md b/web/DESIGN.md
index ca10655c..669f164d 100644
--- a/web/DESIGN.md
+++ b/web/DESIGN.md
@@ -36,7 +36,7 @@ Concretely, a page renders no raw `<button>`, `<input>`, `<textarea>` or `<selec
## How this is enforced
-`web/scripts/style-guard.mjs` scans `web/src/**/*.tsx` for the patterns above and fails CI on any hit outside `web/style-guard.baseline.json`. The baseline lists the pages that have not been migrated yet; a migration PR removes its pages from the baseline and cannot be merged until they pass. New files are never exempt. When the baseline is empty, the file goes.
+`web/scripts/style-guard.mjs` scans `web/src/**/*.tsx` for the patterns above and fails CI on any hit. It runs first in `pnpm build`. While the pages were being migrated, `web/style-guard.baseline.json` listed the ones not yet done; every page passes now and the file is gone. A new file is checked from its first commit.
## Migration order
diff --git a/web/src/pages/Account.tsx b/web/src/pages/Account.tsx
index 4613c80b..20c6decb 100644
--- a/web/src/pages/Account.tsx
+++ b/web/src/pages/Account.tsx
@@ -3,7 +3,11 @@ import { useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { api } from "../api";
import { S } from "../i18n";
-import { Loading } from "../ui";
+import {
+ Button,
+ Input,
+ Loading,
+} from "../ui";
import { toast } from "../toast";
import { Avatar } from "./UserMenu";
@@ -41,77 +45,72 @@ export function Account() {
const field = (label: string, node: React.ReactNode) => (
<div className="mb-4">
- <div className="mb-1 text-[11px] font-medium text-neutral-500">{label}</div>
+ <div className="mb-1 text-fine font-medium text-ink-3">{label}</div>
{node}
</div>
);
return (
<div className="max-w-lg p-8">
- <h1 className="u-title text-lg mb-6">{S.account.profileTitle}</h1>
+ <h1 className="u-title text-title mb-6">{S.account.profileTitle}</h1>
- <div className="glass rounded-2xl p-5 mb-4">
- <div className="flex items-center gap-4 mb-5">
+ <div className="glass rounded-xl p-6 mb-4">
+ <div className="flex items-center gap-4 mb-6">
<Avatar name={me.data.display_name} size={56} />
- <p className="text-xs text-neutral-500">{S.account.avatarHint}</p>
+ <p className="text-small text-ink-3">{S.account.avatarHint}</p>
</div>
{field(
S.account.displayName,
<div className="flex gap-2">
- <input
- className="input-dark flex-1 px-3 py-2 text-sm"
+ <Input className="flex-1"
value={displayName}
onChange={(e) => setName(e.target.value)}
/>
- <button
- className="u-btn u-btn-primary px-3.5 text-xs"
+ <Button variant="primary" size="sm"
disabled={!nameDirty || saveName.isPending}
onClick={() => saveName.mutate(displayName.trim())}
>
{S.account.save}
- </button>
+ </Button>
</div>,
)}
{field(
S.account.email,
- <div className="text-sm text-neutral-400 px-0.5">{me.data.email}</div>,
+ <div className="text-body text-ink-2 px-1">{me.data.email}</div>,
)}
</div>
- <div className="glass rounded-2xl p-5">
- <h2 className="text-[13px] font-medium text-neutral-200 mb-4">
+ <div className="glass rounded-xl p-6">
+ <h2 className="text-body font-medium text-ink mb-4">
{S.account.passwordTitle}
</h2>
{field(
S.account.currentPassword,
- <input
+ <Input className="w-full"
type="password"
autoComplete="current-password"
- className="input-dark w-full px-3 py-2 text-sm"
value={curPw}
onChange={(e) => setCurPw(e.target.value)}
/>,
)}
{field(
S.account.newPassword,
- <input
+ <Input className="w-full"
type="password"
autoComplete="new-password"
- className="input-dark w-full px-3 py-2 text-sm"
value={newPw}
onChange={(e) => setNewPw(e.target.value)}
/>,
)}
<div className="flex justify-end">
- <button
- className="u-btn u-btn-primary px-3.5 py-1.5 text-xs"
+ <Button variant="primary" size="sm"
disabled={!curPw || newPw.length < 8 || changePw.isPending}
onClick={() => changePw.mutate()}
>
{S.account.changePassword}
- </button>
+ </Button>
</div>
</div>
</div>
diff --git a/web/src/pages/AccountShell.tsx b/web/src/pages/AccountShell.tsx
index a0cbdae1..fe25289a 100644
--- a/web/src/pages/AccountShell.tsx
+++ b/web/src/pages/AccountShell.tsx
@@ -6,7 +6,12 @@ import { usePageTitle } from "../useTitle";
import { BookMarked, KeyRound, ShieldCheck, UserRound } from "lucide-react";
import { api, ApiError } from "../api";
import { S } from "../i18n";
-import { GithubMark, RAIL_CLS, SectionMark } from "../ui";
+import {
+ GithubMark,
+ RAIL_CLS,
+ rowClass,
+ SectionMark,
+} from "../ui";
import { ServerDown } from "./ServerDown";
import { UserMenu } from "./UserMenu";
@@ -19,7 +24,7 @@ export function AccountShell() {
if (me.isPending) {
return (
- <div className="min-h-screen flex items-center justify-center text-neutral-500 text-sm">
+ <div className="min-h-screen flex items-center justify-center text-ink-3 text-body">
{S.nav.loading}
</div>
);
@@ -32,19 +37,18 @@ export function AccountShell() {
return <ServerDown />;
}
- const rail =
- "flex items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] text-neutral-400 hover:bg-white/[0.05] hover:text-neutral-200";
- const railActive = "flex items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] u-nav-active";
+ const rail = rowClass(false, "nav");
+ const railActive = rowClass(true, "nav");
return (
<div className="h-screen flex flex-col overflow-hidden u-arrive">
{/* 顶栏与 Docs 页同构:分区字标(点击回城)+ 返回 + GitHub·版本 + 用户 */}
- <header className="glass-strong relative z-40 border-x-0 border-t-0 h-14 shrink-0 flex items-center px-5">
+ <header className="glass-strong relative z-40 border-x-0 border-t-0 h-14 shrink-0 flex items-center px-6">
<SectionMark text={S.account.brand} title={S.docs.backTitle} />
- <div className="ml-auto flex items-center gap-1.5">
+ <div className="ml-auto flex items-center gap-2">
<Link
to="/"
- className="px-2 py-1 rounded-lg text-[12.5px] text-neutral-500 hover:text-neutral-200 hover:bg-white/[0.05] transition-colors"
+ className="u-navlink"
>
{S.account.backToApp}
</Link>
@@ -53,12 +57,12 @@ export function AccountShell() {
target="_blank"
rel="noreferrer"
title="GitHub"
- className="flex items-center gap-1.5 rounded-full border border-white/10 px-2.5 py-1 text-neutral-500 hover:text-neutral-200 hover:border-white/25 transition-colors"
+ className="u-pill"
>
<GithubMark size={13} />
- {health.data && <span className="u-num text-[11px]">v{health.data.version}</span>}
+ {health.data && <span className="u-num text-fine">v{health.data.version}</span>}
</a>
- <div className="ml-1.5">
+ <div className="ml-2">
<UserMenu user={me.data} />
</div>
</div>
@@ -66,7 +70,7 @@ export function AccountShell() {
<div className="flex-1 min-h-0 flex">
{/* 账户导航栏(仅两项,管理员多一项) */}
- <aside className={`${RAIL_CLS} p-3 space-y-0.5`}>
+ <aside className={`${RAIL_CLS} p-3 space-y-1`}>
{/* exact:/account 是 /account/kbs 的前缀,默认前缀匹配会双亮 */}
<Link
to="/account"
diff --git a/web/src/pages/AlertBell.tsx b/web/src/pages/AlertBell.tsx
index eceaeb93..acfcd2b9 100644
--- a/web/src/pages/AlertBell.tsx
+++ b/web/src/pages/AlertBell.tsx
@@ -12,7 +12,15 @@ import { Bell, Search, X } from "lucide-react";
import { api, type AlertGroup } from "../api";
import { S } from "../i18n";
import { toast } from "../toast";
-import { Chip, Pager, cn } from "../ui";
+import {
+ Button,
+ Chip,
+ cn,
+ IconButton,
+ Input,
+ LinkButton,
+ Pager,
+} from "../ui";
import { usePopoverFlip } from "../ui/popoverFlip";
const PAGE = 8;
@@ -56,22 +64,22 @@ function AlertRow({
onKeyDown={(e) => {
if (e.key === "Enter" && g.unread > 0) onRead(g);
}}
- className="w-full text-left flex gap-2.5 px-3.5 py-3 border-b border-white/[0.06] last:border-b-0 hover:bg-white/[0.03] transition-colors cursor-pointer"
+ className="u-row-shell flex w-full cursor-pointer gap-3 border-b border-line px-4 py-3 text-left last:border-b-0"
>
{/* 未读就是一个红点。整行描边或底色会让面板在告警多时变成一片红,
而红点只占它该占的那一点地方,读过就没了 */}
<span
className={cn(
"mt-[7px] h-1.5 w-1.5 rounded-full shrink-0",
- g.unread > 0 ? "bg-rose-500" : "bg-transparent",
+ g.unread > 0 ? "bg-danger" : "bg-transparent",
)}
/>
<div className="min-w-0 flex-1">
- <div className="flex items-center gap-1.5 flex-wrap">
+ <div className="flex items-center gap-2 flex-wrap">
<span
className={cn(
- "text-[13px]",
- g.unread > 0 ? "font-medium text-white" : "text-neutral-400",
+ "text-body",
+ g.unread > 0 ? "font-medium text-ink" : "text-ink-2",
)}
>
{worded?.title ?? S.alerts.unknownKind(g.kind)}
@@ -82,33 +90,32 @@ function AlertRow({
</Chip>
</div>
{worded && (
- <p className="mt-0.5 text-[11.5px] text-neutral-500">{worded.hint}</p>
+ <p className="mt-1 text-small text-ink-3">{worded.hint}</p>
)}
{lines.length > 0 && (
- <ul className="mt-1 space-y-0.5">
+ <ul className="mt-1 space-y-1">
{lines.map((l, i) => (
- <li key={i} className="text-[11px] text-neutral-400 break-words">
+ <li key={i} className="text-fine text-ink-2 break-words">
{l}
</li>
))}
{rest > 0 && (
- <li className="text-[11px] text-neutral-600">
+ <li className="text-fine text-ink-3">
{S.alerts.andMore(rest)}
</li>
)}
</ul>
)}
{/* 时间取组里最新的那一次 */}
- <p className="u-num mt-1.5 text-[10.5px] text-neutral-600">
+ <p className="u-num mt-2 text-fine text-ink-3">
{new Date(g.latest_at).toLocaleString()}
</p>
{/* 修好之后接着跑:把这次故障窗口里失败的任务放回队列(#216)。
余额耗尽是唯一一种「人做完一件具体的事就想让活继续」的失败,
动作长在告警上,闭环就在这里,不必另建一个队列页 */}
{REQUEUE_KINDS.has(g.kind) && (
- <button
+ <Button variant="secondary" size="sm" className="mt-2"
type="button"
- className="u-btn u-btn-ghost mt-2 px-2.5 py-1 text-[11px]"
disabled={requeuing}
onClick={(e) => {
e.stopPropagation();
@@ -116,7 +123,7 @@ function AlertRow({
}}
>
{S.alerts.runAgain}
- </button>
+ </Button>
)}
</div>
</div>
@@ -175,45 +182,43 @@ function Panel({ panelRef }: { panelRef: Ref<HTMLDivElement> }) {
ref={panelRef}
className="u-menu-glass absolute right-0 top-0 w-[420px] rounded-xl shadow-2xl z-50 overflow-hidden"
>
- <div className="flex items-center gap-2 pl-3.5 pr-10 py-2.5 border-b border-white/10">
- <span className="text-[13px] font-medium text-neutral-100">
+ <div className="flex items-center gap-2 pl-4 pr-8 py-3 border-b border-line">
+ <span className="text-body font-medium text-ink">
{S.alerts.title}
</span>
</div>
{/* 跟文库的过滤框同一套:input-dark + 左侧图标 + 有值时右侧清除、Esc 清空 */}
- <div className="px-3.5 py-2.5 border-b border-white/[0.06]">
+ <div className="px-4 py-3 border-b border-line">
<div className="relative">
<Search
size={13}
- className="absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-500 pointer-events-none"
+ className="absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-3 pointer-events-none"
/>
- <input
- className="input-dark w-full pl-8 pr-7 py-1.5 text-[13px]"
+ <Input size="sm" className="w-full pl-8 pr-8"
placeholder={S.alerts.searchPlaceholder}
value={q}
onChange={(e) => setQ(e.target.value)}
onKeyDown={(e) => e.key === "Escape" && setQ("")}
/>
{q && (
- <button
+ <IconButton size="sm" label={S.ui.close} className="absolute right-2 top-1/2 -translate-y-1/2"
onClick={() => setQ("")}
- className="absolute right-2 top-1/2 -translate-y-1/2 text-neutral-500 hover:text-neutral-200"
>
<X size={12} />
- </button>
+ </IconButton>
)}
</div>
</div>
<div className="max-h-[420px] overflow-y-auto">
{groups.length === 0 ? (
- <div className="px-3.5 py-8 text-center">
- <p className="text-[13px] text-neutral-300">
+ <div className="px-4 py-8 text-center">
+ <p className="text-body text-ink-2">
{q ? S.alerts.noMatch : S.alerts.empty}
</p>
{!q && (
- <p className="mt-1 text-[11.5px] text-neutral-500">
+ <p className="mt-1 text-small text-ink-3">
{S.alerts.emptyHint}
</p>
)}
@@ -233,14 +238,11 @@ function Panel({ panelRef }: { panelRef: Ref<HTMLDivElement> }) {
{/* 底栏:整张列表级的动作跟翻页放一起,离光标最远 */}
{groups.length > 0 && (
- <div className="flex items-center gap-3 px-3.5 py-2 border-t border-white/[0.06]">
+ <div className="flex items-center gap-3 px-4 py-2 border-t border-line">
{groups.some((g) => g.unread > 0) && (
- <button
- className="text-[11.5px] text-neutral-500 hover:text-neutral-200 transition-colors"
- onClick={() => readAll.mutate()}
- >
+ <LinkButton onClick={() => readAll.mutate()}>
{S.alerts.markAllRead}
- </button>
+ </LinkButton>
)}
<Pager
className="ml-auto"
@@ -269,28 +271,21 @@ export function AlertBell() {
return (
<div ref={rootRef} className="relative">
- <button
+ <IconButton
+ size="sm"
ref={anchorRef}
- onClick={() => (open ? close() : setOpen(true))}
- title={S.alerts.badgeLabel}
- aria-label={S.alerts.badgeLabel}
+ label={S.alerts.badgeLabel}
aria-expanded={open}
- // h-7 w-7 正方形:只装一个图标的按钮不该是长方形。
- // 关闭按钮用同一组尺寸绝对定位在面板的 right-0 top-0,两者严丝合缝
- className={cn(
- "relative grid h-7 w-7 place-items-center rounded-lg transition-colors",
- open
- ? "text-neutral-200 bg-white/[0.06]"
- : "text-neutral-500 hover:text-neutral-200 hover:bg-white/[0.05]",
- )}
+ className={cn("relative", open && "bg-surface-2 text-ink")}
+ onClick={() => (open ? close() : setOpen(true))}
>
<Bell size={15} />
{/* 角标也是个点,不是数字。"有事没看"是二元的,具体几条打开就知道;
数字还会随重试一路往上跳,跳到三位数就把铃铛撑变形了 */}
{n > 0 && (
- <span className="absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-rose-500" />
+ <span className="absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-danger" />
)}
- </button>
+ </IconButton>
{open && (
<>
<Panel panelRef={panelRef} />
@@ -302,14 +297,14 @@ export function AlertBell() {
光标点开面板之后正停在这个位置,所以这儿必须是"再点一下关掉"。
放"全部标为已读"等于把误触做成默认动作,而它一下清掉的是
所有库的所有告警 */}
- <button
+ <IconButton
+ size="sm"
+ label={S.alerts.close}
+ className="absolute right-0 top-0 z-[60]"
onClick={close}
- title={S.alerts.close}
- aria-label={S.alerts.close}
- className="absolute right-0 top-0 z-[60] grid h-7 w-7 place-items-center rounded-lg text-neutral-500 hover:text-neutral-200 transition-colors"
>
<X size={15} />
- </button>
+ </IconButton>
</>
)}
</div>
diff --git a/web/src/pages/Chat.tsx b/web/src/pages/Chat.tsx
index 443603c2..0136c185 100644
--- a/web/src/pages/Chat.tsx
+++ b/web/src/pages/Chat.tsx
@@ -35,7 +35,17 @@ import {
import { S } from "../i18n";
import { toast } from "../toast";
import { useKb, useKbId } from "../kb";
-import { DangerConfirm, RAIL_CLS } from "../ui";
+import {
+ Button,
+ cn,
+ DangerConfirm,
+ IconButton,
+ Input,
+ RAIL_CLS,
+ REVEAL,
+ Row,
+ Textarea,
+} from "../ui";
import { liveAnswer, type LiveHandle, type Turn } from "../liveAnswer";
import { NodCard } from "./PendingFacts";
import { NextStep, nextStep, useReadiness } from "./NextStep";
@@ -355,11 +365,12 @@ export function Chat() {
/* Composer 卡:新对话首屏居中出场,进入对话后停靠底部(同一块 JSX 两处复用) */
const composerCard = (
- <div className="rounded-2xl border border-white/[0.12] bg-white/[0.04] backdrop-blur-md focus-within:border-white/30 transition-colors px-4 pt-3 pb-2">
- <textarea
+ <div className="u-composer px-4 pt-3 pb-2">
+ <Textarea
+ bare
ref={inputRef}
rows={1}
- className="w-full bg-transparent outline-none text-sm resize-none leading-relaxed max-h-48 u-scroll placeholder:text-neutral-600"
+ className="w-full resize-none text-body leading-relaxed max-h-48"
placeholder={S.ask.placeholder}
value={input}
onChange={(e) => {
@@ -377,77 +388,72 @@ export function Chat() {
}}
/>
<div className="flex items-center justify-between gap-3 pt-1">
- <div className="flex items-center gap-2.5 min-w-0">
+ <div className="flex items-center gap-3 min-w-0">
{/* 作用域 chip:提问点位可见"在问哪个库",切库沿用现有语义(开新会话) */}
<div ref={scopeRef} className="relative shrink-0">
- <button
- onClick={() => setScopeOpen((v) => !v)}
+ <Button
+ variant="ghost"
+ size="sm"
+ className="max-w-52"
title={S.ask.scopeLabel}
- className="flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs text-neutral-400 hover:text-neutral-200 hover:bg-white/[0.07] transition-colors max-w-52"
+ onClick={() => setScopeOpen((v) => !v)}
>
- <Database size={12} className="shrink-0 text-neutral-500" />
+ <Database size={12} className="shrink-0 text-ink-3" />
<span className="truncate">{kb?.name ?? "…"}</span>
<ChevronDown
size={11}
- className={`shrink-0 text-neutral-600 transition-transform ${
- scopeOpen ? "rotate-180" : ""
- }`}
+ className={cn("u-turn shrink-0 text-ink-3", scopeOpen && "rotate-180")}
/>
- </button>
+ </Button>
{scopeOpen && (
- <div className="u-pop u-pop-up absolute bottom-full mb-1.5 left-0 z-50 w-56 rounded-lg shadow-xl overflow-hidden">
- <div className="px-2.5 pt-2 pb-1 text-[9.5px] font-medium uppercase tracking-[0.1em] text-neutral-600 border-b border-white/5">
+ <div className="u-pop u-pop-up absolute bottom-full mb-2 left-0 z-50 w-56 rounded-lg shadow-xl overflow-hidden">
+ <div className="px-3 pt-2 pb-1 text-fine font-medium uppercase tracking-[0.1em] text-ink-3 border-b border-line">
{S.ask.scopeLabel}
</div>
<div className="u-scroll max-h-60 overflow-y-auto">
{kbs.map((k) => (
- <button
+ <Row
key={k.id}
+ density="menu"
+ active={k.id === kb?.id}
onClick={() => {
setScopeOpen(false);
if (k.id !== kb?.id) setKb(k.id);
}}
- className={`w-full flex items-center gap-2 text-left px-2.5 py-1.5 text-xs ${
- k.id === kb?.id
- ? "bg-white/[0.12] text-white"
- : "text-neutral-300 hover:bg-white/[0.06] hover:text-white"
- }`}
>
<span className="flex-1 min-w-0 truncate">{k.name}</span>
- {k.id === kb?.id && <Check size={12} className="shrink-0 text-neutral-400" />}
- </button>
+ {k.id === kb?.id && <Check size={12} className="shrink-0 text-ink-2" />}
+ </Row>
))}
</div>
</div>
)}
</div>
- <span className="text-[11px] text-neutral-600 truncate">{S.ask.composerHint}</span>
+ <span className="text-fine text-ink-3 truncate">{S.ask.composerHint}</span>
</div>
{streaming ? (
- <button
+ <IconButton
onClick={() => {
// **只停正在看的这一场**——切页面、换会话、换库都不打断(liveAnswer.ts),
// 别场照常写它们自己的条目
if (kb) liveAnswer.stop(kb.id, currentId);
}}
- title={S.ask.stop}
- className="h-8 w-8 shrink-0 rounded-lg grid place-items-center bg-white/[0.08] text-neutral-200 hover:bg-white/[0.14] transition-colors"
+ label={S.ask.stop}
+ variant="secondary"
+ className="shrink-0"
>
<Square size={11} fill="currentColor" />
- </button>
+ </IconButton>
) : (
- <button
- onClick={send}
+ <IconButton
+ variant={input.trim() ? "primary" : "secondary"}
+ className="shrink-0"
+ label={S.ask.send}
disabled={!input.trim()}
- title={S.ask.send}
- className={`h-8 w-8 shrink-0 rounded-lg grid place-items-center transition-colors ${
- input.trim()
- ? "bg-white text-black hover:bg-neutral-200"
- : "bg-white/[0.07] text-neutral-600"
- }`}
+ onClick={send}
>
<ArrowUp size={15} strokeWidth={2.4} />
- </button>
+ </IconButton>
)}
</div>
</div>
@@ -459,39 +465,32 @@ export function Chat() {
<aside className={`${RAIL_CLS} flex flex-col`}>
<div className="px-2 pt-3 pb-1">
{/* 与会话行同一套样式:左栏是一列同质的行,新对话只是第一行 */}
- <button
- onClick={newChat}
- className="w-full flex items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[13px] text-neutral-300 hover:bg-white/[0.05] hover:text-white transition-colors"
- >
- <SquarePen size={14} className="shrink-0 text-neutral-500" />
+ <Row density="nav" onClick={newChat}>
+ <SquarePen size={14} className="shrink-0 text-ink-3" />
{S.ask.newChat}
- </button>
+ </Row>
</div>
{/* 搜索。**标题重是常态**(同一个问题问两次就重了),而正文里那句话
才是人记得住的——所以服务端两处都搜 */}
<div className="px-2 pb-2">
- <input
- className="input-dark w-full px-2.5 py-1.5 text-[12.5px]"
+ <Input size="sm" className="w-full"
placeholder={S.ask.searchConversations}
value={convSearch}
onChange={(e) => setConvSearch(e.target.value)}
onKeyDown={(e) => e.key === "Escape" && setConvSearch("")}
/>
</div>
- <div className="u-scroll flex-1 overflow-y-auto px-2 pb-3 space-y-0.5">
+ <div className="u-scroll flex-1 overflow-y-auto px-2 pb-3 space-y-1">
{(convs.data?.conversations ?? []).map((c: ConversationRow) => (
<div
key={c.id}
- className={`group relative rounded-lg transition-colors ${
- c.id === activeId ? "u-nav-active" : "hover:bg-white/[0.05]"
- }`}
+ className="group relative"
>
{/* 单行标题;删除键悬停浮现(弹确认,不直接删) */}
{renamingId === c.id ? (
/* 就地编辑:Enter 保存、Esc 取消。改一个名字不值得弹对话框 */
- <input
+ <Input size="sm" className="w-full"
autoFocus
- className="input-dark w-full px-2 py-1.5 text-[13px]"
value={renameDraft}
onChange={(e) => setRenameDraft(e.target.value)}
onBlur={() => setRenamingId(null)}
@@ -502,29 +501,32 @@ export function Chat() {
}}
/>
) : (
- <button
+ <Row
+ density="nav"
+ active={c.id === activeId}
+ className="pr-8"
onClick={() => openConversation(c.id)}
- className="w-full text-left px-2.5 py-2"
>
<span
- className={`block truncate pr-5 text-[13px] ${
- c.id === activeId ? "text-white" : "text-neutral-300"
+ className={`block truncate pr-6 text-body ${
+ c.id === activeId ? "text-ink" : "text-ink-2"
}`}
>
{c.title || S.ask.untitled}
</span>
- </button>
+ </Row>
)}
{/* 三点菜单:**一个入口装下所有动作**。从前右边直接是删除,
而删除是这里最不该一步到位的那个 */}
{renamingId !== c.id && (
- <button
+ <IconButton
+ size="sm"
+ label={S.ask.moreActions}
+ className={cn(REVEAL, "absolute right-1 top-1/2 -translate-y-1/2")}
onClick={() => setMenuFor(menuFor === c.id ? null : c.id)}
- title={S.ask.moreActions}
- className="absolute right-2 top-1/2 -translate-y-1/2 hidden group-hover:block text-neutral-600 hover:text-neutral-200"
>
<MoreHorizontal size={14} />
- </button>
+ </IconButton>
)}
{menuFor === c.id && (
<>
@@ -535,8 +537,8 @@ export function Chat() {
onClick={() => setMenuFor(null)}
/>
<div className="glass-strong absolute right-2 top-8 z-20 w-32 rounded-lg py-1 shadow-xl">
- <button
- className="w-full px-3 py-1.5 text-left text-xs text-neutral-300 hover:bg-white/5"
+ <Row
+ density="menu"
onClick={() => {
setRenameDraft(c.title || "");
setRenamingId(c.id);
@@ -544,32 +546,33 @@ export function Chat() {
}}
>
{S.ask.rename}
- </button>
- <button
- className="w-full px-3 py-1.5 text-left text-xs text-neutral-300 hover:bg-white/5"
+ </Row>
+ <Row
+ density="menu"
onClick={() => {
navigator.clipboard?.writeText(c.title || "");
setMenuFor(null);
}}
>
{S.ask.copyTitle}
- </button>
- <button
- className="w-full px-3 py-1.5 text-left text-xs text-[var(--u-danger)] hover:bg-white/5"
+ </Row>
+ <Row
+ density="menu"
+ danger
onClick={() => {
setPendingDelete(c);
setMenuFor(null);
}}
>
{S.ask.deleteConversation}
- </button>
+ </Row>
</div>
</>
)}
</div>
))}
{convs.data?.conversations.length === 0 && (
- <p className="px-2.5 py-2 text-xs text-neutral-600">{S.ask.noConversations}</p>
+ <p className="px-3 py-2 text-small text-ink-3">{S.ask.noConversations}</p>
)}
</div>
</aside>
@@ -583,7 +586,7 @@ export function Chat() {
<div className="flex-1 px-4 pt-[22vh]">
<div className="w-full max-w-3xl mx-auto">
<h1
- className="text-center text-[26px] text-neutral-100 mb-9"
+ className="text-center text-[26px] text-ink mb-8"
style={{ fontFamily: "var(--font-brand)", letterSpacing: "0.03em" }}
>
{S.ask.greeting}
@@ -694,10 +697,10 @@ function orbState(kind?: ChatStep["kind"]): OrbState {
/** 思考指示:thinking-orbs 球体 + 当前动作(应用是深色定妆,theme 钉死 dark)。 */
function Thinking({ step }: { step?: ChatStep }) {
return (
- <span className="inline-flex items-center gap-2.5 text-neutral-500">
+ <span className="inline-flex items-center gap-3 text-ink-3">
<ThinkingOrb state={orbState(step?.kind)} size={20} theme="dark" />
{step && (
- <span className="text-xs truncate">
+ <span className="text-small truncate">
{step.label} · {step.detail}
</span>
)}
@@ -710,7 +713,7 @@ function TurnView({ turn, live }: { turn: Turn; live?: boolean }) {
if (turn.role === "user") {
return (
<div className="flex justify-end">
- <div className="u-bubble-user max-w-[85%] rounded-2xl rounded-tr-sm px-4 py-2 text-sm whitespace-pre-wrap text-neutral-100">
+ <div className="u-bubble-user max-w-[85%] rounded-xl rounded-tr-sm px-4 py-2 text-body whitespace-pre-wrap text-ink">
{turn.content}
</div>
</div>
@@ -723,7 +726,7 @@ function TurnView({ turn, live }: { turn: Turn; live?: boolean }) {
return (
<div className="max-w-[95%]">
{/* agent 回复无气泡:正文直接落在画布上(用户消息保留气泡以区分角色) */}
- <div className="py-1 text-sm text-neutral-200 leading-relaxed">
+ <div className="py-1 text-body text-ink leading-relaxed">
{/* **轨迹按发生的顺序穿在正文里。**
模型是边说边查的:说一句、调一次、再说一句。把调用整块提到最前面,
读起来就成了「先查七次再一口气说完」——那不是它做的事,而且相邻两次
@@ -733,14 +736,14 @@ function TurnView({ turn, live }: { turn: Turn; live?: boolean }) {
seg.kind === "steps" ? (
<div
key={i}
- className="my-2.5 space-y-1 border-l border-white/15 pl-2.5"
+ className="my-3 space-y-1 border-l border-line-strong pl-3"
>
{seg.steps.map((s, j) => (
<div key={j}>
- <div className="flex items-center gap-1.5 text-xs">
- <span className="text-neutral-600">{stepIcon(s.kind)}</span>
- <span className="text-neutral-400 truncate">{s.label}</span>
- <span className="text-neutral-600 shrink-0">· {s.detail}</span>
+ <div className="flex items-center gap-2 text-small">
+ <span className="text-ink-3">{stepIcon(s.kind)}</span>
+ <span className="text-ink-2 truncate">{s.label}</span>
+ <span className="text-ink-3 shrink-0">· {s.detail}</span>
</div>
{/* remember 那一步后面跟着确认卡(0015):这句话抽出的事实先等人点头。
抽取是异步的,卡片在任务完成时才长出来;回放时按同一个 chunk 重画 */}
@@ -761,7 +764,7 @@ function TurnView({ turn, live }: { turn: Turn; live?: boolean }) {
),
)}
{thinking && <Thinking step={lastStep} />}
- {turn.error && <div className="text-rose-400">{turn.error}</div>}
+ {turn.error && <div className="text-danger">{turn.error}</div>}
</div>
{/* **引用等答案说完再出。**
`sources` 是随检索一次次增量发来的,跟着渲染的话,一份还在生长的清单
@@ -778,10 +781,10 @@ function TurnView({ turn, live }: { turn: Turn; live?: boolean }) {
params={{ slug: s.slug! }}
hash={s.anchor || undefined}
title={s.excerpt}
- className="flex items-center gap-1.5 text-xs text-neutral-500 glass rounded-lg px-3 py-1.5 glass-hover hover:text-neutral-300"
+ className="u-card-link flex items-center gap-2 text-small text-ink-3 glass rounded-lg px-3 py-2 glass-hover"
>
- <span className="u-num text-[var(--u-accent)]">[{s.n}]</span>
- <BookOpen size={11} className="shrink-0 text-neutral-600" />
+ <span className="u-num text-accent">[{s.n}]</span>
+ <BookOpen size={11} className="shrink-0 text-ink-3" />
<span className="truncate">
{/* 引言节 heading 即文章名,避免 "X › X" */}
{s.heading && s.heading !== s.filename
@@ -796,9 +799,9 @@ function TurnView({ turn, live }: { turn: Turn; live?: boolean }) {
params={{ kbId, docId: s.document_id! }}
search={{ chunk: s.chunk_id }}
title={s.excerpt}
- className="block text-xs text-neutral-500 glass rounded-lg px-3 py-1.5 glass-hover hover:text-neutral-300"
+ className="u-card-link block text-small text-ink-3 glass rounded-lg px-3 py-2 glass-hover"
>
- <span className="u-num text-[var(--u-accent)]">[{s.n}]</span> {s.filename} ·{" "}
+ <span className="u-num text-accent">[{s.n}]</span> {s.filename} ·{" "}
{s.excerpt.slice(0, 60)}…
</Link>
),
diff --git a/web/src/pages/DocViewer.tsx b/web/src/pages/DocViewer.tsx
index f8b27ec6..a0981249 100644
--- a/web/src/pages/DocViewer.tsx
+++ b/web/src/pages/DocViewer.tsx
@@ -58,10 +58,10 @@ export function DocViewer() {
}, [detail.data, chunk]);
if (detail.isPending)
- return <div className="p-8 text-sm text-neutral-500">{S.doc.loading}</div>;
+ return <div className="p-8 text-body text-ink-3">{S.doc.loading}</div>;
if (detail.isError)
return (
- <div className="p-8 text-sm text-rose-400">
+ <div className="p-8 text-body text-danger">
{(detail.error as Error).message}
</div>
);
@@ -83,13 +83,13 @@ export function DocViewer() {
<div className="max-w-4xl mx-auto p-6">
<div className="mb-4 flex items-baseline justify-between gap-4">
<div>
- <h2 className="text-lg font-bold text-neutral-100 break-all">{doc.filename}</h2>
- <p className="mt-0.5 text-xs text-neutral-500">
+ <h2 className="text-title font-semibold text-ink break-all">{doc.filename}</h2>
+ <p className="mt-1 text-small text-ink-3">
{chunks.length} {S.doc.sections} · {(doc.size_bytes / 1024).toFixed(0)} KB ·{" "}
{new Date(doc.created_at).toLocaleDateString()}
</p>
</div>
- <Link to="/kb/$kbId/library" params={{ kbId }} className="shrink-0 text-sm text-[var(--u-accent)] hover:underline">
+ <Link to="/kb/$kbId/library" params={{ kbId }} className="u-link shrink-0 text-body">
{S.doc.backToLibrary}
</Link>
</div>
@@ -101,15 +101,15 @@ export function DocViewer() {
return (
<div key={c.id} ref={hit ? highlightRef : undefined} className="flex gap-3">
<div
- className={`flex-1 min-w-0 rounded-xl border p-4 text-sm leading-relaxed whitespace-pre-wrap border-white/10 transition-[border-color,background-color,box-shadow] duration-700 ${
- hit && flash ? "u-flash" : "bg-white/[0.04]"
+ className={`u-chunk flex-1 min-w-0 rounded-xl border p-4 text-body leading-relaxed whitespace-pre-wrap border-line ${
+ hit && flash ? "u-flash" : "bg-surface"
}`}
>
- <div className="mb-1.5 text-xs text-neutral-500">
+ <div className="mb-2 text-small text-ink-3">
{S.doc.section} {c.seq + 1}
{hit && (
<span
- className={`ml-2 text-[var(--u-accent)] transition-opacity duration-700 ${
+ className={`u-fade-slow ml-2 text-accent ${
flash ? "opacity-100" : "opacity-0"
}`}
>
@@ -122,29 +122,29 @@ export function DocViewer() {
{/* 抽取对照栏:这个分块产出了哪些事实(实体可跳图谱) */}
{facts.length > 0 && (
- <aside className="w-64 shrink-0 rounded-xl border border-white/10 bg-white/[0.02] p-3">
- <div className="mb-2 text-[10px] font-medium uppercase tracking-[0.08em] text-neutral-600">
+ <aside className="w-64 shrink-0 rounded-xl border border-line bg-surface p-3">
+ <div className="mb-2 text-fine font-medium uppercase tracking-[0.08em] text-ink-3">
{S.doc.extracted} · {facts.length}
</div>
<div className="space-y-2">
{facts.map((f) => {
const range = factRange(f);
return (
- <div key={f.fact_id} className="text-xs leading-snug">
+ <div key={f.fact_id} className="text-small leading-snug">
<div>
<Link
to="/kb/$kbId/graph"
params={{ kbId }}
search={{ entity: f.subject_id }}
- className="text-neutral-200 hover:text-white hover:underline underline-offset-2 decoration-white/30"
+ className="u-inline-link text-ink"
>
{f.subject}
</Link>
<span
className={
f.predicate === null
- ? "italic text-neutral-700"
- : "text-neutral-600"
+ ? "italic text-ink-3"
+ : "text-ink-3"
}
title={
f.predicate && f.inferred
@@ -160,15 +160,15 @@ export function DocViewer() {
to="/kb/$kbId/graph"
params={{ kbId }}
search={{ entity: f.object_id }}
- className="text-neutral-200 hover:text-white hover:underline underline-offset-2 decoration-white/30"
+ className="u-inline-link text-ink"
>
{f.object}
</Link>
) : (
- <span className="text-neutral-300">{f.object ?? ""}</span>
+ <span className="text-ink-2">{f.object ?? ""}</span>
)}
</div>
- {range && <div className="u-num text-[10.5px] text-neutral-500">{range}</div>}
+ {range && <div className="u-num text-fine text-ink-3">{range}</div>}
</div>
);
})}
diff --git a/web/src/pages/Docs.tsx b/web/src/pages/Docs.tsx
index 5e34cf6c..64a13189 100644
--- a/web/src/pages/Docs.tsx
+++ b/web/src/pages/Docs.tsx
@@ -8,7 +8,15 @@ import { Link, useNavigate, useParams } from "@tanstack/react-router";
import { Command, Search } from "lucide-react";
import { api } from "../api";
import { S } from "../i18n";
-import { GithubMark, SectionMark } from "../ui";
+import {
+ Button,
+ cn,
+ GithubMark,
+ Input,
+ Row,
+ rowClass,
+ SectionMark,
+} from "../ui";
import { UserMenu } from "./UserMenu";
import { usePageTitle } from "../useTitle";
import ingestMd from "../docs/ingest.md?raw";
@@ -52,7 +60,7 @@ function Highlighted({ text, q }: { text: string; q: string }) {
/* 命中词用警示琥珀:结果列表里一眼定位到匹配处 */
<mark
key={i}
- className="rounded-[3px] bg-[rgba(242,182,109,0.16)] px-0.5 text-[var(--u-warn)]"
+ className="u-mark"
>
{p}
</mark>
@@ -170,7 +178,7 @@ export function DocsPage() {
return (
<div className="h-screen flex flex-col overflow-hidden">
- <header className="glass-strong relative z-40 border-x-0 border-t-0 h-14 shrink-0 flex items-center px-5">
+ <header className="glass-strong relative z-40 border-x-0 border-t-0 h-14 shrink-0 flex items-center px-6">
<SectionMark text={S.docs.brand} title={S.docs.backTitle} />
{/* 居中搜索:检索打包在本地的全部文档;宽度对齐正文栏(max-w-3xl 去掉 px-8) */}
<div
@@ -178,14 +186,11 @@ export function DocsPage() {
className="absolute left-1/2 -translate-x-1/2 w-[min(44rem,55vw)]"
>
<div className="relative">
- <Search
- size={13}
- className="absolute left-3 top-1/2 -translate-y-1/2 text-neutral-500 pointer-events-none"
- />
- <input
+ <Input
+ size="sm"
+ className="w-full"
+ icon={<Search size={13} />}
ref={inputRef}
- className="input-dark w-full pr-14 py-1.5 text-[13px]"
- style={{ paddingLeft: "2.1rem" }}
placeholder={S.docs.searchPlaceholder}
value={q}
onChange={(e) => setQ(e.target.value)}
@@ -193,7 +198,7 @@ export function DocsPage() {
{/* 快捷键提示:输入中不占视线。⌘ 用 lucide 图标;
Ctrl 无图形符号(⌘ 是 Mac 专属键符),Windows 规范写法就是文字 */}
{!q && (
- <kbd className="pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 flex items-center gap-1 rounded border border-white/10 bg-white/[0.04] px-1.5 py-0.5 font-sans text-[10px] text-neutral-600">
+ <kbd className="pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 flex items-center gap-1 rounded-lg border border-line bg-surface px-2 py-1 font-sans text-fine text-ink-3">
{IS_MAC ? <Command size={9} /> : <span>Ctrl</span>}
<span>K</span>
</kbd>
@@ -202,22 +207,23 @@ export function DocsPage() {
{q.trim().length >= 2 && (
<div className="u-pop u-pop-in u-pop-in-tl absolute inset-x-0 top-full mt-2 rounded-xl shadow-2xl overflow-hidden">
{results.length === 0 ? (
- <p className="px-3.5 py-3 text-xs text-neutral-500">{S.docs.noResults}</p>
+ <p className="px-4 py-3 text-small text-ink-3">{S.docs.noResults}</p>
) : (
results.map((r, i) => (
- <button
+ <Row
key={i}
+ density="menu"
+ className="border-b border-line px-4 py-3 last:border-0"
onClick={() => {
setQ("");
navigate({ to: "/docs/$slug", params: { slug: r.slug } });
}}
- className="w-full text-left px-3.5 py-2.5 hover:bg-white/[0.06] border-b border-white/5 last:border-0"
>
- <div className="text-[11px] text-neutral-500">{r.title}</div>
- <div className="text-[13px] text-neutral-200 truncate">
+ <div className="text-fine text-ink-3">{r.title}</div>
+ <div className="text-body text-ink truncate">
<Highlighted text={r.snippet} q={q} />
</div>
- </button>
+ </Row>
))
)}
</div>
@@ -225,10 +231,10 @@ export function DocsPage() {
</div>
{/* 右侧:显式返回(与字标双路回城)+ GitHub·版本胶囊 + 登录态 */}
- <div className="ml-auto flex items-center gap-1.5">
+ <div className="ml-auto flex items-center gap-2">
<Link
to="/"
- className="px-2 py-1 rounded-lg text-[12.5px] text-neutral-500 hover:text-neutral-200 hover:bg-white/[0.05] transition-colors"
+ className="u-navlink"
>
{S.account.backToApp}
</Link>
@@ -237,10 +243,10 @@ export function DocsPage() {
target="_blank"
rel="noreferrer"
title="GitHub"
- className="flex items-center gap-1.5 rounded-full border border-white/10 px-2.5 py-1 text-neutral-500 hover:text-neutral-200 hover:border-white/25 transition-colors"
+ className="u-pill"
>
<GithubMark size={13} />
- {health.data && <span className="u-num text-[11px]">v{health.data.version}</span>}
+ {health.data && <span className="u-num text-fine">v{health.data.version}</span>}
</a>
{me.data ? (
<div className="ml-1">
@@ -249,7 +255,7 @@ export function DocsPage() {
) : me.isError ? (
<Link
to="/login"
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs"
+ className="u-btn u-btn-ghost px-3 py-2 text-small"
>
{S.login.signIn}
</Link>
@@ -264,17 +270,13 @@ export function DocsPage() {
className="flex-1 min-h-0 overflow-y-auto u-scroll"
>
<div className="flex items-start">
- <aside className="w-64 shrink-0 sticky top-0 h-[calc(100vh-3.5rem)] glass-strong border-y-0 border-l-0 p-3 space-y-0.5">
+ <aside className="w-64 shrink-0 sticky top-0 h-[calc(100vh-3.5rem)] glass-strong border-y-0 border-l-0 p-3 space-y-1">
{DOCS.map((d) => (
<Link
key={d.slug}
to="/docs/$slug"
params={{ slug: d.slug }}
- className={`block rounded-lg px-3 py-2 text-[13px] ${
- d.slug === doc.slug
- ? "u-nav-active"
- : "text-neutral-400 hover:bg-white/[0.05] hover:text-neutral-200"
- }`}
+ className={rowClass(d.slug === doc.slug, "nav")}
>
{d.title}
</Link>
@@ -315,23 +317,21 @@ export function DocsPage() {
{/* 右侧目录:sticky 钉住,与正文标题同一水平线起头 */}
{toc.length > 0 && (
<aside className="hidden lg:block w-64 shrink-0 sticky top-0 pt-16 pr-8">
- <nav className="space-y-0.5">
+ <nav className="space-y-1">
{toc.map((h) => (
- <button
+ <Button variant="ghost" size="sm"
key={h.id}
onClick={() =>
document.getElementById(h.id)?.scrollIntoView({ behavior: "smooth" })
}
- className={`block w-full text-left px-2 py-1.5 text-sm leading-snug transition-colors ${
- h.level === 3 ? "pl-5" : ""
- } ${
- activeHeading === h.id
- ? "text-white"
- : "text-neutral-500 hover:text-neutral-300"
- }`}
+ className={cn(
+ "h-auto w-full justify-start whitespace-normal py-2 text-left leading-snug",
+ h.level === 3 && "pl-6",
+ activeHeading === h.id ? "text-ink" : "text-ink-3",
+ )}
>
{h.text}
- </button>
+ </Button>
))}
</nav>
</aside>
diff --git a/web/src/pages/EntityHistory.tsx b/web/src/pages/EntityHistory.tsx
index 2b242001..a5f4595c 100644
--- a/web/src/pages/EntityHistory.tsx
+++ b/web/src/pages/EntityHistory.tsx
@@ -26,12 +26,12 @@ const KIND_ICON = {
} as const;
const KIND_TONE: Record<string, string> = {
- asserted: "text-neutral-500",
- corrected: "text-[var(--u-warn)]",
- rejected: "text-[var(--u-danger)]",
- merged: "text-neutral-500",
- retyped: "text-neutral-500",
- retype_reverted: "text-[var(--u-warn)]",
+ asserted: "text-ink-3",
+ corrected: "text-warn",
+ rejected: "text-danger",
+ merged: "text-ink-3",
+ retyped: "text-ink-3",
+ retype_reverted: "text-warn",
};
/* 这两个函数**故意不一样**,别"统一一下"——它们渲染的是两种时间。
@@ -85,37 +85,37 @@ function EventRow({ e }: { e: EntityHistoryEvent }) {
const Icon = KIND_ICON[e.kind] ?? FileText;
const note = intervalNote(e);
return (
- <div className="flex gap-2.5 px-2 py-2">
- <Icon size={13} className={`mt-0.5 shrink-0 ${KIND_TONE[e.kind] ?? ""}`} />
+ <div className="flex gap-3 px-2 py-2">
+ <Icon size={13} className={`mt-1 shrink-0 ${KIND_TONE[e.kind] ?? ""}`} />
<div className="min-w-0 flex-1">
- <div className="flex items-baseline gap-1.5 flex-wrap">
- <span className="text-[11px] font-medium text-neutral-300">
+ <div className="flex items-baseline gap-2 flex-wrap">
+ <span className="text-fine font-medium text-ink-2">
{S.graph.historyKind[e.kind] ?? e.kind}
</span>
- {note && <span className="u-num text-[11px] text-neutral-500">{note}</span>}
+ {note && <span className="u-num text-fine text-ink-3">{note}</span>}
</div>
{/* 改类事件没有谓词也没有宾语,正文换成类的两端。
起点为空 = 从「未分类」改过来,0009 之后最常见的一种 */}
{e.kind === "retyped" || e.kind === "retype_reverted" ? (
- <div className="mt-0.5 text-[12.5px] text-neutral-400 truncate">
- <span className="text-neutral-500">
+ <div className="mt-1 text-small text-ink-2 truncate">
+ <span className="text-ink-3">
{e.from_type_label ?? S.graph.untyped} →{" "}
</span>
- <span className="text-neutral-200">{e.to_type_label}</span>
+ <span className="text-ink">{e.to_type_label}</span>
</div>
) : (
- <div className="mt-0.5 text-[12.5px] text-neutral-400 truncate">
- <span className="text-neutral-500">
+ <div className="mt-1 text-small text-ink-2 truncate">
+ <span className="text-ink-3">
{e.direction === "in" ? "← " : ""}
- <span className={e.predicate_label === null ? "italic text-neutral-600" : undefined}>
+ <span className={e.predicate_label === null ? "italic text-ink-3" : undefined}>
{e.predicate_label ?? S.graph.unknownPredicate}
</span>
{e.direction === "in" ? "" : " →"}
</span>{" "}
- <span className="text-neutral-200">{objectText(e)}</span>
+ <span className="text-ink">{objectText(e)}</span>
</div>
)}
- <div className="mt-0.5 flex items-center gap-1.5 text-[10.5px] text-neutral-600">
+ <div className="mt-1 flex items-center gap-2 text-fine text-ink-3">
<span className="u-num">{ymd(e.at)}</span>
<span>·</span>
{/* 归因:人名,或引擎(抽取写入 / 时态对账自动闭合) */}
@@ -127,7 +127,7 @@ function EventRow({ e }: { e: EntityHistoryEvent }) {
to="/kb/$kbId/doc/$docId"
params={{ kbId, docId: e.document_id }}
search={{}}
- className="truncate hover:text-neutral-300"
+ className="u-hover-ink truncate"
title={e.quote ?? e.filename}
>
{e.filename}
@@ -149,15 +149,15 @@ export function EntityHistory({ kbId, entityId }: { kbId: string; entityId: stri
});
const total = q.data?.total ?? 0;
- if (q.isPending) return <p className="p-2 text-sm text-neutral-500">{S.nav.loading}</p>;
+ if (q.isPending) return <p className="p-2 text-body text-ink-3">{S.nav.loading}</p>;
// 只有"一条都没有"才是空。记录轴上首次断言本身就是一次事件——
// "我们何时、从哪份文档得知这件事"是这条轴要回答的问题的一半
- if (total === 0) return <p className="p-2 text-xs text-neutral-500">{S.graph.historyEmpty}</p>;
+ if (total === 0) return <p className="p-2 text-small text-ink-3">{S.graph.historyEmpty}</p>;
return (
<div>
- <p className="px-2 pb-1.5 text-[11px] text-neutral-600">{S.graph.historyHint}</p>
- <div className="divide-y divide-white/[0.06]">
+ <p className="px-2 pb-2 text-fine text-ink-3">{S.graph.historyHint}</p>
+ <div className="divide-y divide-line">
{/* key 里用 fact_id ?? at:改类事件没有 fact_id */}
{(q.data?.events ?? []).map((e) => (
<EventRow key={`${e.fact_id ?? e.at}-${e.kind}`} e={e} />
diff --git a/web/src/pages/KbScope.tsx b/web/src/pages/KbScope.tsx
index fa5125b8..adb75ab1 100644
--- a/web/src/pages/KbScope.tsx
+++ b/web/src/pages/KbScope.tsx
@@ -23,15 +23,15 @@ function KbNoAccess({ status }: { status: number }) {
return (
<div className="grid h-full place-items-center px-6">
<div className="max-w-sm text-center">
- <h2 className="text-[15px] text-neutral-200">
+ <h2 className="text-title text-ink">
{status === 404 ? S.kbScope.missingTitle : S.kbScope.deniedTitle}
</h2>
- <p className="mt-2 text-xs leading-relaxed text-neutral-500">
+ <p className="mt-2 text-small leading-relaxed text-ink-3">
{status === 404 ? S.kbScope.missingBody : S.kbScope.deniedBody}
</p>
<Link
to="/account/kbs"
- className="u-btn u-btn-ghost mt-4 inline-block px-3 py-1.5 text-xs"
+ className="u-btn u-btn-ghost mt-4 inline-block px-3 py-2 text-small"
>
{S.kbScope.myKbs}
</Link>
diff --git a/web/src/pages/KbSettings.tsx b/web/src/pages/KbSettings.tsx
index bf41dc56..51a761f2 100644
--- a/web/src/pages/KbSettings.tsx
+++ b/web/src/pages/KbSettings.tsx
@@ -15,12 +15,22 @@ import {
import { api, type AuditEvent } from "../api";
import { LANG_NAMES, S } from "../i18n";
import { toast } from "../toast";
-import { DangerConfirm,
+import {
+ Button,
+ Checkbox,
+ DangerConfirm,
Dropdown,
+ Input,
+ LinkButton,
Loading,
+ localDateTime,
+ NativeSelect,
Pager,
RAIL_CLS,
- SearchSelect, localDateTime } from "../ui";
+ Row,
+ SearchSelect,
+ Segmented,
+} from "../ui";
const KB_ROLES = [
{ value: "viewer", label: S.kbset.roles.viewer },
@@ -134,14 +144,12 @@ export function KbSettings() {
if (!kbId || kb.isPending) return <Loading>{S.nav.loading}</Loading>;
if (kb.isError)
return (
- <div className="p-8 text-sm text-rose-400">
+ <div className="p-8 text-body text-danger">
{(kb.error as Error).message}
</div>
);
- const lbl = "block text-xs font-medium text-neutral-500 mb-1";
- const rail =
- "w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-[13px] text-left transition-colors";
+ const lbl = "block text-small font-medium text-ink-3 mb-1";
const isDefault = kb.data.is_default;
const sections: {
@@ -169,37 +177,32 @@ export function KbSettings() {
return (
<div className="h-full flex">
{/* 分节导航:未来的抽取设置/保留策略/令牌等在此扩展 */}
- <aside className={`${RAIL_CLS} p-3 space-y-0.5`}>
+ <aside className={`${RAIL_CLS} p-3 space-y-1`}>
{sections.map(({ key, label, Icon, danger }) => (
- <button
+ <Row
key={key}
+ density="nav"
+ active={section === key}
+ danger={danger}
+ icon={<Icon size={14} />}
onClick={() => setSection(key)}
- className={`${rail} ${
- section === key
- ? "u-nav-active"
- : danger
- ? "text-neutral-500 hover:bg-white/[0.05] hover:text-[var(--u-danger)]"
- : "text-neutral-400 hover:bg-white/[0.05] hover:text-neutral-200"
- }`}
>
- <Icon size={14} />
{label}
- </button>
+ </Row>
))}
</aside>
<main className="flex-1 min-w-0 overflow-y-auto u-scroll px-8 py-6">
- <div className="max-w-xl space-y-5">
+ <div className="max-w-xl space-y-6">
{/* 不缀库名:顶栏切换器已标明当前库 */}
- <h2 className="u-title text-lg">{S.kbset.title}</h2>
+ <h2 className="u-title text-title">{S.kbset.title}</h2>
{section === "general" && (
<div className="glass rounded-xl p-4 space-y-3">
<div className="grid grid-cols-2 gap-2">
<div>
<label className={lbl}>{S.settings.kbs.name}</label>
- <input
- className="input-dark w-full px-3 py-2 text-sm"
+ <Input className="w-full"
value={name}
onChange={(e) => setName(e.target.value)}
/>
@@ -208,121 +211,83 @@ export function KbSettings() {
<label className={lbl}>{S.settings.kbs.visibility}</label>
{isDefault ? (
/* 默认库锁 open:说明常驻可见(藏在 hover 里等于没解释),详情见 grid 下方整行 */
- <div className="flex items-center gap-1.5 rounded-lg border border-white/10 px-2.5 py-2 text-[11px] text-neutral-500 cursor-not-allowed">
- <Lock size={11} className="shrink-0 text-neutral-600" />
+ <div className="flex items-center gap-2 rounded-lg border border-line px-3 py-2 text-fine text-ink-3 cursor-not-allowed">
+ <Lock size={11} className="shrink-0 text-ink-3" />
{S.kbset.defaultOpenLabel}
</div>
) : (
- <div className="flex rounded-lg overflow-hidden border border-white/10">
- {(
+ <Segmented
+ fill
+ size="sm"
+ value={visibility}
+ onChange={setVisibility}
+ options={(
[
["open", "Open"],
["restricted", S.settings.kbs.visRestricted],
] as const
- ).map(([v, label]) => (
- <button
- key={v}
- onClick={() => setVisibility(v)}
- title={label}
- className={`flex-1 px-2 py-2 text-[11px] truncate transition-colors ${
- visibility === v
- ? "bg-white/[0.12] text-white"
- : "text-neutral-500 hover:bg-white/[0.05] hover:text-neutral-300"
- }`}
- >
- {label}
- </button>
- ))}
- </div>
+ ).map(([v, label]) => ({ value: v, label, title: label }))}
+ />
)}
</div>
</div>
{isDefault && (
- <p className="text-xs leading-relaxed text-neutral-500">
+ <p className="text-small leading-relaxed text-ink-3">
{S.kbset.defaultOpenNote}
</p>
)}
<div>
<label className={lbl}>{S.settings.kbs.description}</label>
- <input
- className="input-dark w-full px-3 py-2 text-sm"
+ <Input className="w-full"
value={desc}
onChange={(e) => setDesc(e.target.value)}
/>
</div>
{/* 自动扩本体:默认开,因为新库的十个默认关系不是任何人选的。
说明里要讲清关掉之后失去的**只是**代劳,不是留意 */}
- <label className="flex items-start gap-2.5 pt-1 cursor-pointer">
- <input
- type="checkbox"
- className="mt-0.5 accent-[var(--u-accent)]"
- checked={autoExtend}
- onChange={(e) => setAutoExtend(e.target.checked)}
- />
- <span className="min-w-0">
- <span className="block text-sm text-neutral-200">
- {S.kbset.autoExtend}
- </span>
- <span className="block text-xs leading-relaxed text-neutral-500">
- {S.kbset.autoExtendNote}
- </span>
- </span>
- </label>
+ <Checkbox
+ className="pt-1"
+ checked={autoExtend}
+ onChange={(e) => setAutoExtend(e.target.checked)}
+ label={S.kbset.autoExtend}
+ hint={S.kbset.autoExtendNote}
+ />
{/* 物化推理:**默认关**,与上面那个相反。自动扩本体动的是词表,
这个动的是账本——它按公理往图里写事实,而声明可能是错的 */}
- <label className="flex items-start gap-2.5 pt-1 cursor-pointer">
- <input
- type="checkbox"
- className="mt-0.5 accent-[var(--u-accent)]"
- checked={materialize}
- onChange={(e) => setMaterialize(e.target.checked)}
- />
- <span className="min-w-0">
- <span className="block text-sm text-neutral-200">
- {S.kbset.materialize}
- </span>
- <span className="block text-xs leading-relaxed text-neutral-500">
- {S.kbset.materializeNote}
- </span>
- </span>
- </label>
+ <Checkbox
+ className="pt-1"
+ checked={materialize}
+ onChange={(e) => setMaterialize(e.target.checked)}
+ label={S.kbset.materialize}
+ hint={S.kbset.materializeNote}
+ />
{/* 类型消解自动跑:抽完排一轮,只自动改子树内精化的那一档,跨轴的仍留给人 */}
- <label className="flex items-start gap-2.5 pt-1 cursor-pointer">
- <input
- type="checkbox"
- className="mt-0.5 accent-[var(--u-accent)]"
- checked={autoResolve}
- onChange={(e) => setAutoResolve(e.target.checked)}
- />
- <span className="min-w-0">
- <span className="block text-sm text-neutral-200">
- {S.kbset.autoResolveTypes}
- </span>
- <span className="block text-xs leading-relaxed text-neutral-500">
- {S.kbset.autoResolveTypesNote}
- </span>
- </span>
- </label>
+ <Checkbox
+ className="pt-1"
+ checked={autoResolve}
+ onChange={(e) => setAutoResolve(e.target.checked)}
+ label={S.kbset.autoResolveTypes}
+ hint={S.kbset.autoResolveTypesNote}
+ />
{/* 重推间隔。**只在开着的时候露出来**——关着时它不影响任何事,
摆在那里只会让人以为设了就会推 */}
{materialize && (
<div className="pl-6 flex items-center gap-2">
- <label className="text-xs text-neutral-500">
+ <label className="text-small text-ink-3">
{S.kbset.inferEvery}
</label>
- <input
+ <Input size="sm" className="w-24 u-num"
type="number"
min={5}
max={10080}
- className="input-dark w-24 px-2 py-1 text-xs u-num"
value={inferMins}
onChange={(e) => setInferMins(Number(e.target.value))}
/>
- <span className="text-xs text-neutral-500">
+ <span className="text-small text-ink-3">
{S.kbset.minutes}
</span>
{kb.data.last_inference_at && (
- <span className="text-[11px] text-neutral-600">
+ <span className="text-fine text-ink-3">
{S.kbset.lastInference(
new Date(kb.data.last_inference_at).toLocaleString(),
)}
@@ -333,53 +298,46 @@ export function KbSettings() {
{/* 失败的任务(#216):有才露出来。「再跑一遍」把这个库里全部 failed 放回队列 */}
{failedJobs.data && failedJobs.data.failed > 0 && (
<div className="flex items-center gap-2">
- <span className="text-xs text-neutral-400">
+ <span className="text-small text-ink-2">
{S.kbset.failedJobs(failedJobs.data.failed)}
</span>
- <button
- className="u-btn u-btn-ghost px-2.5 py-1 text-xs"
+ <Button variant="secondary" size="sm"
disabled={requeue.isPending}
onClick={() => requeue.mutate()}
>
{S.kbset.requeue}
- </button>
+ </Button>
</div>
)}
{/* 语料语言。**不是界面语言**——类描述逐字进抽取提示词,
读者是正在读这些文档的模型,所以它跟文档走不跟读者走 */}
<div className="pt-1">
- <span className="block text-sm text-neutral-200">
+ <span className="block text-body text-ink">
{S.kbset.ontologyLang}
</span>
- <span className="mt-0.5 block text-xs leading-relaxed text-neutral-500">
+ <span className="mt-1 block text-small leading-relaxed text-ink-3">
{S.kbset.ontologyLangNote}
</span>
- <div className="mt-2 flex gap-1 rounded-lg bg-white/5 p-1 w-fit">
- {(["en", "zh"] as const).map((l) => (
- <button
- key={l}
- onClick={() => setOntoLang(l)}
- className={`rounded-md px-3 py-1 text-[12px] font-medium transition-colors ${
- ontoLang === l
- ? "bg-white/10 text-neutral-100"
- : "text-neutral-500 hover:text-neutral-300"
- }`}
- >
- {LANG_NAMES[l]}
- </button>
- ))}
- </div>
+ <Segmented
+ size="sm"
+ className="mt-2 w-fit"
+ value={ontoLang}
+ onChange={setOntoLang}
+ options={(["en", "zh"] as const).map((l) => ({
+ value: l,
+ label: LANG_NAMES[l],
+ }))}
+ />
</div>
<div className="flex items-center gap-3">
- <button
- className="u-btn u-btn-primary px-3.5 py-1.5 text-xs"
+ <Button variant="primary" size="sm"
disabled={!name.trim() || save.isPending}
onClick={() => save.mutate()}
>
{S.kbset.save}
- </button>
+ </Button>
{save.isSuccess && (
- <span className="text-xs text-neutral-400">
+ <span className="text-small text-ink-2">
{S.kbset.saved}
</span>
)}
@@ -394,17 +352,16 @@ export function KbSettings() {
{section === "activity" && <KbActivity kbId={kbId} />}
{section === "danger" && (
- <div className="glass rounded-2xl px-5 py-4 flex items-center justify-between gap-4">
+ <div className="glass rounded-xl px-6 py-4 flex items-center justify-between gap-4">
<div className="min-w-0">
- <div className="text-sm font-medium text-neutral-200">
+ <div className="text-body font-medium text-ink">
{S.kbset.deleteRowTitle}
</div>
- <div className="mt-0.5 text-xs text-neutral-500">
+ <div className="mt-1 text-small text-ink-3">
{S.kbset.deleteRowHint}
</div>
</div>
- <button
- className="u-btn px-3.5 py-1.5 text-xs font-semibold shrink-0"
+ <Button variant="secondary" size="sm" className="shrink-0"
style={{
background: "var(--u-danger-solid)",
color: "#ffffff",
@@ -412,11 +369,11 @@ export function KbSettings() {
onClick={() => setConfirmingDelete(true)}
>
{S.kbset.deleteRowBtn}
- </button>
+ </Button>
</div>
)}
- {error && <p className="text-sm text-rose-400">{error}</p>}
+ {error && <p className="text-body text-danger">{error}</p>}
{confirmingDelete && (
<DangerConfirm
@@ -478,10 +435,9 @@ function KbActivity({ kbId }: { kbId: string }) {
return (
<div className="glass rounded-xl p-4">
- <p className="text-xs text-neutral-500 mb-3">{S.kbset.activityHint}</p>
+ <p className="text-small text-ink-3 mb-3">{S.kbset.activityHint}</p>
<div className="mb-3 flex flex-wrap items-center gap-2">
- <select
- className="input-dark px-2 py-1 text-xs"
+ <NativeSelect size="sm"
value={action}
onChange={(e) => reset(() => setAction(e.target.value))}
>
@@ -491,25 +447,22 @@ function KbActivity({ kbId }: { kbId: string }) {
{a}
</option>
))}
- </select>
- <input
+ </NativeSelect>
+ <Input size="sm" className="u-num"
type="date"
- className="input-dark px-2 py-1 text-xs u-num"
value={since}
title={S.kbset.auditSince}
onChange={(e) => reset(() => setSince(e.target.value))}
/>
- <span className="text-xs text-neutral-600">→</span>
- <input
+ <span className="text-small text-ink-3">→</span>
+ <Input size="sm" className="u-num"
type="date"
- className="input-dark px-2 py-1 text-xs u-num"
value={until}
title={S.kbset.auditUntil}
onChange={(e) => reset(() => setUntil(e.target.value))}
/>
{filtered && (
- <button
- className="u-btn u-btn-ghost px-2 py-1 text-xs"
+ <Button variant="secondary" size="sm"
onClick={() =>
reset(() => {
setAction("");
@@ -519,28 +472,28 @@ function KbActivity({ kbId }: { kbId: string }) {
}
>
{S.kbset.auditClear}
- </button>
+ </Button>
)}
- <span className="ml-auto u-num text-[11px] text-neutral-500">
+ <span className="ml-auto u-num text-fine text-ink-3">
{S.kbset.auditTotal(total)}
</span>
</div>
{audit.isPending ? (
- <p className="text-xs text-neutral-600">{S.nav.loading}</p>
+ <p className="text-small text-ink-3">{S.nav.loading}</p>
) : events.length === 0 ? (
- <p className="text-xs text-neutral-600">{S.kbset.activityEmpty}</p>
+ <p className="text-small text-ink-3">{S.kbset.activityEmpty}</p>
) : (
- <div className="space-y-0.5">
+ <div className="space-y-1">
{events.map((e) => (
<div
key={e.id}
- className="flex items-baseline gap-3 py-1.5 text-[13px]"
+ className="flex items-baseline gap-3 py-2 text-body"
>
- <span className="u-num shrink-0 text-[11px] text-neutral-600">
+ <span className="u-num shrink-0 text-fine text-ink-3">
{localDateTime(e.created_at)}
</span>
<span className="min-w-0 truncate">
- <span className="text-neutral-200">
+ <span className="text-ink">
{e.actor_name ??
(e.actor_id
? S.kbset.deletedUser
@@ -548,11 +501,11 @@ function KbActivity({ kbId }: { kbId: string }) {
? S.kbset.adjudicator
: S.kbset.engine)}
</span>{" "}
- <span className="text-neutral-500">
+ <span className="text-ink-3">
{S.kbset.auditActions[e.action] ?? e.action}
</span>
{auditDetailName(e) && (
- <span className="text-neutral-300">
+ <span className="text-ink-2">
{" "}
“{auditDetailName(e)}”
</span>
@@ -610,20 +563,20 @@ function KbMembers({ kbId, isOpen }: { kbId: string; isOpen: boolean }) {
return (
<div className="glass rounded-xl p-4">
- <p className="text-xs text-neutral-500 mb-3">
+ <p className="text-small text-ink-3 mb-3">
{isOpen ? S.kbset.membersHintOpen : S.kbset.membersHintRestricted}
</p>
{members.data && listed.length === 0 && (
- <p className="text-xs text-neutral-600 mb-3">
+ <p className="text-small text-ink-3 mb-3">
{isOpen ? S.kbset.noWriters : S.kbset.noMembers}
</p>
)}
{listed.map((m) => (
- <div key={m.user_id} className="flex items-center gap-3 py-1.5">
+ <div key={m.user_id} className="flex items-center gap-3 py-2">
<div className="min-w-0 flex-1">
- <span className="text-sm text-neutral-200">{m.display_name}</span>
- <span className="ml-2 text-xs text-neutral-500">{m.email}</span>
+ <span className="text-body text-ink">{m.display_name}</span>
+ <span className="ml-2 text-small text-ink-3">{m.email}</span>
</div>
<Dropdown
size="sm"
@@ -632,12 +585,9 @@ function KbMembers({ kbId, isOpen }: { kbId: string; isOpen: boolean }) {
onChange={(role) => setMember.mutate({ userId: m.user_id, role })}
options={rolesFor(isOpen)}
/>
- <button
- onClick={() => remove.mutate(m.user_id)}
- className="text-xs text-neutral-500 hover:text-rose-400"
- >
+ <LinkButton tone="danger" onClick={() => remove.mutate(m.user_id)}>
{S.kbset.remove}
- </button>
+ </LinkButton>
</div>
))}
@@ -645,7 +595,7 @@ function KbMembers({ kbId, isOpen }: { kbId: string; isOpen: boolean }) {
一个时有时无的控件比一个空着的控件更让人困惑——不见了的第一反应是
功能坏了,而不是"没人可加"。空列表由 SearchSelect 自己说
(它有 noMatches 空态),这里不必再加一句话 */}
- <div className="mt-3 flex gap-2 items-center border-t border-white/5 pt-3">
+ <div className="mt-3 flex gap-2 items-center border-t border-line pt-3">
<SearchSelect
className="flex-1"
value={addUserId}
@@ -663,13 +613,12 @@ function KbMembers({ kbId, isOpen }: { kbId: string; isOpen: boolean }) {
onChange={setAddRole}
options={rolesFor(isOpen)}
/>
- <button
- className="u-btn u-btn-primary px-3 py-1.5 text-xs"
+ <Button variant="primary" size="sm"
disabled={!addUserId || setMember.isPending}
onClick={() => setMember.mutate({ userId: addUserId, role: addRole })}
>
{S.members.add}
- </button>
+ </Button>
</div>
</div>
);
diff --git a/web/src/pages/Legal.tsx b/web/src/pages/Legal.tsx
index d6cb7bea..77eb6631 100644
--- a/web/src/pages/Legal.tsx
+++ b/web/src/pages/Legal.tsx
@@ -21,34 +21,34 @@ function LegalPage({ doc }: { doc: LegalDocData }) {
<div className="mx-auto w-full max-w-xl">
<Link
to="/login"
- className="text-xs text-neutral-500 hover:text-neutral-300 transition-colors"
+ className="u-hover-ink text-small text-ink-3"
>
{S.legal.backToSignIn}
</Link>
<h1
- className="mt-6 text-3xl text-white"
+ className="mt-6 text-display text-ink"
style={{ fontFamily: "var(--font-brand)", letterSpacing: "0.04em" }}
>
{doc.title}
</h1>
- <p className="mt-3 text-xs text-neutral-600">{doc.note}</p>
- <div className="mt-9 space-y-7">
+ <p className="mt-3 text-small text-ink-3">{doc.note}</p>
+ <div className="mt-8 space-y-8">
{doc.sections.map((s) => (
<section key={s.h}>
- <h2 className="text-sm font-semibold text-neutral-200">{s.h}</h2>
+ <h2 className="text-body font-semibold text-ink">{s.h}</h2>
{s.body.map((p, i) => (
- <p key={i} className="mt-2 text-sm leading-relaxed text-neutral-400">
+ <p key={i} className="mt-2 text-body leading-relaxed text-ink-2">
{p}
</p>
))}
{s.bullets && (
- <ul className="mt-2 space-y-1.5">
+ <ul className="mt-2 space-y-2">
{s.bullets.map((b, i) => (
<li
key={i}
- className="relative pl-4 text-sm leading-relaxed text-neutral-400"
+ className="relative pl-4 text-body leading-relaxed text-ink-2"
>
- <span className="absolute left-0 text-neutral-600">–</span>
+ <span className="absolute left-0 text-ink-3">–</span>
{b}
</li>
))}
diff --git a/web/src/pages/Login.tsx b/web/src/pages/Login.tsx
index a93958ed..b80fc1ab 100644
--- a/web/src/pages/Login.tsx
+++ b/web/src/pages/Login.tsx
@@ -18,7 +18,12 @@ function GithubMark({ size = 16 }: { size?: number }) {
}
import { api, ApiError } from "../api";
import { S } from "../i18n";
-import { Wordmark } from "../ui";
+import {
+ Button,
+ Input,
+ Segmented,
+ Wordmark,
+} from "../ui";
import { LoginScene } from "./LoginScene";
import { usePageTitle } from "../useTitle";
@@ -50,7 +55,6 @@ export function Login() {
? S.login.networkError
: null;
- const input = "input-dark w-full px-3 py-2 text-sm";
return (
<div className="min-h-screen flex items-center justify-center px-4">
@@ -63,32 +67,26 @@ export function Login() {
<h1 className="text-5xl font-normal">
<Wordmark />
</h1>
- <p className="mt-2 text-sm text-neutral-400">
+ <p className="mt-2 text-body text-ink-2">
{S.app.tagline}
- <span className="ml-2 text-[11px]">{S.app.taglineSource}</span>
+ <span className="ml-2 text-fine">{S.app.taglineSource}</span>
</p>
</div>
<div
- className="u-card-opaque rounded-2xl p-6 u-rise"
+ className="u-card-opaque rounded-xl p-6 u-rise"
style={{ animationDelay: "90ms" }}
>
- <div className="flex gap-1 mb-5 bg-white/5 rounded-lg p-1">
- {(["login", "register"] as const).map((m) => (
- <button
- key={m}
- type="button"
- onClick={() => setMode(m)}
- className={`flex-1 rounded-md py-1.5 text-sm font-medium transition-colors ${
- mode === m
- ? "bg-white/10 text-neutral-100"
- : "text-neutral-500 hover:text-neutral-300"
- }`}
- >
- {m === "login" ? S.login.signIn : S.login.signUp}
- </button>
- ))}
- </div>
+ <Segmented
+ fill
+ className="mb-6"
+ value={mode}
+ onChange={setMode}
+ options={(["login", "register"] as const).map((m) => ({
+ value: m,
+ label: m === "login" ? S.login.signIn : S.login.signUp,
+ }))}
+ />
<form
className="space-y-3"
@@ -98,43 +96,42 @@ export function Login() {
}}
>
{mode === "register" && (
- <input
- className={input}
+ <Input
+ className="w-full"
placeholder={S.login.displayName}
value={displayName}
onChange={(e) => setDisplayName(e.target.value)}
required
/>
)}
- <input
+ <Input
type="email"
- className={input}
+ className="w-full"
placeholder={S.login.email}
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>
- <input
+ <Input
type="password"
- className={input}
+ className="w-full"
placeholder={S.login.password}
value={password}
onChange={(e) => setPassword(e.target.value)}
required
minLength={8}
/>
- {error && <p className="text-sm text-rose-400">{error}</p>}
- <button
+ {error && <p className="text-body text-danger">{error}</p>}
+ <Button variant="primary" size="md" className="w-full"
type="submit"
disabled={mutation.isPending || leaving}
- className="btn-primary w-full py-2 text-sm"
>
{mutation.isPending || leaving
? S.login.submitting
: mode === "login"
? S.login.signIn
: S.login.createAccount}
- </button>
+ </Button>
</form>
</div>
@@ -143,18 +140,18 @@ export function Login() {
className="mt-6 text-center u-rise"
style={{ animationDelay: "180ms" }}
>
- <p className="u-balance text-[11px] leading-relaxed text-neutral-600">
+ <p className="u-balance text-fine leading-relaxed text-ink-3">
{S.login.agreePrefix}
<Link
to="/terms"
- className="whitespace-nowrap text-neutral-500 underline decoration-white/20 underline-offset-2 hover:text-neutral-300 transition-colors"
+ className="u-link whitespace-nowrap"
>
{S.legal.termsTitle}
</Link>
{S.login.agreeAnd}
<Link
to="/privacy"
- className="whitespace-nowrap text-neutral-500 underline decoration-white/20 underline-offset-2 hover:text-neutral-300 transition-colors"
+ className="u-link whitespace-nowrap"
>
{S.legal.privacyTitle}
</Link>
@@ -165,7 +162,7 @@ export function Login() {
target="_blank"
rel="noreferrer"
title="GitHub"
- className="mt-3 inline-flex text-neutral-600 hover:text-neutral-300 transition-colors"
+ className="u-hover-ink mt-3 inline-flex text-ink-3"
>
<GithubMark size={16} />
</a>
diff --git a/web/src/pages/Mappings.tsx b/web/src/pages/Mappings.tsx
index 2143970d..c0dc6734 100644
--- a/web/src/pages/Mappings.tsx
+++ b/web/src/pages/Mappings.tsx
@@ -15,15 +15,19 @@ import { S } from "../i18n";
import { useKb } from "../kb";
import { toast } from "../toast";
import {
+ Button,
+ Checkbox,
Chip,
type ChipTone,
+ cn,
EmptyState,
ErrorText,
+ Input,
+ LinkButton,
Loading,
Pager,
PageTitle,
SearchSelect,
- cn,
} from "../ui";
const PAGE = 25;
@@ -89,28 +93,24 @@ export function Mappings() {
<div className="p-6 max-w-4xl mx-auto space-y-4">
<div>
<PageTitle>{S.mapping.title}</PageTitle>
- <p className="mt-1 text-xs text-neutral-500">{S.mapping.hint}</p>
+ <p className="mt-1 text-small text-ink-3">{S.mapping.hint}</p>
</div>
- {/* 分段控件用全站那一套(`bg-white/10` 选中 + 静默的未选中),
+ {/* 分段控件用全站那一套(`bg-surface-3` 选中 + 静默的未选中),
不是 `u-btn-primary`——那是主操作的实心白,用在这里每个标签都像
一个行动号召 */}
- <div className="flex w-fit rounded-lg overflow-hidden border border-white/10">
+ <div className="flex w-fit rounded-lg overflow-hidden border border-line">
{(["definitions", "sources"] as const).map((t) => (
- <button
+ <Button
+ variant={tab === t ? "primary" : "ghost"}
+ size="sm"
key={t}
- className={cn(
- "px-3 py-1.5 text-xs transition-colors",
- tab === t
- ? "bg-white/10 text-neutral-100"
- : "text-neutral-500 hover:bg-white/[0.05] hover:text-neutral-300",
- )}
onClick={() => setTab(t)}
>
{t === "definitions"
? S.mapping.tabDefinitions
: S.mapping.tabSources}
- </button>
+ </Button>
))}
</div>
@@ -119,16 +119,12 @@ export function Mappings() {
) : (
<>
<div className="flex items-center gap-2 flex-wrap">
- <div className="flex rounded-lg overflow-hidden border border-white/10">
+ <div className="flex rounded-lg overflow-hidden border border-line">
{FILTERS.map((f) => (
- <button
+ <Button
+ variant={status === f.key ? "primary" : "ghost"}
+ size="sm"
key={f.key}
- className={cn(
- "px-2.5 py-1.5 text-xs transition-colors flex items-center gap-1.5",
- status === f.key
- ? "bg-white/10 text-neutral-100"
- : "text-neutral-500 hover:bg-white/[0.05] hover:text-neutral-300",
- )}
onClick={() => {
setStatus(f.key);
setPage(0);
@@ -140,18 +136,19 @@ export function Mappings() {
className={cn(
"u-num",
status === f.key
- ? "text-neutral-300"
- : "text-neutral-600",
+ ? "text-ink-2"
+ : "text-ink-3",
)}
>
{f.n}
</span>
)}
- </button>
+ </Button>
))}
</div>
- <input
- className="u-input flex-1 min-w-40 px-3 py-1 text-xs"
+ <Input
+ size="sm"
+ className="flex-1 min-w-40"
placeholder={S.mapping.searchPlaceholder}
value={q}
onChange={(e) => {
@@ -162,7 +159,7 @@ export function Mappings() {
</div>
{status === "rejected" && (
- <p className="text-xs text-neutral-600">{S.mapping.rejectedHint}</p>
+ <p className="text-small text-ink-3">{S.mapping.rejectedHint}</p>
)}
{data.isPending ? (
@@ -224,32 +221,32 @@ function MappingCard({
return (
<div className="glass rounded-xl p-3">
<div className="flex items-baseline gap-2 flex-wrap">
- <span className="text-sm text-neutral-200">{m.concept_name}</span>
- <span className="text-[11px] text-neutral-500">{m.source}</span>
+ <span className="text-body text-ink">{m.concept_name}</span>
+ <span className="text-fine text-ink-3">{m.source}</span>
{m.unit && (
- <span className="text-[11px] text-neutral-500">[{m.unit}]</span>
+ <span className="text-fine text-ink-3">[{m.unit}]</span>
)}
{m.derived && (
- <Chip tone="warn" className="text-[11px]">
+ <Chip tone="warn" className="text-fine">
{S.mapping.derivedBadge}
</Chip>
)}
<span className="flex-1" />
- <Chip tone={TONE[m.status]} className="text-[11px]">
+ <Chip tone={TONE[m.status]} className="text-fine">
{statusLabel(m.status)}
</Chip>
</div>
<div
className={cn(
- "mt-1 u-num text-xs break-all",
- how ? "text-neutral-400" : "text-neutral-600",
+ "mt-1 u-num text-small break-all",
+ how ? "text-ink-2" : "text-ink-3",
)}
>
{how ?? S.mapping.noDefinition}
</div>
{m.summary && (
- <p className="mt-1 text-xs text-neutral-500">{m.summary}</p>
+ <p className="mt-1 text-small text-ink-3">{m.summary}</p>
)}
{editing ? (
@@ -263,39 +260,35 @@ function MappingCard({
onCancel={() => setEditing(false)}
/>
) : (
- <div className="mt-2 flex items-center gap-1.5 flex-wrap">
+ <div className="mt-2 flex items-center gap-2 flex-wrap">
{m.status === "proposed" && (
<>
- <button
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs"
+ <Button variant="secondary" size="sm"
disabled={decide.isPending}
onClick={() => decide.mutate("rejected")}
>
{S.mapping.reject}
- </button>
- <button
- className="u-btn u-btn-primary px-3 py-1.5 text-xs"
+ </Button>
+ <Button variant="primary" size="sm"
disabled={decide.isPending}
onClick={() => decide.mutate("confirmed")}
>
{S.mapping.approve}
- </button>
+ </Button>
</>
)}
- <button
- className="u-btn u-btn-ghost px-2 py-1 text-xs flex items-center gap-1"
+ <Button variant="secondary" size="sm" className="flex items-center gap-1"
onClick={() => setEditing(true)}
>
<Pencil size={11} />
{S.mapping.edit}
- </button>
- <button
- className="u-btn u-btn-ghost px-2 py-1 text-xs flex items-center gap-1"
+ </Button>
+ <Button variant="secondary" size="sm" className="flex items-center gap-1"
onClick={() => setShowHistory((v) => !v)}
>
<History size={11} />
{S.mapping.history}
- </button>
+ </Button>
</div>
)}
@@ -344,12 +337,10 @@ function EditForm({
mono = false,
) => (
<label className="block">
- <span className="text-[11px] text-neutral-500">{label}</span>
- <input
- className={cn(
- "u-input w-full px-2 py-1 text-xs mt-0.5",
- mono && "u-num",
- )}
+ <span className="text-fine text-ink-3">{label}</span>
+ <Input
+ size="sm"
+ className={cn("mt-1 w-full", mono && "u-num")}
value={value}
onChange={(e) => set(e.target.value)}
/>
@@ -357,8 +348,8 @@ function EditForm({
);
return (
- <div className="mt-3 space-y-2 border-t border-white/5 pt-3">
- <p className="text-[11px] text-neutral-500">{S.mapping.editTitle}</p>
+ <div className="mt-3 space-y-2 border-t border-line pt-3">
+ <p className="text-fine text-ink-3">{S.mapping.editTitle}</p>
<div className="grid grid-cols-2 gap-2">
{field(S.mapping.fieldTable, table, setTable, true)}
{field(S.mapping.fieldUnit, unit, setUnit)}
@@ -366,31 +357,28 @@ function EditForm({
{field(S.mapping.fieldExpr, expr, setExpr, true)}
{field(S.mapping.fieldSql, sql, setSql, true)}
{field(S.mapping.fieldSummary, summary, setSummary)}
- <label className="flex items-center gap-2 text-xs text-neutral-400">
- <input
- type="checkbox"
- checked={derived}
- onChange={(e) => setDerived(e.target.checked)}
- />
- {S.mapping.fieldDerived}
- </label>
+ <Checkbox
+ checked={derived}
+ onChange={(e) => setDerived(e.target.checked)}
+ label={S.mapping.fieldDerived}
+ />
+ <span className="hidden">
+ </span>
{nothing && (
- <p className="text-xs text-[var(--u-danger)]">{S.mapping.needOne}</p>
+ <p className="text-small text-danger">{S.mapping.needOne}</p>
)}
- <div className="flex gap-1.5">
- <button
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs"
+ <div className="flex gap-2">
+ <Button variant="secondary" size="sm"
onClick={onCancel}
>
{S.mapping.cancel}
- </button>
- <button
- className="u-btn u-btn-primary px-3 py-1.5 text-xs"
+ </Button>
+ <Button variant="primary" size="sm"
disabled={nothing || save.isPending}
onClick={() => save.mutate()}
>
{S.mapping.save}
- </button>
+ </Button>
</div>
</div>
);
@@ -415,31 +403,31 @@ function RevisionList({
// 一条改过口径的记录被说成从没改过,比报错难查得多
if (revs.isError)
return (
- <div className="mt-3 border-t border-white/5 pt-3">
+ <div className="mt-3 border-t border-line pt-3">
<ErrorText>{(revs.error as Error).message}</ErrorText>
</div>
);
const list = revs.data?.revisions ?? [];
return (
- <div className="mt-3 border-t border-white/5 pt-3 space-y-2">
- <p className="text-[11px] text-neutral-500">{S.mapping.historyHint}</p>
+ <div className="mt-3 border-t border-line pt-3 space-y-2">
+ <p className="text-fine text-ink-3">{S.mapping.historyHint}</p>
{list.length === 0 ? (
- <p className="text-xs text-neutral-600">{S.mapping.historyEmpty}</p>
+ <p className="text-small text-ink-3">{S.mapping.historyEmpty}</p>
) : (
list.map((r) => {
const b = r.before;
const was = (b.sql ?? b.expr ?? b.table_name) as string | null;
return (
- <div key={r.id} className="text-xs">
- <div className="text-neutral-500">
+ <div key={r.id} className="text-small">
+ <div className="text-ink-3">
{S.mapping.historyBy(
r.changed_by_name ?? S.mapping.historyUnknown,
)}
- <span className="u-num ml-2 text-neutral-600">
+ <span className="u-num ml-2 text-ink-3">
{r.changed_at.slice(0, 16).replace("T", " ")}
</span>
</div>
- <div className="u-num text-neutral-400 break-all">
+ <div className="u-num text-ink-2 break-all">
{was ?? S.mapping.noDefinition}
</div>
</div>
@@ -520,35 +508,35 @@ function DataSources({
return (
<div className="space-y-4">
- <p className="text-xs text-neutral-500">{S.mapping.sourcesHint}</p>
+ <p className="text-small text-ink-3">{S.mapping.sourcesHint}</p>
- <div className="glass rounded-xl divide-y divide-white/5">
+ <div className="glass rounded-xl divide-y divide-line">
{(mounted.data?.data_sources ?? []).map((d) => (
<div key={d.id} className="px-4 py-3 flex items-center gap-3">
<div className="min-w-0 flex-1">
- <div className="text-sm text-neutral-200">{d.name}</div>
- <div className="text-xs text-neutral-500 u-num truncate">
+ <div className="text-body text-ink">{d.name}</div>
+ <div className="text-small text-ink-3 u-num truncate">
{d.summary}
</div>
</div>
- <button
- className="u-btn u-btn-ghost px-2.5 py-1 text-xs shrink-0"
+ <Button variant="secondary" size="sm" className="shrink-0"
disabled={sync.isPending}
onClick={() => sync.mutate(d.id)}
>
{S.mapping.syncSchema}
- </button>
- <button
- className="text-xs text-neutral-500 hover:text-[var(--u-danger)] shrink-0"
+ </Button>
+ <LinkButton
+ tone="danger"
+ className="shrink-0"
disabled={unmount.isPending}
onClick={() => unmount.mutate(d.id)}
>
{S.mapping.unmount}
- </button>
+ </LinkButton>
</div>
))}
{!hasMounted && (
- <p className="px-4 py-6 text-sm text-neutral-500">
+ <p className="px-4 py-6 text-body text-ink-3">
{S.mapping.sourcesEmpty}
</p>
)}
@@ -567,31 +555,32 @@ function DataSources({
onChange={setPicked}
placeholder={S.mapping.mount + "…"}
/>
- <button
- className="u-btn u-btn-primary px-3.5 py-1.5 text-xs shrink-0"
+ <Button variant="primary" size="sm" className="shrink-0"
disabled={!picked || mount.isPending}
onClick={() => mount.mutate(picked)}
>
{S.mapping.mount}
- </button>
+ </Button>
</div>
)}
{me.data?.is_admin ? (
- <button
- className="flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-300 transition-colors"
+ <Button
+ variant="ghost"
+ size="sm"
+ className="-ml-2"
onClick={() =>
navigate({ to: "/admin", search: { tab: "datasources" } })
}
>
<Plus size={12} />
{S.mapping.newConn}
- </button>
+ </Button>
) : (
mountable.length === 0 &&
available.data &&
!hasMounted && (
- <p className="text-xs text-neutral-600">
+ <p className="text-small text-ink-3">
{S.mapping.sourcesNoneAvailable}
</p>
)
@@ -599,20 +588,19 @@ function DataSources({
{hasMounted && (
<div className="glass rounded-xl px-4 py-3 flex items-center gap-3">
- <p className="text-xs text-neutral-500 flex-1">
+ <p className="text-small text-ink-3 flex-1">
{S.mapping.exploreHint}
</p>
- <button
- className="u-btn u-btn-ghost px-2.5 py-1 text-xs shrink-0"
+ <Button variant="secondary" size="sm" className="shrink-0"
disabled={explore.isPending}
onClick={() => explore.mutate()}
>
{S.mapping.explore}
- </button>
+ </Button>
</div>
)}
- {notice && <p className="text-xs text-[var(--u-ok)]">{notice}</p>}
- {warning && <p className="text-xs text-[var(--u-warn)]">{warning}</p>}
+ {notice && <p className="text-small text-ok">{notice}</p>}
+ {warning && <p className="text-small text-warn">{warning}</p>}
</div>
);
}
diff --git a/web/src/pages/Members.tsx b/web/src/pages/Members.tsx
index d747a22e..5407be54 100644
--- a/web/src/pages/Members.tsx
+++ b/web/src/pages/Members.tsx
@@ -3,7 +3,16 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { api } from "../api";
import { S } from "../i18n";
import { toast } from "../toast";
-import { DangerConfirm, Dropdown, Pager, pageSlice, SearchSelect } from "../ui";
+import {
+ Button,
+ DangerConfirm,
+ Dropdown,
+ Input,
+ LinkButton,
+ Pager,
+ pageSlice,
+ SearchSelect,
+} from "../ui";
const ROLES = ["owner", "admin", "editor", "viewer"] as const;
const ROLE_OPTIONS = ROLES.map((r) => ({ value: r, label: S.members.roles[r] }));
@@ -61,11 +70,10 @@ export function Members({ workspaceId }: { workspaceId: string }) {
const { rows: pagedMembers, safe: safeMemberPage } = pageSlice(memberList, memberPage, MEMBER_PAGE);
return (
- <div className="glass rounded-xl p-5">
+ <div className="glass rounded-xl p-6">
<div className="flex items-center gap-3 mb-3">
- <h3 className="text-sm font-bold text-neutral-200">{S.members.title}</h3>
- <input
- className="input-dark ml-auto w-56 px-2.5 py-1 text-xs"
+ <h3 className="text-body font-semibold text-ink">{S.members.title}</h3>
+ <Input size="sm" className="ml-auto w-56"
placeholder={S.settings.searchUsers}
value={filter}
onChange={(e) => {
@@ -75,22 +83,22 @@ export function Members({ workspaceId }: { workspaceId: string }) {
/>
</div>
- {error && <p className="mb-3 text-sm text-rose-400">{error}</p>}
+ {error && <p className="mb-3 text-body text-danger">{error}</p>}
- <table className="w-full text-sm">
+ <table className="w-full text-body">
<tbody>
{pagedMembers.map((m) => (
- <tr key={m.user_id} className="border-b border-white/5">
+ <tr key={m.user_id} className="border-b border-line">
<td className="py-2 pr-3">
- <div className="text-neutral-200">
+ <div className="text-ink">
{m.display_name}
{m.is_admin && (
- <span className="ml-1.5 rounded bg-[rgba(74,163,255,0.12)] px-1.5 py-0.5 text-[10px] text-[var(--u-accent)]">
+ <span className="ml-2 rounded-lg bg-[rgba(74,163,255,0.12)] px-2 py-1 text-fine text-accent">
{S.members.systemAdmin}
</span>
)}
</div>
- <div className="text-xs text-neutral-500">{m.email}</div>
+ <div className="text-small text-ink-3">{m.email}</div>
</td>
<td className="py-2 pr-3 text-right">
<Dropdown
@@ -102,25 +110,23 @@ export function Members({ workspaceId }: { workspaceId: string }) {
/>
</td>
<td className="py-2 text-right whitespace-nowrap">
- <button
- onClick={() => remove.mutate(m.user_id)}
- className="text-xs text-neutral-500 hover:text-rose-400"
- >
+ <LinkButton tone="danger" onClick={() => remove.mutate(m.user_id)}>
{S.members.remove}
- </button>
+ </LinkButton>
{/* 停用账号跟「移出工作区」是两件事:前者断掉整个系统的访问,
后者只是这个工作区不再有他。所以分开两个按钮,而且停用
只给管理员看——它的影响面大得多 */}
{me.data?.is_admin && me.data.id !== m.user_id && (
- <button
+ <LinkButton
+ tone="danger"
onClick={() =>
setDeactivating({ id: m.user_id, name: m.display_name })
}
- className="ml-3 text-xs text-neutral-600 hover:text-rose-400"
+ className="ml-3"
title={S.members.deactivateHint}
>
{S.members.deactivate}
- </button>
+ </LinkButton>
)}
</td>
</tr>
@@ -156,13 +162,12 @@ export function Members({ workspaceId }: { workspaceId: string }) {
onChange={setAddRole}
options={ROLE_OPTIONS}
/>
- <button
+ <Button variant="primary" size="sm"
onClick={() => addUserId && setRole.mutate({ userId: addUserId, role: addRole })}
disabled={!addUserId}
- className="u-btn u-btn-primary px-3 py-1.5 text-sm"
>
{S.members.add}
- </button>
+ </Button>
</div>
{me.data?.is_admin && <CreateUser onCreated={refresh} />}
@@ -213,29 +218,28 @@ function DeactivatedUsers({ onChanged }: { onChanged: () => void }) {
return (
<div className="mt-6">
- <h4 className="text-[13px] text-neutral-300">
+ <h4 className="text-body text-ink-2">
{S.members.deactivatedTitle}
</h4>
- <p className="mt-0.5 text-[11px] leading-relaxed text-neutral-500">
+ <p className="mt-1 text-fine leading-relaxed text-ink-3">
{S.members.deactivatedHint}
</p>
<div className="mt-2 space-y-1">
{users.map((u) => (
<div
key={u.id}
- className="flex items-center gap-2 rounded border border-white/10 px-2.5 py-1.5"
+ className="flex items-center gap-2 rounded-lg border border-line px-3 py-2"
>
- <span className="text-[13px] text-neutral-300">
+ <span className="text-body text-ink-2">
{u.display_name}
</span>
- <span className="text-[11px] text-neutral-600">{u.email}</span>
- <button
- className="ml-auto u-btn u-btn-ghost px-2 py-0.5 text-xs"
+ <span className="text-fine text-ink-3">{u.email}</span>
+ <Button variant="secondary" size="sm" className="ml-auto"
disabled={revive.isPending}
onClick={() => revive.mutate(u.id)}
>
{S.members.reactivate}
- </button>
+ </Button>
</div>
))}
</div>
@@ -268,23 +272,20 @@ function CreateUser({ onCreated }: { onCreated: () => void }) {
const valid = email.includes("@") && name.trim() && password.length >= 8;
return (
- <div className="mt-5 border-t border-white/10 pt-4">
- <h4 className="text-xs font-bold text-neutral-400 mb-2">{S.settings.newUser}</h4>
+ <div className="mt-6 border-t border-line pt-4">
+ <h4 className="text-small font-semibold text-ink-2 mb-2">{S.settings.newUser}</h4>
<div className="grid grid-cols-2 gap-2 mb-2">
- <input
- className="input-dark px-3 py-2 text-sm"
+ <Input
placeholder={S.login.email}
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
- <input
- className="input-dark px-3 py-2 text-sm"
+ <Input
placeholder={S.login.displayName}
value={name}
onChange={(e) => setName(e.target.value)}
/>
- <input
- className="input-dark px-3 py-2 text-sm"
+ <Input
type="password"
placeholder={S.settings.initialPassword}
value={password}
@@ -301,14 +302,13 @@ function CreateUser({ onCreated }: { onCreated: () => void }) {
/>
</div>
<div className="flex items-center gap-3">
- <button
- className="u-btn u-btn-primary px-3.5 py-1.5 text-xs"
+ <Button variant="primary" size="sm"
disabled={!valid || create.isPending}
onClick={() => create.mutate()}
>
{S.settings.createUserBtn}
- </button>
- {error && <p className="text-xs text-rose-400">{error}</p>}
+ </Button>
+ {error && <p className="text-small text-danger">{error}</p>}
</div>
</div>
);
diff --git a/web/src/pages/MyKbs.tsx b/web/src/pages/MyKbs.tsx
index 5d730d70..55d19998 100644
--- a/web/src/pages/MyKbs.tsx
+++ b/web/src/pages/MyKbs.tsx
@@ -6,7 +6,11 @@ import { Lock } from "lucide-react";
import { api, type MyKb } from "../api";
import { S } from "../i18n";
import { useKb } from "../kb";
-import { Chip, Loading } from "../ui";
+import {
+ Button,
+ Chip,
+ Loading,
+} from "../ui";
const ymd = (iso: string) => iso.slice(0, 10);
@@ -41,37 +45,37 @@ export function MyKbs() {
return (
<div className="max-w-2xl p-8">
<div className="mb-6">
- <h1 className="u-title text-lg">{S.account.kbsTitle}</h1>
+ <h1 className="u-title text-title">{S.account.kbsTitle}</h1>
</div>
<div className="space-y-3">
{rows.map((row) => {
const canManage = row.my_role === "admin" || row.my_role === "owner";
return (
- <div key={row.kb.id} className="glass glass-hover rounded-2xl px-5 py-4">
+ <div key={row.kb.id} className="glass glass-hover rounded-xl px-6 py-4">
<div className="flex items-start gap-3">
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
- <span className="text-[15px] font-medium text-neutral-100 truncate">
+ <span className="text-title font-medium text-ink truncate">
{row.kb.name}
</span>
{row.kb.visibility === "restricted" ? (
- <span className="flex items-center gap-1 text-[10.5px] text-neutral-500">
+ <span className="flex items-center gap-1 text-fine text-ink-3">
<Lock size={10} />
{S.account.kbRestricted}
</span>
) : (
- <span className="text-[10.5px] text-neutral-600">{S.account.kbOpen}</span>
+ <span className="text-fine text-ink-3">{S.account.kbOpen}</span>
)}
</div>
{row.kb.description && (
- <p className="mt-0.5 text-xs text-neutral-500 truncate">
+ <p className="mt-1 text-small text-ink-3 truncate">
{row.kb.description}
</p>
)}
- <p className="mt-1.5 text-[11px] text-neutral-600">
+ <p className="mt-2 text-fine text-ink-3">
<span className="u-num">{S.account.kbStats(row.doc_count, row.member_count)}</span>
- <span className="mx-1.5 text-neutral-700">·</span>
+ <span className="mx-2 text-ink-3">·</span>
{joinInfo(row)}
</p>
</div>
@@ -81,22 +85,20 @@ export function MyKbs() {
{S.account.roleNames[row.my_role] ?? row.my_role}
</Chip>
)}
- <button
+ <Button variant="secondary" size="sm"
onClick={() => openKb(row.kb.id)}
- className="u-btn u-btn-ghost px-2.5 py-1 text-xs"
>
{S.account.openKb}
- </button>
+ </Button>
{canManage && (
- <button
+ <Button variant="secondary" size="sm"
onClick={() => {
setKb(row.kb.id);
navigate({ to: "/kb/$kbId/settings", params: { kbId: row.kb.id } });
}}
- className="u-btn u-btn-ghost px-2.5 py-1 text-xs"
>
{S.account.kbSettingsBtn}
- </button>
+ </Button>
)}
</div>
</div>
diff --git a/web/src/pages/NextStep.tsx b/web/src/pages/NextStep.tsx
index 1f4de412..c600b476 100644
--- a/web/src/pages/NextStep.tsx
+++ b/web/src/pages/NextStep.tsx
@@ -30,7 +30,7 @@ export function NextStep({
action?: { label: string; to: string; params?: Record<string, string>; search?: Record<string, unknown> };
}) {
return (
- <div className="text-center text-sm text-neutral-500 max-w-xs">
+ <div className="text-center text-body text-ink-3 max-w-xs">
{line}
{action && (
<Link
@@ -38,7 +38,7 @@ export function NextStep({
to={action.to as never}
params={action.params as never}
search={(action.search ?? {}) as never}
- className="block mt-3 text-neutral-300 hover:text-white underline underline-offset-4"
+ className="u-link mt-3 block"
>
{action.label}
</Link>
diff --git a/web/src/pages/OntologySchemaGraph.tsx b/web/src/pages/OntologySchemaGraph.tsx
index 81fae10a..78e0b464 100644
--- a/web/src/pages/OntologySchemaGraph.tsx
+++ b/web/src/pages/OntologySchemaGraph.tsx
@@ -37,7 +37,15 @@ import {
import { Maximize2, Network, Search, X, ZoomIn, ZoomOut } from "lucide-react";
import type { EntityTypeView, RelationTypeView } from "../api";
import { S } from "../i18n";
-import { cn } from "../ui";
+import {
+ cn,
+ Input,
+ Pill,
+ Row,
+ ToolButton,
+ ToolDivider,
+ ToolTower,
+} from "../ui";
import { usePopoverFlip } from "../ui/popoverFlip";
/* ============ 边的三种语义,与三种视觉语汇的映射 ============
@@ -654,10 +662,9 @@ export function OntologySchemaGraph({
<div className="relative pointer-events-auto">
<Search
size={12}
- className="absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-600"
+ className="absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-3"
/>
- <input
- className="input-dark w-60 pl-7 pr-2 py-[5px] text-sm shadow-lg"
+ <Input className="w-60 pl-8 pr-2 shadow-lg"
placeholder={S.ontology.schemaSearchPlaceholder}
value={searchQ}
onChange={(e) => setSearchQ(e.target.value)}
@@ -665,13 +672,14 @@ export function OntologySchemaGraph({
{searchQ && (
<div className="glass-strong absolute mt-1 w-72 rounded-lg shadow-xl overflow-hidden">
{searchHits.length === 0 && (
- <p className="px-3 py-2 text-xs text-neutral-600">{S.ui.noMatches}</p>
+ <p className="px-3 py-2 text-small text-ink-3">{S.ui.noMatches}</p>
)}
{searchHits.map((hit) => (
- <button
+ <Row
key={`${hit.kind}:${hit.id}`}
+ density="menu"
+ className="text-body text-ink"
onClick={() => pickHit(hit)}
- className="w-full px-3 py-1.5 text-left text-sm text-neutral-200 hover:bg-white/5 flex items-center gap-2"
>
{hit.kind === "class" ? (
<span
@@ -682,21 +690,21 @@ export function OntologySchemaGraph({
style={{ background: entityById.get(hit.id)?.color }}
/>
) : (
- <Network size={11} className="shrink-0 text-[#c4a5ff]" />
+ <Network size={11} className="shrink-0 text-violet" />
)}
<span className="truncate">{hit.label}</span>
{hit.sub && (
- <span className="ml-auto shrink-0 text-xs text-neutral-500 truncate max-w-[9rem]">
+ <span className="ml-auto shrink-0 text-small text-ink-3 truncate max-w-[9rem]">
{hit.sub}
</span>
)}
- </button>
+ </Row>
))}
</div>
)}
</div>
- <div className="pointer-events-auto flex flex-wrap gap-1.5 pt-0.5">
+ <div className="pointer-events-auto flex flex-wrap gap-2 pt-1">
{/* 静态图例:三种边各自的说法,不是可切换的过滤器——本体的边远比
实例图少,藏一种边省下的空间不值得多一层交互 */}
{(
@@ -708,7 +716,7 @@ export function OntologySchemaGraph({
).map(([label, color]) => (
<span
key={label}
- className="glass rounded-full px-2.5 py-1 text-[11px] flex items-center gap-1.5 text-neutral-300"
+ className="glass rounded-full px-3 py-1 text-fine flex items-center gap-2 text-ink-2"
>
<span className="h-0.5 w-3 rounded-full" style={{ background: color }} />
{label}
@@ -717,47 +725,40 @@ export function OntologySchemaGraph({
{schema.unscoped.length > 0 && (
<div className="relative" ref={unscopedPop.rootRef}>
- <button
+ <Pill
ref={unscopedPop.anchorRef}
+ active={unscopedPop.open}
+ aria-expanded={unscopedPop.open}
onClick={() =>
unscopedPop.open ? unscopedPop.close() : unscopedPop.setOpen(true)
}
- aria-expanded={unscopedPop.open}
- className={cn(
- "glass rounded-full px-2.5 py-1 text-[11px] transition-colors",
- unscopedPop.open ? "text-neutral-100" : "text-neutral-400",
- "hover:text-neutral-100",
- )}
>
{S.ontology.schemaUnscoped(schema.unscoped.length)}
- </button>
+ </Pill>
{unscopedPop.open && (
<div
ref={unscopedPop.panelRef}
className="u-menu-glass absolute left-0 top-0 z-50 w-64 overflow-hidden rounded-xl p-2 shadow-2xl"
>
- <button
- onClick={() => unscopedPop.close()}
- className="mb-1.5 flex w-full items-center gap-1.5 rounded-full px-1.5 py-0.5 text-[11px] text-neutral-300 hover:text-neutral-100"
- >
+ <Pill className="mb-2 w-full" onClick={() => unscopedPop.close()}>
{S.ontology.schemaUnscoped(schema.unscoped.length)}
- <X size={11} className="ml-auto text-neutral-500" />
- </button>
- <p className="px-1.5 pb-1.5 text-[11px] leading-relaxed text-neutral-500">
+ <X size={11} className="ml-auto text-ink-3" />
+ </Pill>
+ <p className="px-2 pb-2 text-fine leading-relaxed text-ink-3">
{S.ontology.schemaUnscopedHint}
</p>
<div className="flex max-h-64 flex-col overflow-y-auto">
{schema.unscoped.map((r) => (
- <button
+ <Row
key={r.id}
+ className="text-small"
onClick={() => {
onSelect({ kind: "relation", id: r.id });
unscopedPop.close();
}}
- className="w-full truncate rounded px-1.5 py-1 text-left text-[12px] text-neutral-300 hover:bg-white/5 hover:text-white"
>
{r.label}
- </button>
+ </Row>
))}
</div>
</div>
@@ -776,38 +777,29 @@ export function OntologySchemaGraph({
{/* 左下:缩放 + 归位。不给布局切换——模式图只有一套确定性布局,
不像实例图那样需要按类型聚簇或摊成环 */}
<div className="absolute bottom-4 left-3 z-10 flex flex-col items-start gap-2">
- <div className="u-tower group glass-strong rounded-xl shadow-xl flex flex-col overflow-hidden">
- <button
- title={S.ontology.schemaZoomIn}
+ <ToolTower>
+ <ToolButton
+ label={S.ontology.schemaZoomIn}
+ icon={<ZoomIn size={15} />}
onClick={() => sigmaRef.current?.getCamera().animatedZoom({ duration: 220 })}
- className="flex items-center p-2 text-neutral-400 hover:text-white hover:bg-white/[0.06] transition-colors"
- >
- <ZoomIn size={15} />
- <span className="u-tower-label">{S.ontology.schemaZoomIn}</span>
- </button>
- <button
- title={S.ontology.schemaZoomOut}
+ />
+ <ToolButton
+ label={S.ontology.schemaZoomOut}
+ icon={<ZoomOut size={15} />}
onClick={() => sigmaRef.current?.getCamera().animatedUnzoom({ duration: 220 })}
- className="flex items-center p-2 text-neutral-400 hover:text-white hover:bg-white/[0.06] transition-colors"
- >
- <ZoomOut size={15} />
- <span className="u-tower-label">{S.ontology.schemaZoomOut}</span>
- </button>
- <div className="h-px bg-white/10 mx-1.5" />
- <button
- title={S.ontology.schemaFitView}
+ />
+ <ToolDivider />
+ <ToolButton
+ label={S.ontology.schemaFitView}
+ icon={<Maximize2 size={15} />}
onClick={() => sigmaRef.current?.getCamera().animatedReset({ duration: 300 })}
- className="flex items-center p-2 text-neutral-400 hover:text-white hover:bg-white/[0.06] transition-colors"
- >
- <Maximize2 size={15} />
- <span className="u-tower-label">{S.ontology.schemaFitView}</span>
- </button>
- </div>
+ />
+ </ToolTower>
</div>
{empty && (
<div className="absolute inset-0 grid place-items-center pointer-events-none">
- <div className="text-center text-sm text-neutral-500 max-w-xs">
+ <div className="text-center text-body text-ink-3 max-w-xs">
{S.ontology.schemaEmpty}
</div>
</div>
diff --git a/web/src/pages/PendingFacts.tsx b/web/src/pages/PendingFacts.tsx
index fe2524a1..72f7ec55 100644
--- a/web/src/pages/PendingFacts.tsx
+++ b/web/src/pages/PendingFacts.tsx
@@ -1,3 +1,4 @@
+import { Button } from "../ui";
/* 等人点头的事实(docs/decisions/0015)。
一句 remember 抽出的三元组先进待确认队列,不上图;人在这里点头它才进账本。
**原句在上,三元组在下**:只列三元组等于要人凭空判断它对不对——
@@ -58,17 +59,17 @@ export function PendingFactRow({
return (
<div className="glass rounded-xl p-4">
{/* 原句先出。它是人自己说的,判断的依据就是它 */}
- <p className="text-xs text-neutral-400 italic">“{sentence(fact.quote)}”</p>
- <div className="mt-2.5 flex items-center gap-2 flex-wrap">
- <span className="text-sm font-medium text-white">{fact.subject_name}</span>
- <span className="text-xs text-neutral-500">
+ <p className="text-small text-ink-2 italic">“{sentence(fact.quote)}”</p>
+ <div className="mt-3 flex items-center gap-2 flex-wrap">
+ <span className="text-body font-medium text-ink">{fact.subject_name}</span>
+ <span className="text-small text-ink-3">
—{" "}
{fact.predicate_label ? (
<span>{fact.predicate_label}</span>
) : (
/* 本体里没有这个关系:显示原话,斜体标明它不是词表里的词(0010) */
<span
- className="italic text-neutral-600"
+ className="italic text-ink-3"
title={S.review.pendingNoPredicate}
>
{fact.proposed_predicate ?? S.graph.unknownPredicate}
@@ -76,15 +77,15 @@ export function PendingFactRow({
)}{" "}
→
</span>
- <span className="text-sm font-medium text-white">{objectText(fact)}</span>
- {range && <span className="text-xs text-neutral-500">({range})</span>}
+ <span className="text-body font-medium text-ink">{objectText(fact)}</span>
+ {range && <span className="text-small text-ink-3">({range})</span>}
{!fact.predicate_label && (
<span className="u-chip u-chip-warn ml-auto">{S.review.pendingNoPredicateChip}</span>
)}
</div>
<div className="mt-3 flex items-center gap-2">
{fact.proposed_by_name && (
- <span className="text-[11px] text-neutral-600">
+ <span className="text-fine text-ink-3">
{fact.proposed_token_name
? S.review.pendingSaidVia(
fact.proposed_by_name,
@@ -95,20 +96,18 @@ export function PendingFactRow({
)}
{canDecide && (
<div className="ml-auto flex gap-2">
- <button
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs text-[var(--u-danger)]"
+ <Button variant="danger" size="sm"
disabled={busy}
onClick={onReject}
>
{S.review.reject}
- </button>
- <button
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs"
+ </Button>
+ <Button variant="secondary" size="sm"
disabled={busy}
onClick={onConfirm}
>
{S.review.confirm}
- </button>
+ </Button>
</div>
)}
</div>
@@ -139,7 +138,7 @@ export function NodCard({ kbId, chunkId }: { kbId: string; chunkId: string }) {
if (items.length === 0) return null;
return (
<div className="my-2 space-y-2">
- <div className="text-xs text-neutral-500">{S.review.nodCardTitle(items.length)}</div>
+ <div className="text-small text-ink-3">{S.review.nodCardTitle(items.length)}</div>
{items.map((f) => (
<PendingFactRow
key={f.id}
diff --git a/web/src/pages/Search.tsx b/web/src/pages/Search.tsx
index 6285f280..b21acc14 100644
--- a/web/src/pages/Search.tsx
+++ b/web/src/pages/Search.tsx
@@ -4,7 +4,12 @@ import { Link, useNavigate, useSearch } from "@tanstack/react-router";
import { api } from "../api";
import { S } from "../i18n";
import { useKb, useKbId } from "../kb";
-import { Pager, pageSlice } from "../ui";
+import {
+ Button,
+ Input,
+ Pager,
+ pageSlice,
+} from "../ui";
import { NextStep, nextStep, useReadiness } from "./NextStep";
const RESULT_PAGE = 10;
@@ -50,8 +55,7 @@ export function Search() {
<div className="h-full overflow-y-auto p-6">
<div className="max-w-2xl mx-auto">
<div className="flex gap-2 mb-6">
- <input
- className="input-dark flex-1 px-4 py-2.5 text-sm"
+ <Input className="flex-1"
placeholder={S.search.placeholder}
value={input}
onChange={(e) => setInput(e.target.value)}
@@ -59,29 +63,28 @@ export function Search() {
if (e.key === "Enter" && !e.nativeEvent.isComposing) submit();
}}
/>
- <button
+ <Button variant="primary" size="md"
onClick={submit}
disabled={!input.trim()}
- className="u-btn u-btn-primary px-5 py-2 text-sm"
>
{S.search.button}
- </button>
+ </Button>
</div>
{/* 一次都还没搜、而库里本来就没东西:与其等他敲一个词再回"没有结果",
不如现在就说下一步(#313) */}
{!query && step && (
- <div className="py-10 grid place-items-center">
+ <div className="py-8 grid place-items-center">
<NextStep {...step} />
</div>
)}
- {results.isFetching && <p className="text-sm text-neutral-500">{S.search.searching}</p>}
+ {results.isFetching && <p className="text-body text-ink-3">{S.search.searching}</p>}
{results.isError && (
- <p className="text-sm text-rose-400">{(results.error as Error).message}</p>
+ <p className="text-body text-danger">{(results.error as Error).message}</p>
)}
{results.data && results.data.results.length === 0 && (
- <p className="text-sm text-neutral-500">{S.search.noResults}</p>
+ <p className="text-body text-ink-3">{S.search.noResults}</p>
)}
<div className="space-y-3">
@@ -93,10 +96,10 @@ export function Search() {
search={{ chunk: r.id }}
className="block glass rounded-xl p-4 glass-hover"
>
- <div className="mb-1.5 text-xs text-neutral-500">
+ <div className="mb-2 text-small text-ink-3">
{S.search.chunkOf(r.filename, r.seq + 1)}
</div>
- <p className="text-sm text-neutral-300 leading-relaxed line-clamp-4 whitespace-pre-wrap">
+ <p className="text-body text-ink-2 leading-relaxed line-clamp-4 whitespace-pre-wrap">
{r.text}
</p>
</Link>
diff --git a/web/src/pages/ServerDown.tsx b/web/src/pages/ServerDown.tsx
index d3c87cca..f03fd016 100644
--- a/web/src/pages/ServerDown.tsx
+++ b/web/src/pages/ServerDown.tsx
@@ -3,7 +3,10 @@
import { Home, RefreshCw } from "lucide-react";
import { Link } from "@tanstack/react-router";
import { S } from "../i18n";
-import { Wordmark } from "../ui";
+import {
+ Button,
+ Wordmark,
+} from "../ui";
import { usePageTitle } from "../useTitle";
import { LoginScene } from "./LoginScene";
@@ -21,14 +24,14 @@ function PunishmentPage({
<h1 className="text-5xl font-normal">
<Wordmark />
</h1>
- <p className="u-balance mt-4 text-sm text-neutral-400">{message}</p>
- <div className="mt-5 flex items-center justify-center gap-4">
+ <p className="u-balance mt-4 text-body text-ink-2">{message}</p>
+ <div className="mt-6 flex items-center justify-center gap-4">
{children}
<a
href={`${S.login.githubUrl}/issues`}
target="_blank"
rel="noreferrer"
- className="u-link text-xs"
+ className="u-link text-small"
>
{S.nav.reportIssue}
</a>
@@ -42,13 +45,12 @@ export function ServerDown() {
usePageTitle(S.app.name, "Punishment 500");
return (
<PunishmentPage message={S.nav.serverUnreachable}>
- <button
+ <Button variant="secondary" size="sm" className="flex items-center gap-2"
onClick={() => window.location.reload()}
- className="u-btn u-btn-ghost px-3.5 py-1.5 text-xs flex items-center gap-1.5"
>
<RefreshCw size={12} />
{S.nav.refresh}
- </button>
+ </Button>
</PunishmentPage>
);
}
@@ -57,7 +59,7 @@ export function NotFound() {
usePageTitle(S.app.name, "Punishment 404");
return (
<PunishmentPage message={S.nav.notFound}>
- <Link to="/" className="u-btn u-btn-ghost px-3.5 py-1.5 text-xs flex items-center gap-1.5">
+ <Link to="/" className="u-btn u-btn-ghost px-4 py-2 text-small flex items-center gap-2">
<Home size={12} />
{S.nav.returnHome}
</Link>
diff --git a/web/src/pages/Shell.tsx b/web/src/pages/Shell.tsx
index 3f55d514..6f1ef1cd 100644
--- a/web/src/pages/Shell.tsx
+++ b/web/src/pages/Shell.tsx
@@ -73,7 +73,7 @@ export function Shell() {
if (me.isPending) {
return (
- <div className="min-h-screen flex items-center justify-center text-neutral-500 text-sm">
+ <div className="min-h-screen flex items-center justify-center text-ink-3 text-body">
{S.nav.loading}
</div>
);
@@ -95,12 +95,12 @@ export function Shell() {
{/* 顶栏:品牌 + 工作区 + 用户(Vercel 式) */}
{/* z-40:backdrop-filter 使顶栏与 tab 条各自成 stacking context,
不提权则后者按 DOM 序盖住顶栏内的弹出面板 */}
- <header className="glass-strong relative z-40 border-x-0 border-t-0 h-14 shrink-0 flex items-center gap-4 px-5">
+ <header className="glass-strong relative z-40 border-x-0 border-t-0 h-14 shrink-0 flex items-center gap-4 px-6">
{/* 字标:逐字母淡入,hover 浮出 ↗,点击去官网 */}
- <Wordmark className="text-[17px]" />
+ <Wordmark className="text-title" />
{/* 面包屑唯一一级:知识库。Workspace 已从概念层折叠为部署级隐形管道
(settings/members 仍经它走 API,如 organizations 之于单租户)。 */}
- <span className="text-neutral-700">/</span>
+ <span className="text-ink-3">/</span>
{/* 纯切换器:建库是管理动作,入口在 System settings › Knowledge bases */}
<Dropdown
className="w-40"
@@ -111,18 +111,18 @@ export function Shell() {
onChange={setKb}
options={kbs.map((k) => ({ value: k.id, label: k.name }))}
/>
- {/* 三组:项目入口 / 告警 / 身份。**组间 gap-3,组内 gap-1.5**——
+ {/* 三组:项目入口 / 告警 / 身份。**组间 gap-3,组内 gap-2**——
间距由结构表达,而不是给某一个元素补一次性的 ml。
- 此前用户菜单挂着一个 ml-1.5(当初它紧挨 GitHub 胶囊时调的),
+ 此前用户菜单挂着一个 ml-2(当初它紧挨 GitHub 胶囊时调的),
铃铛插进两者之间以后就成了左 6px 右 12px */}
<div className="ml-auto flex items-center gap-3">
{/* 项目入口:Docs + [GitHub·版本] 胶囊(版本取自后端 health,与部署一致)。
版本并入 GitHub 胶囊:两个等高元素,视觉平衡。
这两个是一对,所以彼此贴得比组间近 */}
- <div className="flex items-center gap-1.5">
+ <div className="flex items-center gap-2">
<Link
to="/docs"
- className="px-2 py-1 rounded-lg text-[12.5px] text-neutral-500 hover:text-neutral-200 hover:bg-white/[0.05] transition-colors"
+ className="u-navlink"
>
{S.nav.docs}
</Link>
@@ -131,11 +131,11 @@ export function Shell() {
target="_blank"
rel="noreferrer"
title="GitHub"
- className="flex items-center gap-1.5 rounded-full border border-white/10 px-2.5 py-1 text-neutral-500 hover:text-neutral-200 hover:border-white/25 transition-colors"
+ className="u-pill"
>
<GithubMark size={13} />
{health.data && (
- <span className="u-num text-[11px]">
+ <span className="u-num text-fine">
v{health.data.version}
</span>
)}
@@ -156,11 +156,8 @@ export function Shell() {
key={to}
to={to}
params={{ kbId }}
- className="flex items-center gap-2 px-3.5 py-2.5 text-[13.5px] font-medium text-neutral-400 border-b-2 border-transparent hover:text-neutral-200"
- activeProps={{
- className:
- "flex items-center gap-2 px-3.5 py-2.5 text-[13.5px] font-medium text-white border-b-2 border-white",
- }}
+ className="u-tab"
+ activeProps={{ className: "u-tab is-active" }}
>
<Icon size={15} strokeWidth={1.8} />
{label}
diff --git a/web/src/pages/SourcesRail.tsx b/web/src/pages/SourcesRail.tsx
index b5341f8f..f06c7b44 100644
--- a/web/src/pages/SourcesRail.tsx
+++ b/web/src/pages/SourcesRail.tsx
@@ -33,7 +33,11 @@ import {
} from "lucide-react";
import { api, type SourceView } from "../api";
import { S } from "../i18n";
-import { RAIL_CLS } from "../ui";
+import {
+ IconButton,
+ RAIL_CLS,
+ Row,
+} from "../ui";
/** 左栏选择:全部 / 手动上传 / 某个来源 id */
/** "deleted" = 墓碑视图(#268):删了、还能恢复或清除的文档 */
@@ -95,11 +99,11 @@ export const SYNCING_KINDS = new Set([
]);
export const SYNC_DOT: Record<SourceView["last_sync_status"], string> = {
- never: "bg-neutral-600",
- queued: "bg-[var(--u-warn)]",
- running: "bg-[var(--u-warn)] animate-pulse",
- ok: "bg-[var(--u-ok)]",
- failed: "bg-[var(--u-danger)]",
+ never: "bg-ink-3",
+ queued: "bg-warn",
+ running: "bg-warn animate-pulse",
+ ok: "bg-ok",
+ failed: "bg-danger",
};
export function sourceIcon(s: SourceView): LucideIcon {
@@ -124,17 +128,18 @@ function RailItem({
dot?: string;
}) {
return (
- <button
+ <Row
+ density="nav"
+ active={active}
+ icon={icon}
+ trailing={<span className="u-num">{count}</span>}
onClick={onClick}
- className={`w-full flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-[13px] transition-colors ${
- active ? "u-nav-active" : "text-neutral-400 hover:bg-white/[0.05] hover:text-neutral-200"
- }`}
>
- <span className="shrink-0 text-neutral-500">{icon}</span>
- <span className="truncate">{label}</span>
- {dot && <span className={`h-1.5 w-1.5 rounded-full shrink-0 ${dot}`} />}
- <span className="ml-auto shrink-0 u-num text-[10.5px] text-neutral-600">{count}</span>
- </button>
+ <span className="flex items-center gap-2">
+ <span className="truncate">{label}</span>
+ {dot && <span className={`h-1.5 w-1.5 shrink-0 rounded-full ${dot}`} />}
+ </span>
+ </Row>
);
}
@@ -180,21 +185,19 @@ export function SourcesRail({
count={docs.data?.total ?? 0}
/>
</div>
- <div className="flex items-center justify-between px-4 pt-3 pb-1.5">
- <span className="text-[10px] font-medium uppercase tracking-[0.08em] text-neutral-500">
+ <div className="flex items-center justify-between px-4 pt-3 pb-2">
+ <span className="text-fine font-medium uppercase tracking-[0.08em] text-ink-3">
{S.library.sources}
</span>
{onAdd && (
- <button
+ <IconButton size="sm" label={S.library.addSource}
onClick={onAdd}
- title={S.library.addSource}
- className="text-neutral-500 hover:text-neutral-200"
>
<Plus size={14} />
- </button>
+ </IconButton>
)}
</div>
- <div className="u-scroll flex-1 overflow-y-auto px-2 pb-3 space-y-0.5">
+ <div className="u-scroll flex-1 overflow-y-auto px-2 pb-3 space-y-1">
{/* Uploads:常驻默认来源(上传的默认去处,不可删除) */}
<RailItem
active={active === "uploads"}
diff --git a/web/src/pages/Tokens.tsx b/web/src/pages/Tokens.tsx
index 47fb8801..420d910d 100644
--- a/web/src/pages/Tokens.tsx
+++ b/web/src/pages/Tokens.tsx
@@ -10,7 +10,13 @@ import { Check, Copy, KeyRound } from "lucide-react";
import { api, type TokenView } from "../api";
import { S } from "../i18n";
import { useKb } from "../kb";
-import { Chip, Loading } from "../ui";
+import {
+ Button,
+ Chip,
+ Input,
+ Loading,
+ NativeSelect,
+} from "../ui";
import { toast } from "../toast";
const ymd = (iso: string) => iso.slice(0, 10);
@@ -45,8 +51,8 @@ function mcpSnippet(kbId: string, kbName: string, token: string): string {
function CopyButton({ text, small }: { text: string; small?: boolean }) {
const [done, setDone] = useState(false);
return (
- <button
- className={`u-btn u-btn-ghost ${small ? "px-2 py-1 text-[11px]" : "px-3 py-1.5 text-xs"} flex items-center gap-1.5`}
+ <Button variant="secondary" size="sm"
+ className={`u-btn u-btn-ghost ${small ? "px-2 py-1 text-fine" : "px-3 py-2 text-small"} flex items-center gap-2`}
onClick={() => {
copyText(text);
setDone(true);
@@ -55,7 +61,7 @@ function CopyButton({ text, small }: { text: string; small?: boolean }) {
>
{done ? <Check size={12} /> : <Copy size={12} />}
{done ? S.account.copied : S.account.copy}
- </button>
+ </Button>
);
}
@@ -79,23 +85,22 @@ function IssuedPanel({
const kb = kbs.find((k) => k.id === kbId);
const snippet = kb ? mcpSnippet(kb.id, kb.name, token) : "";
return (
- <div className="glass rounded-2xl p-5 mb-4 border border-[var(--u-warn)]/40">
- <div className="text-[13px] font-medium text-neutral-100">{S.account.issuedTitle}</div>
- <p className="mt-1 text-xs text-neutral-500">{S.account.issuedHint}</p>
+ <div className="glass rounded-xl p-6 mb-4 border border-warn/40">
+ <div className="text-body font-medium text-ink">{S.account.issuedTitle}</div>
+ <p className="mt-1 text-small text-ink-3">{S.account.issuedHint}</p>
<div className="mt-3 flex items-center gap-2">
- <code className="flex-1 min-w-0 truncate rounded-lg bg-black/40 px-3 py-2 font-mono text-[12px] text-neutral-200">
+ <code className="flex-1 min-w-0 truncate rounded-lg bg-well px-3 py-2 font-mono text-small text-ink">
{token}
</code>
<CopyButton text={token} />
</div>
- <div className="mt-5 flex items-baseline justify-between gap-3 flex-wrap">
- <div className="text-[13px] font-medium text-neutral-200">{S.account.mcpTitle}</div>
+ <div className="mt-6 flex items-baseline justify-between gap-3 flex-wrap">
+ <div className="text-body font-medium text-ink">{S.account.mcpTitle}</div>
{candidates.length > 1 && (
- <label className="flex items-center gap-2 text-xs text-neutral-500">
+ <label className="flex items-center gap-2 text-small text-ink-3">
{S.account.mcpBase}
- <select
- className="input-dark px-2 py-1 text-xs"
+ <NativeSelect size="sm"
value={kbId}
onChange={(e) => setKbId(e.target.value)}
>
@@ -104,13 +109,13 @@ function IssuedPanel({
{k.name}
</option>
))}
- </select>
+ </NativeSelect>
</label>
)}
</div>
- <p className="mt-1 text-xs text-neutral-500">{S.account.mcpHint}</p>
+ <p className="mt-1 text-small text-ink-3">{S.account.mcpHint}</p>
<div className="mt-2 relative">
- <pre className="rounded-lg bg-black/40 px-3 py-2 font-mono text-[11.5px] text-neutral-300 overflow-x-auto u-scroll">
+ <pre className="rounded-lg bg-well px-3 py-2 font-mono text-small text-ink-2 overflow-x-auto u-scroll">
{snippet}
</pre>
<div className="absolute top-1.5 right-1.5">
@@ -119,9 +124,9 @@ function IssuedPanel({
</div>
<div className="mt-4 flex justify-end">
- <button className="u-btn u-btn-primary px-3.5 py-1.5 text-xs" onClick={onDone}>
+ <Button variant="primary" size="sm" onClick={onDone}>
{S.account.tokenDone}
- </button>
+ </Button>
</div>
</div>
);
@@ -147,9 +152,9 @@ function TokenRow({
return (
<div className={`glass rounded-xl px-4 py-3 ${revoked ? "opacity-55" : ""}`}>
<div className="flex items-center gap-2 flex-wrap">
- <KeyRound size={13} className="text-neutral-500 shrink-0" />
- <span className="text-sm font-medium text-neutral-100">{t.name}</span>
- <code className="font-mono text-[11px] text-neutral-500">{t.token_prefix}…</code>
+ <KeyRound size={13} className="text-ink-3 shrink-0" />
+ <span className="text-body font-medium text-ink">{t.name}</span>
+ <code className="font-mono text-fine text-ink-3">{t.token_prefix}…</code>
<Chip tone={t.scope === "write" ? "warn" : "neutral"}>
{t.scope === "write" ? S.account.scopeWrite : S.account.scopeRead}
</Chip>
@@ -157,27 +162,25 @@ function TokenRow({
{!revoked && (
<div className="ml-auto flex gap-2">
{arm ? (
- <button
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs text-[var(--u-danger)]"
+ <Button variant="danger" size="sm"
disabled={busy}
onClick={onRevoke}
onBlur={() => setArm(false)}
>
{S.account.revokeConfirm}
- </button>
+ </Button>
) : (
- <button
- className="u-btn u-btn-ghost px-3 py-1.5 text-xs"
+ <Button variant="secondary" size="sm"
disabled={busy}
onClick={() => setArm(true)}
>
{S.account.revoke}
- </button>
+ </Button>
)}
</div>
)}
</div>
- <div className="mt-1.5 text-[11.5px] text-neutral-500 flex gap-x-3 gap-y-0.5 flex-wrap u-num">
+ <div className="mt-2 text-small text-ink-3 flex gap-x-3 gap-y-1 flex-wrap u-num">
<span title={t.kb_ids?.length ? bases : undefined}>
{t.kb_ids?.length ? S.account.nBases(t.kb_ids.length) : S.account.allBases}
</span>
@@ -241,16 +244,16 @@ export function Tokens() {
const field = (label: string, node: React.ReactNode, hint?: string) => (
<div className="mb-4">
- <div className="mb-1 text-[11px] font-medium text-neutral-500">{label}</div>
+ <div className="mb-1 text-fine font-medium text-ink-3">{label}</div>
{node}
- {hint && <p className="mt-1 text-[11px] text-neutral-600">{hint}</p>}
+ {hint && <p className="mt-1 text-fine text-ink-3">{hint}</p>}
</div>
);
return (
<div className="max-w-2xl p-8">
- <h1 className="u-title text-lg">{S.account.tokensTitle}</h1>
- <p className="mt-1 mb-6 text-xs text-neutral-500 max-w-lg">{S.account.tokensHint}</p>
+ <h1 className="u-title text-title">{S.account.tokensTitle}</h1>
+ <p className="mt-1 mb-6 text-small text-ink-3 max-w-lg">{S.account.tokensHint}</p>
{issued && (
<IssuedPanel
@@ -261,12 +264,11 @@ export function Tokens() {
/>
)}
- <div className="glass rounded-2xl p-5 mb-6">
- <h2 className="text-[13px] font-medium text-neutral-200 mb-4">{S.account.newToken}</h2>
+ <div className="glass rounded-xl p-6 mb-6">
+ <h2 className="text-body font-medium text-ink mb-4">{S.account.newToken}</h2>
{field(
S.account.tokenName,
- <input
- className="input-dark w-full px-3 py-2 text-sm"
+ <Input className="w-full"
placeholder={S.account.tokenNamePlaceholder}
value={name}
maxLength={64}
@@ -277,13 +279,13 @@ export function Tokens() {
S.account.tokenScope,
<div className="flex gap-2">
{(["read", "write"] as const).map((s) => (
- <button
+ <Button variant="secondary" size="sm"
key={s}
- className={`u-btn px-3 py-1.5 text-xs ${scope === s ? "u-btn-primary" : "u-btn-ghost"}`}
+ className={`u-btn px-3 py-2 text-small ${scope === s ? "u-btn-primary" : "u-btn-ghost"}`}
onClick={() => setScope(s)}
>
{s === "read" ? S.account.scopeRead : S.account.scopeWrite}
- </button>
+ </Button>
))}
</div>,
S.account.scopeHint,
@@ -294,9 +296,9 @@ export function Tokens() {
{kbs.map((k) => {
const on = picked.has(k.id);
return (
- <button
+ <Button variant="secondary" size="sm"
key={k.id}
- className={`u-btn px-2.5 py-1 text-xs ${on ? "u-btn-primary" : "u-btn-ghost"}`}
+ className={`u-btn px-3 py-1 text-small ${on ? "u-btn-primary" : "u-btn-ghost"}`}
onClick={() => {
const next = new Set(picked);
if (on) next.delete(k.id);
@@ -305,7 +307,7 @@ export function Tokens() {
}}
>
{k.name}
- </button>
+ </Button>
);
})}
</div>,
@@ -315,30 +317,29 @@ export function Tokens() {
S.account.tokenExpires,
<div className="flex gap-2">
{EXPIRY_CHOICES.map((d) => (
- <button
+ <Button variant="secondary" size="sm"
key={d}
- className={`u-btn px-2.5 py-1 text-xs u-num ${days === d ? "u-btn-primary" : "u-btn-ghost"}`}
+ className={`u-btn px-3 py-1 text-small u-num ${days === d ? "u-btn-primary" : "u-btn-ghost"}`}
onClick={() => setDays(d)}
>
{d === 0 ? S.account.expiresNever : S.account.expiresDays(d)}
- </button>
+ </Button>
))}
</div>,
)}
<div className="flex justify-end">
- <button
- className="u-btn u-btn-primary px-3.5 py-1.5 text-xs"
+ <Button variant="primary" size="sm"
disabled={!name.trim() || issue.isPending}
onClick={() => issue.mutate()}
>
{S.account.issueToken}
- </button>
+ </Button>
</div>
</div>
- <h2 className="text-[13px] font-medium text-neutral-200 mb-3">{S.account.yourTokens}</h2>
+ <h2 className="text-body font-medium text-ink mb-3">{S.account.yourTokens}</h2>
{rows.length === 0 ? (
- <div className="glass rounded-xl p-8 text-center text-sm text-neutral-500">
+ <div className="glass rounded-xl p-8 text-center text-body text-ink-3">
{S.account.noTokens}
</div>
) : (
diff --git a/web/src/pages/UserMenu.tsx b/web/src/pages/UserMenu.tsx
index 36fda419..8a0d4eea 100644
--- a/web/src/pages/UserMenu.tsx
+++ b/web/src/pages/UserMenu.tsx
@@ -1,3 +1,8 @@
+import {
+ Button,
+ cn,
+ Row,
+} from "../ui";
/* 用户菜单:顶栏右侧的头像胶囊 + 弹出面板(个人信息 / 系统管理 / 登出)。
Shell(KB 工作区)与 AccountShell(账户层)共用。 */
import { useQueryClient } from "@tanstack/react-query";
@@ -24,7 +29,7 @@ export function Avatar({ name, size = 24 }: { name: string; size?: number }) {
: [...trimmed].slice(0, 2).join("").toUpperCase();
return (
<span
- className="inline-grid place-items-center rounded-full bg-white/[0.09] border border-white/10 text-neutral-200 select-none shrink-0"
+ className="inline-grid place-items-center rounded-full bg-surface-3 border border-line text-ink select-none shrink-0"
style={{ width: size, height: size, fontSize: Math.round(size * 0.38) }}
>
{initials}
@@ -52,21 +57,18 @@ export function UserMenu({ user }: { user: User }) {
};
// 行通到面板边缘(与 Dropdown 同语汇):容器不留内衬,高度由行自身撑
- const item =
- "w-full flex items-center gap-2.5 px-3.5 py-2.5 text-[13px] text-neutral-300 hover:bg-white/[0.06] hover:text-white transition-colors";
return (
<div ref={rootRef} className="relative">
- <button
+ <Button
+ variant="ghost"
ref={anchorRef}
+ className={cn("u-avatar-btn", open && "is-hidden")}
onClick={() => setOpen((v) => !v)}
- className={`flex items-center gap-2 rounded-full py-1 pl-1 pr-3 transition-[background-color,opacity] duration-150 ${
- open ? "opacity-0" : "hover:bg-white/[0.06]"
- }`}
>
<Avatar name={user.display_name} size={24} />
- <span className="text-sm text-neutral-300">{user.display_name}</span>
- </button>
+ <span className="text-body text-ink-2">{user.display_name}</span>
+ </Button>
{open && (
<div
@@ -76,71 +78,68 @@ export function UserMenu({ user }: { user: User }) {
{/* 身份头:再点一下缩回胶囊 */}
<div
onClick={close}
- className="flex items-center gap-3 px-3.5 py-3 border-b border-white/10 cursor-pointer hover:bg-white/[0.04] transition-colors"
+ className="u-row-shell flex cursor-pointer items-center gap-3 border-b border-line px-4 py-3"
>
<Avatar name={user.display_name} size={32} />
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
- <span className="truncate text-[13px] font-medium text-neutral-100">
+ <span className="truncate text-body font-medium text-ink">
{user.display_name}
</span>
{user.is_admin && (
- <span className="u-chip u-chip-neutral !text-[10px] !px-1.5">
+ <span className="u-chip u-chip-neutral !text-fine !px-2">
{S.account.adminChip}
</span>
)}
</div>
- <div className="truncate text-[11px] text-neutral-500">
+ <div className="truncate text-fine text-ink-3">
{user.email}
</div>
</div>
</div>
<div>
- <button onClick={() => go("/account")} className={item}>
- <UserRound size={13} className="text-neutral-500" />
+ <Row density="menu" className="gap-3 px-4 py-3 text-body" onClick={() => go("/account")}>
+ <UserRound size={13} className="text-ink-3" />
{S.account.profile}
- </button>
+ </Row>
{/* 人人可看:全部可见库 + 我在每个库的身份 */}
- <button onClick={() => go("/account/kbs")} className={item}>
- <BookMarked size={13} className="text-neutral-500" />
+ <Row density="menu" className="gap-3 px-4 py-3 text-body" onClick={() => go("/account/kbs")}>
+ <BookMarked size={13} className="text-ink-3" />
{S.account.kbsNav}
- </button>
+ </Row>
{user.is_admin && (
- <button onClick={() => go("/admin")} className={item}>
- <ShieldCheck size={13} className="text-neutral-500" />
+ <Row density="menu" className="gap-3 px-4 py-3 text-body" onClick={() => go("/admin")}>
+ <ShieldCheck size={13} className="text-ink-3" />
{S.account.administration}
- </button>
+ </Row>
)}
</div>
{/* 界面语言:看的人自己定,不经过后端(docs/decisions/0004)。
每个选项用**它自己的语言**写——看不懂英文的人才认得出"中文" */}
- <div className="border-t border-white/10">
- <div className="flex items-center gap-2.5 px-3.5 pt-2.5 pb-1 text-[11px] text-neutral-500">
- <Languages size={13} className="text-neutral-500" />
+ <div className="border-t border-line">
+ <div className="flex items-center gap-3 px-4 pt-3 pb-1 text-fine text-ink-3">
+ <Languages size={13} className="text-ink-3" />
{S.account.language}
</div>
{LANGS.map((l) => (
- <button key={l} onClick={() => setLang(l)} className={item}>
+ <Row density="menu" className="gap-3 px-4 py-3 text-body" key={l} onClick={() => setLang(l)}>
<span className="w-[13px] shrink-0">
{l === lang && (
- <Check size={13} className="text-neutral-400" />
+ <Check size={13} className="text-ink-2" />
)}
</span>
{LANG_NAMES[l]}
- </button>
+ </Row>
))}
</div>
- <div className="border-t border-white/10">
- <button
- onClick={logout}
- className={`${item} !text-[var(--u-danger)]`}
- >
+ <div className="border-t border-line">
+ <Row density="menu" danger className="gap-3 px-4 py-3 text-body" onClick={logout}>
<LogOut size={13} />
{S.nav.signOut}
- </button>
+ </Row>
</div>
</div>
)}
diff --git a/web/src/styles.css b/web/src/styles.css
index fb6aa7c7..c4d972f8 100644
--- a/web/src/styles.css
+++ b/web/src/styles.css
@@ -23,6 +23,7 @@
**唯一**入口——text-ink-2、border-line、bg-surface-2、text-danger。
Tailwind 自带的 neutral-500、white/10 在页面里禁用(scripts/style-guard.mjs) */
--color-ground: var(--u-ground);
+ --color-well: var(--u-well);
--color-ink: var(--u-text);
--color-ink-2: var(--u-text-2);
--color-ink-3: var(--u-text-3);
@@ -88,6 +89,8 @@
--u-surface-3: rgba(255, 255, 255, 0.1);
/* 键盘焦点环:够亮,因为它是键盘用户唯一的"我在哪" */
--u-ring: rgba(255, 255, 255, 0.6);
+ /* 凹下去的一格:代码块、令牌那种"这是原样内容"的底 */
+ --u-well: rgba(0, 0, 0, 0.4);
/* 动效两档:进入 fast、离开 base(见 .glass-strong 上的说明) */
--u-fast: 120ms;
--u-base: 260ms;
@@ -700,6 +703,119 @@ select.input-dark option {
transition: width 500ms ease;
}
+/* 无皮输入:装在别的面里 */
+.u-input-bare {
+ background: transparent;
+ border: 0;
+ outline: none;
+ padding: 0;
+ color: var(--u-text);
+}
+.u-input-bare::placeholder {
+ color: var(--u-text-3);
+}
+
+/* 顶栏里的小链接(Docs、返回) */
+.u-navlink {
+ padding: 0.25rem 0.5rem;
+ border-radius: 0.5rem;
+ font-size: var(--text-small);
+ line-height: var(--text-small--line-height);
+ color: var(--u-text-3);
+ transition:
+ color var(--u-fast),
+ background-color var(--u-fast);
+}
+.u-navlink:hover {
+ color: var(--u-text);
+ background: var(--u-surface-2);
+}
+
+/* 主导航的一页:图标 + 文字,激活态下划线 */
+.u-tab {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ padding: 0.75rem 1rem;
+ font-size: var(--text-body);
+ line-height: var(--text-body--line-height);
+ font-weight: 500;
+ color: var(--u-text-2);
+ border-bottom: 2px solid transparent;
+ transition: color var(--u-fast);
+}
+.u-tab:hover {
+ color: var(--u-text);
+}
+.u-tab.is-active {
+ color: var(--u-text);
+ border-bottom-color: #ffffff;
+}
+
+/* 一行的壳:自己不是按钮(里面还有按钮)但整行要有 hover */
+.u-row-shell {
+ transition: background-color var(--u-fast);
+}
+.u-row-shell:hover {
+ background: var(--u-surface-2);
+}
+
+/* 玻璃卡片式链接(引用来源):指针停上字提亮 */
+.u-card-link:hover {
+ color: var(--u-text-2);
+}
+
+/* 检索命中:警示琥珀的浅底 */
+.u-mark {
+ border-radius: 3px;
+ padding: 0 0.25rem;
+ background: rgba(242, 182, 109, 0.16);
+ color: var(--u-warn);
+}
+
+/* 对话输入框的外壳 */
+.u-composer {
+ border-radius: 0.75rem;
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ background: var(--u-surface);
+ backdrop-filter: blur(12px);
+ -webkit-backdrop-filter: blur(12px);
+ transition: border-color var(--u-fast);
+}
+.u-composer:focus-within {
+ border-color: var(--u-line-strong);
+}
+
+/* 文档页的分块卡:引用定位时闪一下(u-flash),之后慢慢淡回 */
+.u-chunk {
+ transition:
+ border-color 700ms,
+ background-color 700ms,
+ box-shadow 700ms;
+}
+.u-fade-slow {
+ transition: opacity 700ms;
+}
+
+/* 用户菜单的触发胶囊:打开时原地隐身,让面板从它身上长出来 */
+.u-avatar-btn {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ height: auto;
+ border-radius: 9999px;
+ padding: 0.25rem 0.75rem 0.25rem 0.25rem;
+ transition:
+ background-color var(--u-fast),
+ opacity var(--u-fast);
+}
+.u-avatar-btn:hover {
+ background: var(--u-surface-2);
+}
+.u-avatar-btn.is-hidden {
+ opacity: 0;
+}
+
/* ---- chips ---- */
.u-chip {
display: inline-block;
@@ -817,6 +933,7 @@ select.input-dark option {
}
}
+@layer components {
/* ---- text helpers ---- */
.u-accent {
color: var(--u-accent);
@@ -840,6 +957,7 @@ select.input-dark option {
color: #ffffff;
letter-spacing: -0.02em;
}
+}
/* 登录卡:近实底,不用 backdrop-filter(对动画背景每帧重算模糊,代价高) */
.u-card-opaque {
diff --git a/web/src/ui/index.tsx b/web/src/ui/index.tsx
index 5574d1e6..df1bff96 100644
--- a/web/src/ui/index.tsx
+++ b/web/src/ui/index.tsx
@@ -75,19 +75,23 @@ const BUTTON_VARIANT: Record<ButtonVariant, string> = {
danger: "u-btn-danger",
};
-export function Button({
- variant = "secondary",
- size = "md",
- icon,
- busy,
- className,
- disabled,
- children,
- type = "button",
- ...props
-}: ButtonProps) {
+export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
+ {
+ variant = "secondary",
+ size = "md",
+ icon,
+ busy,
+ className,
+ disabled,
+ children,
+ type = "button",
+ ...props
+ },
+ ref,
+) {
return (
<button
+ ref={ref}
type={type}
className={cn(
"u-btn",
@@ -103,24 +107,24 @@ export function Button({
{children}
</button>
);
-}
+});
/* 只有图标的按钮:正方形;`label` 同时是 aria-label 与 title——
没有可见文字的按钮必须有一个名字,这是无障碍的底线 */
-export function IconButton({
- label,
- variant = "ghost",
- size = "md",
- className,
- type = "button",
- ...props
-}: ButtonHTMLAttributes<HTMLButtonElement> & {
- label: string;
- variant?: ButtonVariant;
- size?: "sm" | "md";
-}) {
+export const IconButton = forwardRef<
+ HTMLButtonElement,
+ ButtonHTMLAttributes<HTMLButtonElement> & {
+ label: string;
+ variant?: ButtonVariant;
+ size?: "sm" | "md";
+ }
+>(function IconButton(
+ { label, variant = "ghost", size = "md", className, type = "button", ...props },
+ ref,
+) {
return (
<button
+ ref={ref}
type={type}
aria-label={label}
title={label}
@@ -133,23 +137,22 @@ export function IconButton({
{...props}
/>
);
-}
+});
/* ---------- Input / Textarea / NativeSelect ---------- */
type InputSize = { size?: "sm" | "md" };
-export function Input({
- className,
- size = "md",
- icon,
- ...props
-}: Omit<InputHTMLAttributes<HTMLInputElement>, "size"> &
- InputSize & {
- /** 左侧的语义图标(筛选框的放大镜)。给了它,className 落在外层容器上 */
- icon?: ReactNode;
- }) {
+export const Input = forwardRef<
+ HTMLInputElement,
+ Omit<InputHTMLAttributes<HTMLInputElement>, "size"> &
+ InputSize & {
+ /** 左侧的语义图标(筛选框的放大镜)。给了它,className 落在外层容器上 */
+ icon?: ReactNode;
+ }
+>(function Input({ className, size = "md", icon, ...props }, ref) {
const control = (
<input
+ ref={ref}
className={cn(
"input-dark",
size === "sm" ? "u-input-sm" : "u-input-md",
@@ -173,24 +176,28 @@ export function Input({
{control}
</div>
);
-}
+});
-export function Textarea({
- className,
- size = "md",
- ...props
-}: TextareaHTMLAttributes<HTMLTextAreaElement> & InputSize) {
+export const Textarea = forwardRef<
+ HTMLTextAreaElement,
+ TextareaHTMLAttributes<HTMLTextAreaElement> &
+ InputSize & {
+ /** 没有自己的皮:装在别的面里(对话输入框那种) */
+ bare?: boolean;
+ }
+>(function Textarea({ className, size = "md", bare, ...props }, ref) {
return (
<textarea
+ ref={ref}
className={cn(
- "input-dark u-scroll",
- size === "sm" ? "u-input-sm" : "u-input-md",
+ "u-scroll",
+ bare ? "u-input-bare" : cn("input-dark", size === "sm" ? "u-input-sm" : "u-input-md"),
className,
)}
{...props}
/>
);
-}
+});
/* 原生 select:弹层无法主题化,所以只给"两三个选项、不值得一个 Dropdown"的地方用 */
export function NativeSelect({
@@ -1046,11 +1053,25 @@ export function localDateTime(iso: string): string {
一行整条可点,指针停上变面、选中反白。列表里的行与左栏导航项是同一个东西,
只差密度:nav 高一点、带图标;list 矮一点、可缩进。 */
/** 一行的类:Row 自己用;页面里必须是 <Link> 的行(跳去图谱的实例行)也用它 */
-export function rowClass(active?: boolean, density: "nav" | "list" = "list"): string {
+export type RowDensity = "nav" | "list" | "menu";
+export function rowClass(
+ active?: boolean,
+ density: RowDensity = "list",
+ danger?: boolean,
+): string {
return cn(
- "group flex w-full items-center gap-2 rounded-lg text-left transition-colors duration-fast",
- density === "nav" ? "px-2 py-2 text-body font-medium" : "px-2 py-1 text-body",
- active ? "u-nav-active" : "text-ink-2 hover:bg-surface-2 hover:text-ink",
+ "group flex w-full items-center gap-2 text-left transition-colors duration-fast",
+ density === "menu" ? "rounded-none" : "rounded-lg",
+ density === "nav"
+ ? "px-2 py-2 text-body font-medium"
+ : density === "menu"
+ ? "px-3 py-2 text-small"
+ : "px-2 py-1 text-body",
+ active
+ ? "u-nav-active"
+ : danger
+ ? "text-danger hover:bg-surface-2"
+ : "text-ink-2 hover:bg-surface-2 hover:text-ink",
);
}
/** 行右端小字:静止时最淡,整行被指着时提亮一级 */
@@ -1058,6 +1079,7 @@ export const ROW_TRAILING = "ml-auto shrink-0 text-fine text-ink-3 group-hover:t
export function Row({
active,
+ danger,
density = "list",
indent = 0,
icon,
@@ -1068,7 +1090,10 @@ export function Row({
...props
}: ButtonHTMLAttributes<HTMLButtonElement> & {
active?: boolean;
- density?: "nav" | "list";
+ /** 危险的那一行(菜单里的删除) */
+ danger?: boolean;
+ /** nav = 左栏导航项;list = 列表行;menu = 弹出菜单里的一项(顶满、不圆角) */
+ density?: RowDensity;
/** 树形缩进的层级 */
indent?: number;
icon?: ReactNode;
@@ -1080,7 +1105,7 @@ export function Row({
type={type}
aria-current={active ? "true" : undefined}
style={indent ? { paddingLeft: `${8 + indent * 14}px` } : undefined}
- className={cn(rowClass(active, density), className)}
+ className={cn(rowClass(active, density, danger), className)}
{...props}
>
{icon && <span className="shrink-0 text-ink-3">{icon}</span>}
diff --git a/web/style-guard.baseline.json b/web/style-guard.baseline.json
deleted file mode 100644
index 7722c625..00000000
--- a/web/style-guard.baseline.json
+++ /dev/null
@@ -1,25 +0,0 @@
-[
- "src/pages/Account.tsx",
- "src/pages/AccountShell.tsx",
- "src/pages/AlertBell.tsx",
- "src/pages/Chat.tsx",
- "src/pages/DocViewer.tsx",
- "src/pages/Docs.tsx",
- "src/pages/EntityHistory.tsx",
- "src/pages/KbScope.tsx",
- "src/pages/KbSettings.tsx",
- "src/pages/Legal.tsx",
- "src/pages/Login.tsx",
- "src/pages/Mappings.tsx",
- "src/pages/Members.tsx",
- "src/pages/MyKbs.tsx",
- "src/pages/NextStep.tsx",
- "src/pages/OntologySchemaGraph.tsx",
- "src/pages/PendingFacts.tsx",
- "src/pages/Search.tsx",
- "src/pages/ServerDown.tsx",
- "src/pages/Shell.tsx",
- "src/pages/SourcesRail.tsx",
- "src/pages/Tokens.tsx",
- "src/pages/UserMenu.tsx"
-]