@imfusion/web-ui 0.5.1-dev.19.g11b806f9 → 0.5.1-dev.2.gf11bbed1

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 (45) hide show
  1. package/README.md +32 -119
  2. package/bin/install-skill.js +180 -0
  3. package/dist/components/logo/logo.d.ts +1 -1
  4. package/dist/index.js +2 -4
  5. package/dist/style.css +1 -1
  6. package/package.json +24 -34
  7. package/src/docgen/doc.gen.json +1 -1
  8. package/src/llms/skills/imf-web-ui/SKILL.md +11 -15
  9. package/src/llms/skills/imf-web-ui-components/SKILL.md +1 -1
  10. package/src/llms/skills/imf-web-ui-frontend-patterns/SKILL.md +93 -0
  11. package/src/llms/skills/imf-web-ui-frontend-patterns/references/code-conventions.md +133 -0
  12. package/src/llms/skills/{imf-web-ui-frontend-conventions/references/react.md → imf-web-ui-frontend-patterns/references/react-patterns.md} +12 -26
  13. package/src/llms/skills/imf-web-ui-imfusion-frontend-setup/SKILL.md +201 -0
  14. package/src/llms/skills/imf-web-ui-setup/SKILL.md +57 -0
  15. package/src/llms/skills/imf-web-ui-ux/SKILL.md +4 -4
  16. package/src/llms/skills/imf-web-ui-ux/references/forms.md +1 -1
  17. package/bin/install.js +0 -319
  18. package/bin/install.test.ts +0 -139
  19. package/dist/build/vite-css-module-names/index.d.ts +0 -20
  20. package/dist/build/vite-css-module-names.js +0 -17
  21. package/src/llms/skills/imf-web-ui-agent-setup/SKILL.md +0 -71
  22. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/baseline-staleness.sh +0 -17
  23. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/post-tool-use.sh +0 -21
  24. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/session-start.sh +0 -4
  25. package/src/llms/skills/imf-web-ui-agent-setup/templates/hooks/user-prompt-submit.sh +0 -4
  26. package/src/llms/skills/imf-web-ui-agent-setup/templates/settings.json +0 -37
  27. package/src/llms/skills/imf-web-ui-frontend-conventions/SKILL.md +0 -45
  28. package/src/llms/skills/imf-web-ui-frontend-conventions/references/assets.md +0 -23
  29. package/src/llms/skills/imf-web-ui-frontend-conventions/references/class-names.md +0 -42
  30. package/src/llms/skills/imf-web-ui-frontend-conventions/references/components.md +0 -63
  31. package/src/llms/skills/imf-web-ui-frontend-conventions/references/data.md +0 -196
  32. package/src/llms/skills/imf-web-ui-frontend-conventions/references/docs-structure.md +0 -44
  33. package/src/llms/skills/imf-web-ui-frontend-conventions/references/git.md +0 -33
  34. package/src/llms/skills/imf-web-ui-frontend-conventions/references/library-boundary.md +0 -37
  35. package/src/llms/skills/imf-web-ui-frontend-conventions/references/npm-project.md +0 -57
  36. package/src/llms/skills/imf-web-ui-frontend-conventions/references/project-structure.md +0 -21
  37. package/src/llms/skills/imf-web-ui-frontend-conventions/references/stack.md +0 -39
  38. package/src/llms/skills/imf-web-ui-frontend-conventions/references/styling.md +0 -91
  39. package/src/llms/skills/imf-web-ui-frontend-conventions/references/testing.md +0 -16
  40. package/src/llms/skills/imf-web-ui-frontend-conventions/references/tooling.md +0 -76
  41. package/src/llms/skills/imf-web-ui-frontend-conventions/references/typescript.md +0 -45
  42. package/src/llms/skills/imf-web-ui-frontend-setup/SKILL.md +0 -89
  43. package/src/llms/skills/imf-web-ui-frontend-setup/templates/AGENTS.md +0 -34
  44. package/src/llms/skills/imf-web-ui-frontend-setup/templates/README.md +0 -27
  45. package/src/llms/skills/imf-web-ui-library-setup/SKILL.md +0 -36
@@ -1,139 +0,0 @@
1
- import { beforeEach, describe, expect, it } from "vitest";
2
- import { spawnSync } from "node:child_process";
3
- import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
4
- import { tmpdir } from "node:os";
5
- import { join, resolve } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
-
8
- const installer = resolve(fileURLToPath(new URL(".", import.meta.url)), "install.js");
9
-
10
- function runInstall(cwd: string, ...args: string[]) {
11
- const result = spawnSync("node", [installer, ...args], { cwd, encoding: "utf-8" });
12
- expect(result.status).toBe(0);
13
- return result;
14
- }
15
-
16
- function readSettings(cwd: string) {
17
- return JSON.parse(readFileSync(join(cwd, ".claude", "settings.json"), "utf-8")) as {
18
- permissions?: { allow: string[] };
19
- hooks: Record<string, { hooks: { command: string }[] }[]>;
20
- };
21
- }
22
-
23
- let consumer: string;
24
-
25
- beforeEach(() => {
26
- consumer = mkdtempSync(join(tmpdir(), "web-ui-install-"));
27
- });
28
-
29
- describe("web-ui-install", () => {
30
- it("installs skills into both targets with version markers", () => {
31
- runInstall(consumer, "--skills", "--target", "agents", "--target", "claude");
32
-
33
- const installed = readdirSync(join(consumer, ".agents", "skills"));
34
- expect(installed).toContain("imf-web-ui");
35
- expect(installed).toContain("imf-web-ui-frontend-conventions");
36
- expect(installed).toContain("imf-web-ui-frontend-setup");
37
-
38
- for (const name of installed) {
39
- expect(existsSync(join(consumer, ".agents", "skills", name, ".imf-web-ui-skill-version.json"))).toBe(true);
40
- expect(lstatSync(join(consumer, ".claude", "skills", name)).isSymbolicLink()).toBe(true);
41
- }
42
- });
43
-
44
- it("installs hooks into an installer-owned directory and registers them", () => {
45
- runInstall(consumer, "--hooks");
46
-
47
- const hookDir = join(consumer, ".agents", "hooks", "imf-web-ui");
48
- const scripts = readdirSync(hookDir);
49
- expect(scripts).toEqual(expect.arrayContaining(["session-start.sh", "user-prompt-submit.sh", "post-tool-use.sh"]));
50
- for (const script of scripts) {
51
- expect(statSync(join(hookDir, script)).mode & 0o100).toBeTruthy();
52
- }
53
-
54
- const settings = readSettings(consumer);
55
- expect(Object.keys(settings.hooks)).toEqual(expect.arrayContaining(["SessionStart", "UserPromptSubmit", "PostToolUse"]));
56
- // --hooks alone installs no skills
57
- expect(existsSync(join(consumer, ".agents", "skills"))).toBe(false);
58
- });
59
-
60
- it("merges registrations without clobbering existing settings, idempotently", () => {
61
- mkdirSync(join(consumer, ".claude"), { recursive: true });
62
- writeFileSync(
63
- join(consumer, ".claude", "settings.json"),
64
- JSON.stringify({
65
- permissions: { allow: ["Bash(git *)"] },
66
- hooks: { PostToolUse: [{ matcher: "Edit", hooks: [{ type: "command", command: "echo existing" }] }] }
67
- })
68
- );
69
-
70
- runInstall(consumer, "--hooks");
71
- runInstall(consumer, "--hooks");
72
-
73
- const settings = readSettings(consumer);
74
- expect(settings.permissions?.allow).toEqual(["Bash(git *)"]);
75
- const commands = settings.hooks.PostToolUse.flatMap(entry => entry.hooks.map(hook => hook.command));
76
- expect(commands).toContain("echo existing");
77
- // the shipped registration is added exactly once across both runs
78
- expect(commands.filter(command => command.includes("post-tool-use.sh"))).toHaveLength(1);
79
- });
80
-
81
- it("upserts the fenced AGENTS.md block and leaves the rest untouched", () => {
82
- const agentsPath = join(consumer, "AGENTS.md");
83
- writeFileSync(
84
- agentsPath,
85
- "# AGENTS.md\n\nRepo-specific intro.\n\n<!-- imf-web-ui:begin stale -->\nold content\n<!-- imf-web-ui:end -->\n\nRepo-specific outro.\n"
86
- );
87
-
88
- runInstall(consumer, "--skills", "--target", "agents");
89
- const updated = readFileSync(agentsPath, "utf-8");
90
- expect(updated).toContain("Repo-specific intro.");
91
- expect(updated).toContain("Repo-specific outro.");
92
- expect(updated).not.toContain("old content");
93
- expect(updated).toContain("resynced with `npx web-ui-install`");
94
-
95
- // no fence yet → block is appended; missing AGENTS.md entirely → left alone
96
- writeFileSync(agentsPath, "# AGENTS.md\n\nNo fence here.\n");
97
- runInstall(consumer, "--skills", "--target", "agents");
98
- const appended = readFileSync(agentsPath, "utf-8");
99
- expect(appended).toContain("No fence here.");
100
- expect(appended).toContain("<!-- imf-web-ui:begin");
101
- });
102
-
103
- it("ships hooks that stay advisory: exit 0 with and without a usable payload", () => {
104
- runInstall(consumer, "--hooks");
105
- const hookDir = join(consumer, ".agents", "hooks", "imf-web-ui");
106
-
107
- const noFile = spawnSync("sh", [join(hookDir, "post-tool-use.sh")], { input: "{}", encoding: "utf-8" });
108
- expect(noFile.status).toBe(0);
109
-
110
- const missingFile = spawnSync("sh", [join(hookDir, "post-tool-use.sh")], {
111
- input: JSON.stringify({ tool_input: { file_path: join(consumer, "nope.ts") } }),
112
- encoding: "utf-8"
113
- });
114
- expect(missingFile.status).toBe(0);
115
-
116
- const sessionStart = spawnSync("sh", [join(hookDir, "session-start.sh")], { encoding: "utf-8" });
117
- expect(sessionStart.status).toBe(0);
118
- expect(sessionStart.stdout).toContain("imf-web-ui-frontend-conventions");
119
-
120
- // no node_modules in the consumer → silent success
121
- const staleness = spawnSync("sh", [join(hookDir, "baseline-staleness.sh")], { cwd: consumer, encoding: "utf-8" });
122
- expect(staleness.status).toBe(0);
123
- expect(staleness.stdout).toBe("");
124
- });
125
-
126
- it("warns from the staleness script when skill markers lag the package", () => {
127
- runInstall(consumer, "--skills", "--hooks", "--target", "agents");
128
- const pkgDir = join(consumer, "node_modules", "@imfusion", "web-ui");
129
- mkdirSync(pkgDir, { recursive: true });
130
- writeFileSync(join(pkgDir, "package.json"), JSON.stringify({ version: "99.0.0" }));
131
-
132
- const result = spawnSync("sh", [join(consumer, ".agents", "hooks", "imf-web-ui", "baseline-staleness.sh")], {
133
- cwd: consumer,
134
- encoding: "utf-8"
135
- });
136
- expect(result.status).toBe(0);
137
- expect(result.stdout).toContain("npx web-ui-install");
138
- });
139
- });
@@ -1,20 +0,0 @@
1
- import { Plugin } from 'vite';
2
- export interface ReadableCssModuleNamesOptions {
3
- /** Namespace for every generated class name. Short, stable, app-scoped (`imf-ui`, `acme`). */
4
- prefix: string;
5
- }
6
- /**
7
- * Generates readable CSS Module class names instead of the default hash, so the DOM
8
- * stays legible in devtools and browser automation. `button.module.css` yields
9
- * `{prefix}-button-module-root` — `[name]` is the filename, which keeps its `.module`
10
- * suffix.
11
- *
12
- * Register it in every tool that compiles the CSS (the app build AND Storybook). A
13
- * compiler left out generates different class names for the same source file and its
14
- * styles silently don't apply.
15
- *
16
- * Defaults to opting into Lightning CSS, which drops `css.modules` options it has no
17
- * equivalent for (`localsConvention`). Set `css.transformer: "postcss"` to stay on
18
- * the PostCSS pipeline.
19
- */
20
- export declare function readableCssModuleNames({ prefix }: ReadableCssModuleNamesOptions): Plugin;
@@ -1,17 +0,0 @@
1
- //#region src/build/vite-css-module-names/index.ts
2
- function e(e, t) {
3
- let { lightningcss: n, modules: r, transformer: i } = e.css ?? {}, a = n?.cssModules;
4
- if (!(typeof a == "boolean" || r === !1) && !a?.pattern && !(typeof r == "object" && r.generateScopedName)) return i === "postcss" ? { css: { modules: { generateScopedName: t } } } : { css: {
5
- transformer: "lightningcss",
6
- lightningcss: { cssModules: { pattern: t } }
7
- } };
8
- }
9
- function t({ prefix: t }) {
10
- let n = `${t}-[name]-[local]`;
11
- return {
12
- name: "imf-ui:readable-css-module-names",
13
- config: (t) => e(t, n)
14
- };
15
- }
16
- //#endregion
17
- export { t as readableCssModuleNames };
@@ -1,71 +0,0 @@
1
- ---
2
- name: imf-web-ui-agent-setup
3
- description:
4
- "Install or update the LLM/agent tooling @imfusion/web-ui ships in a consumer repo: the vendored imf-web-ui-* skills, the
5
- AGENTS.md fence, the agent lifecycle hooks, and the staleness wiring. Also covers reaching the Agent Skills a dependency
6
- ships — TanStack Intent (@tanstack/intent) and its allowlist. Wraps npx web-ui-install and adds the judgment the binary
7
- can't have — reading what the repo already registers before adding anything. Load when setting up agent tooling in a
8
- consumer app, when skills are stale, when hooks should be installed or adapted, or when asked to set up TanStack Intent or
9
- dependency-shipped Agent Skills. Not for project tooling (imf-web-ui-frontend-setup) or library wiring
10
- (imf-web-ui-library-setup)."
11
- ---
12
-
13
- # imf-web-ui-agent-setup
14
-
15
- Sets up or updates the agent side of a consumer repo. The binary does the mechanics; this skill does the judgment.
16
-
17
- ## Skills
18
-
19
- `npx web-ui-install` installs or refreshes the vendored `imf-web-ui-*` skills (interactive target choice on first run,
20
- remembered after; `--reconfigure` re-opens it). It also refreshes the `<!-- imf-web-ui:begin/end -->` fence in an existing
21
- `AGENTS.md`. Stale check: `.imf-web-ui-skill-version.json` in each installed skill vs. the installed package version — older
22
- marker means re-run the binary, never hand-diff skill contents.
23
-
24
- ## Hooks
25
-
26
- Three agent lifecycle hooks ship as templates in [`templates/hooks/`](templates/hooks/), registration in
27
- [`templates/settings.json`](templates/settings.json):
28
-
29
- - **SessionStart** — once per session: the conventions baseline is vendored, load it before writing.
30
- - **UserPromptSubmit** — a one-line conventions reminder per prompt. Per-prompt, not per-tool-call: a PreToolUse reminder
31
- would re-inject the same text on every edit.
32
- - **PostToolUse** (advisory) — file-scope checks on the touched file after every Edit/Write, failures fed straight back.
33
- Never exits non-zero.
34
- - **`baseline-staleness.sh`** — not registered as an agent hook; the repo's pre-commit calls it
35
- ([`git.md`](../imf-web-ui-frontend-conventions/references/git.md), Staleness at commit time).
36
-
37
- **Read `.claude/settings.json` before installing.** Then pick per event:
38
-
39
- - **Nothing registered** → install as shipped: `npx web-ui-install --hooks` copies the scripts to `.agents/hooks/imf-web-ui/`
40
- (installer-owned, refreshed wholesale) and merges the registrations without touching existing entries.
41
- - **The repo already covers an event** (its own session reminder, its own post-edit verify) → don't stack a second hook on
42
- it. Use the template as a starting point instead: fold the missing behaviour into the repo's existing script, or adapt the
43
- template and register that. Surface the situation and let the human pick.
44
-
45
- ## Dependency-shipped skills
46
-
47
- Some libraries ship Agent Skills inside their npm package; TanStack does across much of the suite.
48
- [TanStack Intent](https://github.com/TanStack/intent) (`@tanstack/intent`) is the CLI that surfaces them — an agent holding a
49
- dependency but not its guidance writes plausible code against a half-remembered API.
50
-
51
- Setting it up is the project's own call, not something web-ui does on its behalf. Point it out:
52
-
53
- > This project has TanStack dependencies that ship their own Agent Skills. `@tanstack/intent` can make them reachable — worth
54
- > a look if you want your agent working from the library's own guidance.
55
-
56
- Intent offers two things: a fenced instructions block in `AGENTS.md`, and a `PreToolUse` hook that blocks an edit until a
57
- matching skill has been read. The house preference is both — the block alone is advice an agent can walk past. The hook
58
- refuses every edit while no matching skill is loadable, so a project adopting it wants the current docs open; that sequencing
59
- belongs to whoever runs it.
60
-
61
- **Allowlist the whole scope.** `intent.skills` takes `@tanstack/*`. Per-package entries like `@tanstack/react-query` look
62
- more precise and silently reach almost nothing, because the skills ship from packages the app never names directly. Exclude
63
- `@tanstack/devtools-event-client` — it publishes skills that are noise in an app repo.
64
-
65
- Read Intent's own docs before wiring it; it is young and moves. Whatever the project decides, guidance you didn't read is not
66
- guidance you have: use `npx @tanstack/cli` for TanStack docs, and never guess at a skill name.
67
-
68
- ## Not this skill
69
-
70
- - Project tooling, docs structure, the audit checklist → `imf-web-ui-frontend-setup` (which delegates agent tooling here)
71
- - Library wiring (styles import, provider) → `imf-web-ui-library-setup`
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env sh
2
- # Advisory baseline-staleness check, meant to be called from the repo's pre-commit hook.
3
- # Compares the installed imf-web-ui skill markers against the installed package version
4
- # and warns on drift. Always exits 0 — staleness never blocks a commit.
5
- PKG=node_modules/@imfusion/web-ui/package.json
6
- [ -f "$PKG" ] || exit 0
7
- CURRENT=$(node -p "require('./$PKG').version" 2>/dev/null) || exit 0
8
-
9
- for marker in .agents/skills/imf-web-ui-*/.imf-web-ui-skill-version.json; do
10
- [ -f "$marker" ] || continue
11
- INSTALLED=$(node -p "require('./$marker').version" 2>/dev/null) || continue
12
- if [ "$INSTALLED" != "$CURRENT" ]; then
13
- echo "imf-web-ui skills are stale ($INSTALLED installed, package is $CURRENT) — run: npx web-ui-install"
14
- break
15
- fi
16
- done
17
- exit 0
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env sh
2
- # PostToolUse (Edit|Write): advisory file-scope checks on the touched file. Never exits
3
- # non-zero, so a mid-flight refactor can't trap the agent. Resolve the repo from the edited
4
- # file, not cwd, which is not guaranteed for hooks.
5
- FILE=$(jq -r '.tool_input.file_path // empty' 2>/dev/null)
6
- [ -f "$FILE" ] || exit 0
7
-
8
- ROOT=$(cd "$(dirname "$FILE")" && git rev-parse --show-toplevel 2>/dev/null) || exit 0
9
- cd "$ROOT" || exit 0
10
-
11
- case "$FILE" in
12
- *.ts | *.tsx | *.js | *.jsx)
13
- [ -x ./node_modules/.bin/eslint ] && ./node_modules/.bin/eslint --cache "$FILE" 2>&1
14
- ;;
15
- esac
16
- case "$FILE" in
17
- *.ts | *.tsx | *.js | *.jsx | *.css | *.json | *.md)
18
- [ -x ./node_modules/.bin/prettier ] && ./node_modules/.bin/prettier --check "$FILE" 2>&1
19
- ;;
20
- esac
21
- exit 0
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- # SessionStart: point the agent at the vendored conventions baseline once per session.
3
- echo "The ImFusion frontend conventions baseline is vendored in .agents/skills/ (imf-web-ui-frontend-conventions and siblings). Load the relevant skill before writing code, styles, or docs; repo docs in docs/ carry only what is unique to this repo."
4
- exit 0
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- # UserPromptSubmit: one-line conventions reminder per prompt.
3
- echo "Conventions check: if this task touches code, styles, data fetching, or docs, consult the matching imf-web-ui-* skill in .agents/skills/ before acting."
4
- exit 0
@@ -1,37 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/claude-code-settings.json",
3
- "hooks": {
4
- "SessionStart": [
5
- {
6
- "hooks": [
7
- {
8
- "type": "command",
9
- "command": "\"$CLAUDE_PROJECT_DIR/.agents/hooks/imf-web-ui/session-start.sh\""
10
- }
11
- ]
12
- }
13
- ],
14
- "UserPromptSubmit": [
15
- {
16
- "hooks": [
17
- {
18
- "type": "command",
19
- "command": "\"$CLAUDE_PROJECT_DIR/.agents/hooks/imf-web-ui/user-prompt-submit.sh\""
20
- }
21
- ]
22
- }
23
- ],
24
- "PostToolUse": [
25
- {
26
- "matcher": "Edit|MultiEdit|Write",
27
- "hooks": [
28
- {
29
- "type": "command",
30
- "command": "\"$CLAUDE_PROJECT_DIR/.agents/hooks/imf-web-ui/post-tool-use.sh\"",
31
- "statusMessage": "Verifying file"
32
- }
33
- ]
34
- }
35
- ]
36
- }
37
- }
@@ -1,45 +0,0 @@
1
- ---
2
- name: imf-web-ui-frontend-conventions
3
- description:
4
- "The ImFusion frontend conventions baseline — in-house conventions, valid in every ImFusion frontend and usable by anyone
5
- who likes them. A router over topic references: library boundary, React, components, TypeScript, styling, data layer,
6
- project structure, testing, stack, npm project, tooling config, git, assets, docs structure. Load when writing wrapper
7
- components, custom UI, styling beyond the defaults, adding new files to a consumer app, writing repo docs, touching tool
8
- config, or choosing any dependency."
9
- ---
10
-
11
- # imf-web-ui-frontend-conventions
12
-
13
- The ImFusion frontend baseline. In-house conventions, not industry claims — they encode how ImFusion frontends are built, and
14
- anyone else is welcome to them.
15
-
16
- **The project wins.** These defaults fill vacuums: if the host project already has a convention — a styling system, a state
17
- library, a folder shape — that stands. They are not a license to refactor a consumer codebase toward this document.
18
-
19
- **Alignment mode.** The exception is intent: when the user asks to _align_ the repo with the baseline ("align", "alignment"
20
- is the flag), the project-wins guard lifts. Deviations then become migration findings — proposed as a plan, still nothing
21
- changed until the human approves.
22
-
23
- ## The references
24
-
25
- Each topic lives in one reference. Read the one whose moment you're in; starting a new feature usually wants several.
26
-
27
- | Reference | Covers | Read when |
28
- | ------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------- |
29
- | [library-boundary.md](references/library-boundary.md) | staying behind `@imfusion/web-ui`, wrappers, type derivation, peers | touching anything that renders library components |
30
- | [react.md](references/react.md) | component roles, state kinds and owners, effects discipline | writing new screens, components, or wrappers |
31
- | [components.md](references/components.md) | component anatomy on disk: grouping, folders, colocation | adding a component file |
32
- | [typescript.md](references/typescript.md) | functional style, types, naming | writing any code |
33
- | [styling.md](references/styling.md) | native CSS Modules, tokens, the override contract | writing CSS or styling beyond the defaults |
34
- | [class-names.md](references/class-names.md) | CVA variants, `cx`, merging the incoming `className` | writing a component with variants or a `className` prop |
35
- | [data.md](references/data.md) | `api/`+`http/` shape, Zod boundary, query/mutation patterns | adding an API topic, a fetch, or a mutation |
36
- | [project-structure.md](references/project-structure.md) | the `src/` tree, file naming, imports | adding files rather than editing existing ones |
37
- | [testing.md](references/testing.md) | what's worth testing and what isn't | writing or reviewing tests |
38
- | [stack.md](references/stack.md) | the topic→tool map, when a library owns a layer | choosing or adding any dependency |
39
- | [npm-project.md](references/npm-project.md) | `package.json`, the `verify:*` script set, dependency pinning | running or adding a script, adding a dependency |
40
- | [tooling.md](references/tooling.md) | Prettier, ESLint, tsconfig, staged files, CSS class names | touching tool config |
41
- | [git.md](references/git.md) | `git:config`, verify scopes, staleness at commit time | wiring hooks or the commit path |
42
- | [assets.md](references/assets.md) | image formats, the WebP recipe | adding images or other static assets |
43
- | [docs-structure.md](references/docs-structure.md) | what a repo documents, where, how it's written | writing or restructuring repo docs |
44
-
45
- `imf-web-ui-frontend-setup` bootstraps and audits a repo against this baseline.
@@ -1,23 +0,0 @@
1
- # Assets
2
-
3
- Import everything from `src/assets/` so the bundler fingerprints and bundles it. Never reference an image by public-path
4
- string.
5
-
6
- ## Photographs — WebP
7
-
8
- ```bash
9
- magick source.png -resize 2000x -quality 80 -define webp:method=6 src/assets/name.webp
10
- ```
11
-
12
- - Quality 80 is visually lossless on photos and routinely cuts file size by an order of magnitude.
13
- - `method=6` is the densest encoding. It's a one-off cost at conversion time, so take the smaller file.
14
- - Cap the long edge at 2000px — nothing on the market resolves more in a content image.
15
- - No `<picture>` fallback needed; WebP is supported everywhere since 2020.
16
-
17
- ## Other formats
18
-
19
- - **Alpha, or pixels that must stay exact** → PNG, optimized with `oxipng` or `pngquant`.
20
- - **Icons, logos, line art** → inline SVG component, so it inherits `currentColor` and follows the theme.
21
-
22
- These rules apply to assets as they're added or touched. Existing assets in another format are not findings to sweep —
23
- convert opportunistically, when you're working on them anyway.
@@ -1,42 +0,0 @@
1
- # Class names in components
2
-
3
- How a component turns props into a `className` string. What the build does with the result is [tooling.md](tooling.md); what
4
- goes in the stylesheet is [styling.md](styling.md).
5
-
6
- **CVA is the only tool.** `class-variance-authority` maps variant props to CSS Module classes. No `clsx`, no
7
- `tailwind-merge`, no local `cn()` helper. `cx` is CVA's own concatenator and `@imfusion/web-ui` re-exports it, so it comes
8
- from the library alongside the components.
9
-
10
- ```tsx
11
- import { cva } from "class-variance-authority";
12
- import classes from "./chip.module.css";
13
-
14
- const chip = cva(classes.root, {
15
- variants: {
16
- appearance: { outline: classes.appearanceOutline, solid: classes.appearanceSolid },
17
- inline: { false: null, true: classes.inline }
18
- }
19
- });
20
-
21
- export function Chip({ appearance = "outline", inline = false, className, ...props }: Props) {
22
- return <span {...props} className={chip({ appearance, inline, className })} />;
23
- }
24
- ```
25
-
26
- - **Base class is CVA's first argument**, variant values are CSS Module references, never string literals. A boolean axis
27
- uses `null` for its off-state.
28
- - **The incoming `className` goes into CVA's `className` slot**, which appends it last so a caller's class always wins. With
29
- no variants to map, `cx(classes.inline, className)` does the same job.
30
- - **Every component that accepts `className` merges it.** A component whose surface is deliberately closed omits the prop
31
- entirely rather than accepting and ignoring it.
32
- - **Defaults live in the props destructuring, not CVA's `defaultVariants`.** react-docgen-typescript reads the destructuring,
33
- so defaults declared in CVA don't reach the generated docs.
34
- - **Resolve a function-form `className` before merging.** Components built on a library that passes render state
35
- (`className={state => …}`) receive either shape:
36
-
37
- ```tsx
38
- className={state => cx(classes.root, typeof className === "function" ? className(state) : className)}
39
- ```
40
-
41
- - **Two components sharing one visual share one CVA module**, a `{name}.cva.ts` next to them, so their variant axes can't
42
- drift apart.
@@ -1,63 +0,0 @@
1
- # Components
2
-
3
- How a component lives on disk and how dumb it stays. Roles, state, and effects in full are [react.md](react.md); styling is
4
- [styling.md](styling.md).
5
-
6
- ## As dumb as possible
7
-
8
- Data comes from outside — props-fed, never self-fetching. Presentational logic (formatting a label, deriving a display state)
9
- is fine; owning data is not:
10
-
11
- ```tsx
12
- // components/user-card/user-card.tsx
13
- interface Props {
14
- name: string;
15
- role: string;
16
- onEdit: () => void;
17
- }
18
-
19
- export function UserCard({ name, role, onEdit }: Props) {
20
- return (
21
- <Card.Root>
22
- <Card.Content>
23
- <Typo>{name}</Typo>
24
- <Chip>{role}</Chip>
25
- </Card.Content>
26
- <Card.Footer>
27
- <Button onClick={onEdit}>Edit</Button>
28
- </Card.Footer>
29
- </Card.Root>
30
- );
31
- }
32
- ```
33
-
34
- No query hook, no store access, no route awareness — the component renders what it's given and reports events upward. Local
35
- UI state (`isOpen`, a draft value) is allowed; anything whose truth lives elsewhere is not ([react.md](react.md)).
36
-
37
- ## Grouping
38
-
39
- `components/` groups by kind — a layout component under `layouts/`, not beside a domain widget. Flat is fine while there are
40
- few; let the grouping follow what the project actually has rather than imposing it up front. The kinds worth separating are
41
- the component roles in [react.md](react.md).
42
-
43
- ## One file or a folder
44
-
45
- A component gets a folder once it has more than one file — sub-components, styles, tests — with an `index.ts` that only
46
- re-exports:
47
-
48
- ```
49
- components/data-table/
50
- data-table.tsx
51
- data-table-row.tsx
52
- data-table.module.css
53
- index.ts
54
- ```
55
-
56
- Imports then read `#/components/data-table` and the inside can be restructured without touching call sites. Single-file
57
- components stay single files, directly in their group.
58
-
59
- ## Colocation
60
-
61
- The stylesheet is colocated as `<component>.module.css` next to the component, and only dumb components have one — a
62
- container that wants CSS is asking for a layout component instead ([react.md](react.md)). Tests and local types sit next to
63
- their subject too. A file you have to hunt for in a parallel tree gets edited less carefully.