Skip to content

Local Linking ​

Family layout convention ​

lh-ui/                        # Family parent directory (not a repo)
├── lh-ui-core/               # Token source of truth + codegen
├── lh-ui-android/            # Sibling repos
├── lh-ui-ios/
├── lh-ui-harmony/
└── lh-ui-windows/            # This repo

When the repos share one parent directory, tokens are linked locally; when the sibling repos are absent (a CI single-repo clone), it falls back to the npm package automatically. This is structurally identical to the web bloodline's vite alias guard (master plan D18).

Three-level guard ​

scripts/link-tokens.mjs resolves the token artifacts by priority:

PrioritySourceNotes
1../lh-ui-core/dist/windowsLocal linking: change a token and it takes effect immediately
2node_modules/@lh-ui/core/dist/windowsnpm fallback: @lh-ui/core's files:["dist"] ships every platform's artifacts
3—Errors out — without tokens there is nothing to build against

Tokens land in src/Tokens/ (codegen's relativePath is Tokens/*.cs); on the component side, using Top.Lhgb.Ui.Tokens; points here. This directory is generated (.gitignore) — hand-editing is forbidden.

Daily workflow ​

bash
# 1. Change tokens (in the core repo)
cd ../lh-ui-core
vim tokens/color.json           # or spacing / typography / ...

# 2. Regenerate + verify
pnpm codegen                    # Regenerates the dist/ artifacts for every platform
pnpm verify                     # schema + references + WCAG contrast + spec consistency

# 3. Sync back to this repo
cd ../lh-ui-windows
pnpm link:tokens                # Overwrites src/Tokens/

# 4. Regression (dotnet)
dotnet test                     # xUnit golden cases
dotnet build                    # Compiling is the type check

Docs-site tokens ​

The docs site's simulator CSS variables are also generated from tokens:

bash
pnpm gen:sim                    # Generates docs/.vitepress/theme/sim-tokens.css
pnpm docs:dev                   # Runs gen:sim first internally; port 5186
pnpm sim:check                  # Verifies the sim CSS contains no token literals (red line)

CI gate ​

bash
pnpm link:tokens:check          # Checks whether tokens are synced (file-count comparison; exits 1 when out of sync)

Forbidden ​

  • ❌ Hand-editing src/Tokens/ (generated, gitignored)
  • ❌ Committing generated token files to the repo
  • ❌ Writing color/spacing literals inside components (e.g. Color.FromArgb(0xFF,0x2B,0x4C,0x7C), new GridLength(40), or raw font-size numbers)
  • ❌ Copying artifacts manually instead of running link:tokens

Troubleshooting ​

SymptomCauseFix
Compile error The type or namespace 'LhTokens' does not existTokens not syncedpnpm link:tokens
Token values do not match expectationsThe core repo was not re-run through codegenpnpm codegen in the core repo, then link again
link:tokens reports "token artifacts not found"Sibling repos absent and no npm package installedCheck the family layout or pnpm i -D @lh-ui/core
Dark colors are wrongLight primary changed but the dark pre-computation was not updatedUpdate color-dark.json and re-run (R-n6)
Component colors are all lightThe entry point never called LhTheme.ApplyCall it once at App / main window startup
dotnet build reports MC1000 and other XAML errorsComponents build their visual trees in code; the repo ships no XAMLCheck whether a .xaml file was added by mistake

lh-ui native bloodline · Windows (C# + WinUI 3)