@hezhijie0327/zjdesign 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/AGENTS.md +106 -0
  2. package/DESIGN.md +98 -0
  3. package/package.json +6 -2
package/AGENTS.md ADDED
@@ -0,0 +1,106 @@
1
+ # AGENTS.md
2
+
3
+ ZJ Design (`@hezhijie0327/zjdesign`) — the shared design system of the ZJ product family (ZJBlog / ZJKVM / ZJSearch / ZJStudio): warm paper, ink text, amber gold. It packages the family's design tokens (CSS), Tailwind class fragments, theme hooks and React components so the four apps consume one versioned source instead of repo-local copies. Design language reference: [DESIGN.md](DESIGN.md); human-facing docs: [README.md](README.md).
4
+
5
+ ## Behavioral Guidelines
6
+
7
+ **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
8
+
9
+ ### 1. Think Before Coding
10
+
11
+ **Don't assume. Don't hide confusion. Surface tradeoffs.**
12
+
13
+ - State assumptions explicitly; ask when uncertain.
14
+ - If multiple interpretations exist, present them — don't pick silently.
15
+ - If a simpler approach exists, say so. Push back when warranted.
16
+
17
+ ### 2. Simplicity First
18
+
19
+ **Minimum code that solves the problem. Nothing speculative.**
20
+
21
+ - No features beyond what was asked; no abstractions for single-use code.
22
+ - No "flexibility" or "configurability" that wasn't requested.
23
+
24
+ ### 3. Surgical Changes
25
+
26
+ **Touch only what you must. Clean up only your own mess.**
27
+
28
+ - Match existing style; don't refactor what isn't broken.
29
+ - Remove only what your own change orphaned.
30
+
31
+ ### 4. Goal-Driven Execution
32
+
33
+ **Define success criteria. Loop until verified.**
34
+
35
+ For every change: `pnpm lint && pnpm check && pnpm test && pnpm build` must pass, and visual changes must be verified in the playground (`pnpm dev`) against all three palette tiers (light / dark / black).
36
+
37
+ ## Git commit convention
38
+
39
+ Every commit subject starts with a type prefix — `feat` / `fix` / `chore` / `docs` / `revert` / `refactor` / `perf` / `test` / `build` — optionally scoped: `fix(modal): ...`. Subject: imperative, lowercase start, no trailing period, aim ≤ 72 chars; detail goes in the body after a blank line (why, not what). Never rewrite pushed history.
40
+
41
+ Commit incrementally — one logical change per commit, after lint and tests pass. Only ONE co-author line is allowed:
42
+
43
+ ```
44
+ Co-authored-by: ZCode <noreply@z.ai>
45
+ ```
46
+
47
+ ## Documentation format
48
+
49
+ - **Language**: AGENTS.md, DESIGN.md are English; README.md is Chinese (human-facing). Keep literal UI strings and code identifiers verbatim.
50
+ - **Formatting**: ATX headings (`#`), never skip a level; code fences always carry a language tag; tables for structured reference; no decorative emoji in headings or bullets; bold for key terms only.
51
+
52
+ ## Project
53
+
54
+ **Architecture: single package, multi-entry** (lobe-ui style). One npm package `@hezhijie0327/zjdesign`, five JS subpaths plus a CSS subpath:
55
+
56
+ | Subpath | Contents |
57
+ | ---------- | ------------------------------------------------------------------- |
58
+ | `.` | React components + hooks (re-exports `components/` and `hooks/`) |
59
+ | `./styles` | `cn()` + class fragments (`fragments.ts`) |
60
+ | `./hooks` | theme controller / `useTheme` / `useExitPresence` / `reducedMotion` |
61
+ | `./paper` | `Tape` + `tapePhysics` (seed physics) |
62
+ | `./brand` | `Wordmark` |
63
+ | `./tokens` | CSS entry (also `./tokens/*.css` per file) |
64
+
65
+ Layering (strict, top depends on bottom only):
66
+
67
+ ```
68
+ tokens (CSS) ← styles (fragments + cn) ← hooks ← components / paper / brand
69
+ ```
70
+
71
+ **Key constraints:**
72
+
73
+ 1. **Tokens are the family contract.** `src/tokens/tokens.css` values must stay byte-identical to the family contract (ZJBlog DESIGN.md §3). Changing a value is a spec change: update DESIGN.md first, then sync, then release a minor bump. Never add raw colors anywhere else.
74
+ 2. **Fragments before classes.** Recurring Tailwind combinations must be added to `src/styles/fragments.ts` and consumed via `className={FRAGMENT}` + `cn()` overrides — never hand-write long class strings inside components.
75
+ 3. **Styling = Tailwind utilities only** inside components. CSS files under `src/tokens/` carry only what utilities cannot reach (@property registrations, pseudo-elements, clip-path paper language, document behaviors). If a widget skin is needed (e.g. `.zj-range` for range pseudo-elements), it lives there and must be token-driven.
76
+ 4. **Peer deps only.** `react`, `react-dom`, `lucide-react`, `tailwindcss` are peer dependencies; runtime deps are limited to `clsx` + `tailwind-merge`. Do not add state libraries (jotai etc.) — the Toast bus is deliberately dependency-free.
77
+ 5. **Consumers scan the dist.** Fragment classes live in shipped JS; consumer Tailwind setup must `@source` the package (see README). Never rely on utilities that only exist in an app's own source.
78
+
79
+ ## Commands
80
+
81
+ ```bash
82
+ pnpm install # install
83
+ pnpm build # tsdown build → dist/ (JS + dts + copied CSS)
84
+ pnpm check # tsc --noEmit
85
+ pnpm lint # biome check .
86
+ pnpm lint:fix # biome check --write .
87
+ pnpm test # vitest run (jsdom)
88
+ pnpm dev # vite playground (visual verification, :5199 in docs)
89
+ ```
90
+
91
+ Release: bump version in `package.json`, `pnpm build && pnpm test && pnpm lint && pnpm check`, `npm publish` (publishConfig pins the official registry). npm package names are lowercase — the scope is `@hezhijie0327`, package `zjdesign`.
92
+
93
+ ## Conventions
94
+
95
+ - **Named export only**, no default exports; explicit `.ts` / `.tsx` import extensions (bundler resolution + `allowImportingTsExtensions`).
96
+ - **Biome 2.6**: 2-space indent, 120 cols, double quotes, semicolons, trailing commas.
97
+ - TypeScript strict + `noUncheckedIndexedAccess` + `verbatimModuleSyntax`.
98
+ - Every component directory: `Widget.tsx` + `index.ts` (lobe-ui layout). Tests live in `/tests` (flat, family repo style).
99
+ - Gotcha: `tapePhysics` shifts MUST use logical `>>>` (arithmetic `>>` sign-extends int32 and breaks the spec range — see DESIGN.md §7). Do not change its constants; the visual spec lives in DESIGN.md and is two-way synced with the family repos.
100
+ - Gotcha: jsdom lacks `matchMedia` — `tests/setup.ts` stubs it globally; add new matchMedia-dependent setup there.
101
+
102
+ ## Key Docs
103
+
104
+ - [DESIGN.md](DESIGN.md) — design language spec (tokens, fragments, paper physics, motion)
105
+ - [README.md](README.md) — Chinese user docs: install, consumer setup, component list
106
+ - Family repos: `C:\Users\zhijie.he\Lab\{blog,ZJKVM,searxng,ZJStudio}` (consumer apps during migration)
package/DESIGN.md ADDED
@@ -0,0 +1,98 @@
1
+ # DESIGN.md
2
+
3
+ The ZJ family design language, packaged. This file is the packaging repo's view of the family contract; the authoritative narrative lives in ZJBlog's DESIGN.md (§1–18). Values below are normative for this package — token values must stay byte-identical across the family.
4
+
5
+ ## 1. Design principles
6
+
7
+ - **Warm paper × ink × amber gold**: page ground is warm paper (`--bg`), text is ink (`--ink`), the single accent family is amber gold (`--accent*`).
8
+ - **Paper physics**: decorations imitate physical paper (torn edges, tape, postmarks) and follow deterministic physics — never random, so SSR and hydration agree.
9
+ - **Editorial typography**: serif for headings and long-form (`--font-serif`), sans for UI chrome, mono for meta and code. Zero webfonts — system stacks only.
10
+ - **Restraint**: three surface tiers (`--bg` → `--surface` → `--surface-2`), two elevations (`--shadow-card` → `--shadow-pop`), three palette tiers (light / dark / black-OLED).
11
+ - **Motion contract**: every interactive surface has enter/exit animations with timeout fallbacks; global `prefers-reduced-motion` gate.
12
+
13
+ ## 2. Tokens (`src/tokens/tokens.css`)
14
+
15
+ All color tokens are registered as `<color>` `@property` (initial-value = light tier). When `html.dark` flips, the variables interpolate on `<html>` — one transition (behaviors.css) drives the whole-page cross-fade. `.black` (OLED, declared after `.dark`) overrides surface/line/ink neutrals only; gold stays.
16
+
17
+ | Token | Light | Dark | Black | Role |
18
+ | ------------------------- | ----------------------------- | --------------------- | ------------ | ------------------------------------------------------------------------------------------ |
19
+ | `--bg` | `#faf9f6` | `#1b1a18` | `#000000` | page ground |
20
+ | `--surface` | `#ffffff` | `#232120` | `#0b0b0c` | cards / panels |
21
+ | `--surface-2` | `#f1efe8` | `#2c2a27` | `#161617` | hover ground / secondary surface |
22
+ | `--line` | `#e6e2d7` | `#38342f` | `#242426` | hairlines / strokes |
23
+ | `--ink` | `#201d17` | `#eceae4` | `#ececec` | primary text |
24
+ | `--ink-2` | `#6b675c` | `#a8a399` | `#9a9a9a` | secondary text |
25
+ | `--ink-3` | `#716c61` | `#9b958a` | `#828282` | meta text (≥4.5:1) |
26
+ | `--accent` | `#8c6800` | `#fec843` | dark | **text** accent (links / chips) |
27
+ | `--accent-hover` | `#7a5c00` | `#ffd76b` | dark | text accent hover |
28
+ | `--accent-strong` | `#f5c84c` | `#fec843` | dark | **fill** accent (primary buttons / selected pills); text on it must be `--accent-contrast` |
29
+ | `--accent-strong-hover` | `#eebd35` | `#ffd76b` | dark | fill accent hover |
30
+ | `--accent-soft` | `#faf0cf` | `#3a3320` | `#292413` | soft accent ground (tape / icon tiles) |
31
+ | `--accent-contrast` | `#241d0e` | `#241d0e` | dark | text on gold fills (mandatory) |
32
+ | `--highlight-bg` | `#fde68a` | `#4a4020` | `#3d3617` | highlights / selection |
33
+ | `--danger` | `#dc2626` | `#f87171` | dark | destructive / errors |
34
+ | `--warning` | `#b45309` | `#fbbf24` | dark | connecting / pending |
35
+ | `--ok` | `#15803d` | `#4ade80` | dark | success / connected |
36
+ | `--code-bg` / `--code-fg` | `#fbfaf6` / `#24211a` | `#0d0b08` / `#e0d9c8` | dark | code blocks |
37
+ | `--shadow-card` | warm 5% | black 35/30% | black 60/50% | static cards |
38
+ | `--shadow-pop` | warm 7/16% | black 45/55% | — | overlays / hover lift |
39
+ | `--scrim` | `rgb(0 0 0 / 0.6)` both tiers | | | lightbox backdrops (physical black, never flips) |
40
+
41
+ Iron rules: no raw hex / `text-gray-*` outside tokens.css; `--accent` is text-only, `--accent-strong` is fill-only; new tokens are registered in tokens.css first, documented here, then consumed.
42
+
43
+ Fonts (`@theme inline` mappings, zero webfonts):
44
+
45
+ - `--font-sans`: `ui-sans-serif, system-ui, …` — UI
46
+ - `--font-serif`: `"Noto Serif SC", "Source Han Serif SC", …` — headings + long-form
47
+ - `--font-mono`: `ui-monospace, "SF Mono", …` — meta / code / readouts
48
+
49
+ Informational text floor: 12px. Interactive controls: 13px (`text-[13px]`) or 14px. Brand wordmark: `font-serif text-2xl font-semibold tracking-tight` + gold dot (`BRAND_DOT`, 0.25em circle).
50
+
51
+ ## 3. Fragments (`src/styles/fragments.ts`)
52
+
53
+ The single source for recurring Tailwind combinations; components consume `className={FRAGMENT}` and override via `cn(FRAGMENT, "...")`. Family sections (byte-identical across the four repos before packaging) and app-panel additions both live here. Canonical list: `ICON_BTN`, `CARD`, `CARD_HOVER`, `DIVIDE_LIST`, `LIST_ROW`, `BTN_PRIMARY`, `BTN_OUTLINE`, `BTN_GHOST`, `PAPER_STRIP`(+`STRIP_PRIMARY`/`STRIP_PAPER`), `ALERT_DANGER`, `MEDIA_FAILED`, `CHIP`, `MONO_CHIP`, `META`, `EYEBROW`, `BRAND_DOT`, `INPUT`, `PANEL`, `TAPE`, `GHOST_DATE`, `GHOST_TEXT`, `SECTION`, `SECTION_DETAIL`, `PANEL_ROW`, `PANEL_COL`, `SEGMENT`(+`SEGMENT_ITEM_ON/OFF`), `PANEL_STATE_CHIP`, `TOOLBAR`(+`TOOLBAR_DIVIDER`), `STATUS_CHIP`, `MODAL_SCRIM`/`MODAL_PANEL`, `SHEET`.
54
+
55
+ z-index ladder: 20 stage info → 30 sheets → 40 floating chrome → 50 nav/progress → 90 popovers → 100 modals → 110 toasts.
56
+
57
+ ## 4. Paper language (`src/tokens/paper.css`)
58
+
59
+ Utilities cannot express clip-path / pseudo-element paper; these classes are token-driven:
60
+
61
+ - `.paper-note` / `.paper-note--blank` — torn-edge note ground (ruled / blank); clip-path on the element itself, so tape must be a SIBLING node.
62
+ - `.paper-strip` — torn-edge strip on `::before` (keeps focus ring intact); paper color via `[--strip:…]` (see `PAPER_STRIP` + `STRIP_PRIMARY`/`STRIP_PAPER`).
63
+ - `.marker-strip` — torn highlight strip behind headline keywords (position inside `relative inline-block`, text in a following `relative` span).
64
+ - `.hollow-text` — stroked watermark (`--hollow-stroke` override); decorative only, `aria-hidden` mandatory.
65
+ - `.paper-chapter` — hand-drawn divider between sibling sections.
66
+ - `.film-number` — film-sprocket numeral (storyboard strips).
67
+ - `.paper-postmark` — dashed outer + solid inner ring (carries information; NOT aria-hidden).
68
+ - `.zj-range` (base.css) — token-driven range skin (warm line track, gold thumb).
69
+
70
+ Decor physics: whitespace only, `aria-hidden` + `pointer-events-none`, deterministic micro-tilts.
71
+
72
+ ### Tape seed physics (authoritative)
73
+
74
+ `tapePhysics(seed, corner?)` in `src/paper/Tape.tsx` — djb2 (`h = ((h << 5) + h + c) >>> 0`, start 5381), all shifts use logical `>>>` (arithmetic `>>` sign-extends int32 and breaks the range — regression from 2026-10 visual debugging, do not revert):
75
+
76
+ - `top = -(6 + h % 4)` → −6..−9px
77
+ - `rotate = (h % 2 ? −1 : +1) × (4 + (h >>> 4) % 4)` → ±4..7°
78
+ - side composition: `inset = 24 + (h >>> 2) % 5 × 4` px, side = seed parity unless `corner` given
79
+ - center composition: `drift = (h >>> 6) % 5 × 6 − 12` px, `translateX(-50%)` then rotate
80
+
81
+ The component is the family's single implementation; the algorithm must stay verbatim-compatible with the apps' copies until each app migrates.
82
+
83
+ ## 5. Theme (`src/hooks/theme.ts`)
84
+
85
+ Class strategy: `html.dark` (+ `html.black` OLED tier). `data-theme-mode` drives icon visibility (behaviors.css). Storage contract: localStorage `zj-theme` (default) or cookie `simple_style` (server-rendered apps). `THEME_BOOTSTRAP` is the pre-paint inline script (anti-FOUC). Palette transition + `.zjs-palette-anim` stand-down window (350 ms) live in behaviors.css; the JS module only flips classes. `applyThemeStyle` is pure (no persistence); `setThemeStyle` persists + applies.
86
+
87
+ ## 6. Motion
88
+
89
+ - Enter/exit pairs: `fade-up` 0.35s `cubic-bezier(0.22,1,0.36,1)` / `fade-out` 0.16s; overlays `slide-in-right` / `slide-out-right` (ZJSearch).
90
+ - Unmount windows are plain timers sized to the animation (`useExitPresence`), doubling as the timeout fallback (animation contract).
91
+ - Global reduced-motion gate collapses everything to 0.01ms.
92
+
93
+ ## 7. Governance
94
+
95
+ 1. Spec change → DESIGN.md (family) → tokens.css → release.
96
+ 2. New fragment → fragments.ts + this doc §3 → release.
97
+ 3. New component → playground demo + visual check on all three tiers + test if behavior-bearing.
98
+ 4. A release without a green `lint + check + test + build` is forbidden.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hezhijie0327/zjdesign",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "ZJ Design — the shared design system of the ZJ product family (warm paper / ink / amber-gold). Tokens, Tailwind fragments, hooks and React components.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -52,7 +52,11 @@
52
52
  "main": "./dist/index.mjs",
53
53
  "types": "./dist/index.d.mts",
54
54
  "files": [
55
- "dist"
55
+ "dist",
56
+ "README.md",
57
+ "LICENSE",
58
+ "DESIGN.md",
59
+ "AGENTS.md"
56
60
  ],
57
61
  "scripts": {
58
62
  "build": "tsdown",