diff --git a/docs/ui.md b/docs/ui.md index 8e30f00..06a67a9 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -100,6 +100,16 @@ **胶囊要写 `pill`,不要写半高。** `height: 26px; border-radius: 13px` 在高度改成 28px 的那天 就不再是胶囊了;`--radius-pill` 与高度无关。 +### 2.7 无封面的占位 + +没有封面的书、影片按标题取一个色相(`web/src/ui/cover-tint.ts`,12 档、每档 30°), +写进 `--cover-hue`,样式表把 `hsl(var(--cover-hue) 55% 55%)` 以 10–20% 混进当前主题的 +surface。这是「组件不写死颜色」的唯一例外,理由与封面图片相同:它是内容的颜色,不是界面的颜色。 + +- **按标题取,不按位置取**:同一本书在书架、书库、搜索里颜色一致,刷新也不变。 +- **只混少量**:占位上的文字仍用 ink/muted,对比度由主题保证;深色模式下自然变成暗底微染。 +- 不加色相之前,一屏全是同一个色块,只能逐个读字找书。 + --- ## 3. 布局 diff --git a/web/src/features/library/pages/LibraryPage.tsx b/web/src/features/library/pages/LibraryPage.tsx index 23f6595..d64cca0 100644 --- a/web/src/features/library/pages/LibraryPage.tsx +++ b/web/src/features/library/pages/LibraryPage.tsx @@ -1,4 +1,5 @@ import { BookOpen, FileText, Folder, Plus, Search, Upload } from 'lucide-react'; +import { coverTint } from '../../../ui/cover-tint.ts'; import { ActionMenu } from '../../../ui/action-menu.tsx'; import { Callout, Icon } from '../../../ui/toolkit.tsx'; import { useQuery, useQueryClient } from '@tanstack/react-query'; @@ -25,7 +26,7 @@ function Cover({ book }: { book: Book }) { }).catch(() => { if (live) setSrc(null); }); return () => { live = false; if (objectUrl) URL.revokeObjectURL(objectUrl); }; }, [runtime.api, book.coverUrl]); - return