Skip to content

Commit bf11bac

Browse files
authored
Merge pull request #2482 from GCWing/gcwing/design-system-foundation
feat(design-system): establish independent UI foundation
2 parents 47f4bc9 + 05f3554 commit bf11bac

458 files changed

Lines changed: 18852 additions & 8569 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

design-system/AGENTS.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# AGENTS.md
2+
3+
## Scope
4+
5+
This file applies to `design-system/**`. Repository-wide rules in the root `AGENTS.md` still apply.
6+
7+
## Architecture
8+
9+
- Public packages live under `packages/`; private authoring and validation tools live under `tooling/`; Design Lab lives under `apps/`.
10+
- `@bitfun/ui` owns React anatomy, behavior, accessibility, and stable variants. It must remain independent from product routes, stores, locale catalogs, Tauri APIs, and concrete themes.
11+
- `@bitfun/design-tokens` owns theme-independent names and system scales. `@bitfun/theme-bitfun` supplies replaceable reference and semantic values.
12+
- Components consume semantic or system CSS variables. Raw colors are forbidden in public component CSS. Component-private variables use the `--_` prefix.
13+
- Files under `dist/` are generated and must not be edited or committed.
14+
- Design Lab may alias `@bitfun/ui` to source only during Vite development for HMR. Its production build must consume package exports.
15+
- `@bitfun/ui/registry` is the source of truth for published components. Design Lab derives navigation, counts, token scopes, and detail routes from that registry; Lab-only previews or copy must never add, retain, or remove a package component.
16+
17+
## Publication boundary
18+
19+
- Public manifests expose only `dist/`, README, and package metadata.
20+
- React and React DOM stay peer dependencies of `@bitfun/ui`.
21+
- Workspace dependencies use the `workspace:` protocol and must be converted to semver ranges by `pnpm pack`.
22+
- New public package boundaries require a real consumer; do not create empty placeholder packages.
23+
24+
## Verification
25+
26+
Use the narrowest matching command:
27+
28+
```bash
29+
pnpm run design-system:build
30+
pnpm run design-system:test
31+
pnpm run design-system:check
32+
```
33+
34+
Run `pnpm run design-system:check` for cross-package or release-boundary changes. Token and theme changes must also run the repository-level `pnpm run theme:color-audit:all`.
35+
36+
Do not use browser automation or mock screenshots as visual proof. Design Lab is the manual authoring surface; source, build, HTTP, and package checks do not establish final visual fidelity.

design-system/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 CWing
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

design-system/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# BitFun Design System
2+
3+
This directory is an independently buildable and publishable design-system boundary inside the BitFun monorepo.
4+
5+
It deliberately does not depend on Web UI routes, stores, locale catalogs, Tauri APIs, or product-domain state. Applications consume only package exports.
6+
7+
## Packages
8+
9+
- `@bitfun/design-tokens`: token contract, system scales, density modes, and generated CSS/TypeScript artifacts.
10+
- `@bitfun/theme-bitfun`: replaceable BitFun light, dark, and high-contrast theme values.
11+
- `@bitfun/ui`: theme-independent React primitives and components.
12+
- `@bitfun/token-engine`: private build-time token resolver shared by packages and authoring tools.
13+
- `@bitfun/design-lab`: private standalone preview and token-authoring application.
14+
15+
The BitFun theme uses a two-layer color model. Foundational colors use named numeric scales such as `ref.color.neutral.50` and `ref.color.blue.500`; mode-specific semantic colors map those values to UI roles. Reference colors are available to authoring tools as data, but emit no runtime CSS variables and are never a component styling contract.
16+
17+
Design Lab exposes an Overview, a searchable component catalog with interactive component-detail workbenches, a Design Tokens workbench for non-color contracts, and a dedicated Colors reference page. Colors reads the generated semantic theme catalog and foundational reference scales directly from `@bitfun/theme-bitfun`, compares Light, Dark, High Contrast Light, and High Contrast Dark values in one table, and documents scale, palette, and resolved mapping relationships without duplicating source values. The Design Tokens workbench keeps typography, spacing, geometry, motion, layer, opacity, and shadow authoring separate, combines a selectable token table with a focused inspector, renders token-driven previews, and can filter the catalog by component ownership. Edits are scoped to the active density and theme modes, update the effect preview immediately, persist as a local draft, and can be exported. In local development, its loopback-only authoring bridge validates changes, writes the owning token source document, rebuilds the package, and rolls back the source if validation fails.
18+
19+
`@bitfun/ui/registry` is the component source of truth. Design Lab derives its component navigation, counts, token scopes, and detail routes from that package export; adding Lab copy or a preview cannot publish a component or keep a removed component alive.
20+
21+
## Commands
22+
23+
```bash
24+
pnpm run design-system:dev
25+
pnpm run design-system:build
26+
pnpm run design-system:test
27+
pnpm run design-system:check
28+
```
29+
30+
The Design Lab development entry uses source aliases for component HMR. Its production build consumes the public package exports, so authoring convenience cannot silently become the published contract.
31+
32+
## Dependency direction
33+
34+
```text
35+
token-engine -> design-tokens -> theme-bitfun
36+
design-tokens -------------> ui
37+
design-tokens + theme-bitfun + ui -> design-lab
38+
```
39+
40+
`@bitfun/ui` never depends on a concrete theme. A consumer imports a theme package and UI styles separately.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta name="color-scheme" content="light dark" />
7+
<title>BitFun Design Lab</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@bitfun/design-lab",
3+
"version": "0.1.0",
4+
"private": true,
5+
"description": "Standalone authoring and preview application for the BitFun design system",
6+
"type": "module",
7+
"scripts": {
8+
"dev": "vite --host 127.0.0.1 --port 4178 --strictPort",
9+
"build": "tsc -p tsconfig.json --noEmit && vite build",
10+
"test": "node --test vite/*.test.mjs && pnpm run type-check",
11+
"type-check": "tsc -p tsconfig.json --noEmit"
12+
},
13+
"dependencies": {
14+
"@bitfun/design-tokens": "workspace:^",
15+
"@bitfun/theme-bitfun": "workspace:^",
16+
"@bitfun/ui": "workspace:^",
17+
"lucide-react": "^0.541.0",
18+
"react": "^18.3.1",
19+
"react-dom": "^18.3.1"
20+
},
21+
"devDependencies": {
22+
"@bitfun/token-engine": "workspace:*",
23+
"@types/node": "^20.10.0",
24+
"@types/react": "^18.3.0",
25+
"@types/react-dom": "^18.3.0",
26+
"@vitejs/plugin-react": "^4.6.0",
27+
"typescript": "~5.8.3",
28+
"vite": "^7.0.4"
29+
},
30+
"engines": {
31+
"node": ">=22.12.0"
32+
}
33+
}

0 commit comments

Comments
 (0)