@imfusion/web-ui 0.6.4-dev.8.g41d03f2f → 0.7.0
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.
- package/CHANGELOG.md +391 -0
- package/README.md +22 -55
- package/dist/assets/vendors/base-ui.d.ts +2 -3
- package/dist/breakpoints/min-width.d.ts +3 -7
- package/dist/breakpoints/registry.d.ts +3 -9
- package/dist/{code-Ce8uiPsv.js → code-D2lwxHgd.js} +15 -15
- package/dist/codegen/gen-breakpoints-css.d.ts +0 -4
- package/dist/codegen/gen-token-css.d.ts +0 -2
- package/dist/components/app-shell/app-shell.d.ts +7 -11
- package/dist/components/button/button.d.ts +7 -12
- package/dist/components/callout/callout.d.ts +11 -18
- package/dist/components/card/card.d.ts +11 -10
- package/dist/components/checkbox/checkbox.d.ts +2 -38
- package/dist/components/chip/chip.cva.d.ts +2 -4
- package/dist/components/chip/chip.d.ts +1 -1
- package/dist/components/code/code.d.ts +2 -2
- package/dist/components/collapsible/collapsible.d.ts +4 -35
- package/dist/components/copy-button/copy-button.d.ts +1 -1
- package/dist/components/drawer/drawer.d.ts +17 -100
- package/dist/components/field/field.d.ts +7 -67
- package/dist/components/fieldset/fieldset.d.ts +2 -15
- package/dist/components/icon/icon.d.ts +2 -2
- package/dist/components/input/input.d.ts +2 -8
- package/dist/components/logo/imfusion/imfusion.d.ts +2 -5
- package/dist/components/logo/imfusion/marks.d.ts +10 -0
- package/dist/components/logo/logo.d.ts +3 -3
- package/dist/components/navigation-menu/subs/flyout-link.d.ts +5 -19
- package/dist/components/navigation-menu/subs/inline-submenu.d.ts +2 -4
- package/dist/components/navigation-menu/subs/link.d.ts +6 -23
- package/dist/components/navigation-menu/subs/overlay.d.ts +6 -51
- package/dist/components/navigation-menu/subs/shared.d.ts +4 -14
- package/dist/components/navigation-menu/subs/structure.d.ts +7 -29
- package/dist/components/navigation-menu/subs/trigger.d.ts +11 -20
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/number-field.d.ts +72 -0
- package/dist/components/number-field/number-field.meta.d.ts +2 -0
- package/dist/components/popover/popover.d.ts +23 -98
- package/dist/components/row/row.d.ts +1 -1
- package/dist/components/select/select.d.ts +26 -189
- package/dist/components/separator/separator.d.ts +5 -4
- package/dist/components/slider/slider.d.ts +7 -77
- package/dist/components/spinner/spinner.d.ts +13 -8
- package/dist/components/stack/stack.d.ts +3 -4
- package/dist/components/switch/switch.d.ts +2 -31
- package/dist/components/table/table.d.ts +10 -18
- package/dist/components/tabs/tabs.d.ts +18 -52
- package/dist/components/toast/toast.d.ts +16 -103
- package/dist/components/toggle/toggle.d.ts +3 -21
- package/dist/components/toggle-group/toggle-group.d.ts +3 -20
- package/dist/components/tooltip/tooltip.d.ts +26 -85
- package/dist/components/typo/typo.d.ts +25 -25
- package/dist/docgen/gen-docgen.utils.d.ts +3 -4
- package/dist/hooks/use-color-scheme.d.ts +5 -11
- package/dist/hooks/use-media-query.d.ts +2 -7
- package/dist/{icons-Cy1HAosO.js → icons-CaGCCwG-.js} +7 -7
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1486 -1368
- package/dist/integrations/code-highlight/highlighter.d.ts +1 -56
- package/dist/integrations/code-highlight.js +41 -189
- package/dist/integrations/image-display-options/image-display-options-view.utils.d.ts +0 -1
- package/dist/integrations/image-display-options.js +54 -54
- package/dist/llms/evals/runner/affected.d.ts +2 -0
- package/dist/llms/evals/runner/benchmark.d.ts +12 -0
- package/dist/llms/evals/runner/compare.d.ts +2 -0
- package/dist/llms/evals/runner/config.d.ts +29 -0
- package/dist/llms/evals/runner/evidence.d.ts +7 -0
- package/dist/llms/evals/runner/execute.d.ts +32 -0
- package/dist/llms/evals/runner/grade.d.ts +10 -0
- package/dist/llms/evals/runner/report-md.d.ts +2 -0
- package/dist/llms/evals/runner/report.d.ts +4 -0
- package/dist/llms/evals/runner/run.d.ts +2 -0
- package/dist/llms/evals/runner/scenario.d.ts +3 -0
- package/dist/llms/evals/runner/types.d.ts +140 -0
- package/dist/llms/evals/runner/workspace.d.ts +2 -0
- package/dist/llms/evals/runner/write-generated.d.ts +1 -0
- package/dist/provider/web-ui-provider.d.ts +4 -1
- package/dist/style.css +1 -1
- package/dist/tabs-BS6rqrrA.js +398 -0
- package/dist/tokens/apply.d.ts +4 -9
- package/dist/tokens/control-registry.d.ts +3 -6
- package/dist/tokens/types.d.ts +7 -24
- package/dist/tokens/use-token-controls.d.ts +3 -12
- package/dist/types/meta.d.ts +15 -32
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/resolve-state-props.d.ts +4 -0
- package/dist/vite/brand-assets.d.ts +3 -0
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/readable-css-module-names.d.ts +11 -0
- package/dist/vite.js +55 -0
- package/dist/web-ui-cli.js +322 -0
- package/docs/user-guide/AgentTooling.mdx +133 -0
- package/docs/user-guide/BrandAssets.mdx +103 -0
- package/docs/user-guide/Changelog.mdx +26 -0
- package/docs/user-guide/GettingStarted.mdx +71 -0
- package/docs/user-guide/HowItsBuilt.mdx +114 -0
- package/docs/user-guide/Tokens.mdx +88 -0
- package/docs/user-guide/UsagePatterns.mdx +123 -0
- package/package.json +28 -22
- package/src/assets/public/favicon/apple-touch-icon.png +0 -0
- package/src/assets/public/favicon/favicon-16.png +0 -0
- package/src/assets/public/favicon/favicon-32.png +0 -0
- package/src/assets/public/favicon/favicon.ico +0 -0
- package/src/assets/public/favicon/favicon.svg +7 -0
- package/src/assets/public/favicon/icon-192.png +0 -0
- package/src/assets/public/favicon/icon-512.png +0 -0
- package/src/assets/public/favicon/og-image.png +0 -0
- package/src/assets/public/spinner/imfusion-spinner-black.webp +0 -0
- package/src/assets/public/spinner/imfusion-spinner-blue.webp +0 -0
- package/src/assets/public/spinner/imfusion-spinner-white.webp +0 -0
- package/src/docgen/doc.gen.json +3255 -603
- package/src/llms/install-templates/AGENTS.md +4 -4
- package/src/llms/install-templates/hooks/baseline-staleness.sh +9 -2
- package/src/llms/llms.gen.txt +7 -1
- package/src/llms/skills/imf-web-ui/SKILL.md +44 -21
- package/src/llms/skills/imf-web-ui-audit/SKILL.md +25 -11
- package/src/llms/skills/imf-web-ui-components/SKILL.md +7 -3
- package/src/llms/skills/imf-web-ui-conventions/SKILL.md +3 -2
- package/src/llms/skills/imf-web-ui-conventions/templates/AUDIT_CHECKLIST.md +0 -1
- package/src/llms/skills/imf-web-ui-conventions/templates/REPORT.md +21 -2
- package/src/llms/skills/imf-web-ui-conventions/topics/agent-tooling.md +15 -10
- package/src/llms/skills/imf-web-ui-conventions/topics/assets.md +7 -4
- package/src/llms/skills/imf-web-ui-conventions/topics/data.md +3 -1
- package/src/llms/skills/imf-web-ui-conventions/topics/docs-structure.md +2 -2
- package/src/llms/skills/imf-web-ui-conventions/topics/git.md +4 -2
- package/src/llms/skills/imf-web-ui-conventions/topics/library-setup.md +10 -1
- package/src/llms/skills/imf-web-ui-conventions/topics/styling.md +2 -2
- package/src/llms/skills/imf-web-ui-conventions/topics/tokens.md +4 -2
- package/src/llms/skills/imf-web-ui-conventions/topics/tooling.md +13 -11
- package/src/llms/skills/imf-web-ui-setup/SKILL.md +17 -9
- package/src/llms/skills/imf-web-ui-update/SKILL.md +47 -19
- package/src/llms/skills/imf-web-ui-ux/SKILL.md +6 -3
- package/src/llms/tokens.gen.json +79 -15
- package/bin/install.js +0 -446
- package/dist/build/vite-css-module-names/index.d.ts +0 -20
- package/dist/build/vite-css-module-names.js +0 -17
- package/dist/components/spinner/spinner.geometry.d.ts +0 -37
- package/dist/integrations/code-highlight/languages/cmake.d.ts +0 -1
- package/dist/integrations/code-highlight/languages/cpp.d.ts +0 -1
- package/dist/tabs-DIe1Utiy.js +0 -371
- /package/dist/{meta-CySnRuVp.js → meta-j-7HGrWv.js} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import { Typo } from "#/components/typo";
|
|
3
|
+
|
|
4
|
+
<Meta title="User Guide/Getting Started" />
|
|
5
|
+
|
|
6
|
+
<Typo.Hero>Getting started</Typo.Hero>
|
|
7
|
+
|
|
8
|
+
<Typo.Lead variant="primary">`@imfusion/web-ui` is the shared React UI library for ImFusion web apps. It provides accessible primitives, ImFusion tokens,
|
|
9
|
+
and one public import surface.</Typo.Lead>
|
|
10
|
+
|
|
11
|
+
The library is built to be set up and used through a coding agent. The recommended way to wire it up is to ask the agent,
|
|
12
|
+
rather than follow a manual walkthrough.
|
|
13
|
+
|
|
14
|
+
## 1. Install the package
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @imfusion/web-ui
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The package requires React and React DOM 19 or newer.
|
|
21
|
+
|
|
22
|
+
## 2. Install the agent skills
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npx web-ui install skills --harness=all
|
|
26
|
+
npx web-ui install hooks --harness=all
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This installs the skills an agent uses to work with the library. The hooks point the agent at the right skill for each task
|
|
30
|
+
and ask it to verify the project after it edits source files. [Agent Tooling](./AgentTooling.mdx) covers the flags and what
|
|
31
|
+
each piece does.
|
|
32
|
+
|
|
33
|
+
## 3. Ask the agent to set up the library
|
|
34
|
+
|
|
35
|
+
Tell your agent, in plain language:
|
|
36
|
+
|
|
37
|
+
> Set up @imfusion/web-ui in this project.
|
|
38
|
+
|
|
39
|
+
Behind the scenes this runs the setup skill, `/imf-web-ui-setup`. It proposes a plan and writes the wiring only after you
|
|
40
|
+
approve it.
|
|
41
|
+
|
|
42
|
+
## 4. What the agent writes
|
|
43
|
+
|
|
44
|
+
For an existing project, the agent adds the stylesheet import and mounts `WebUIProvider` once, near the application root:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import "@imfusion/web-ui/styles.css";
|
|
48
|
+
import { Button, WebUIProvider } from "@imfusion/web-ui";
|
|
49
|
+
|
|
50
|
+
export function App() {
|
|
51
|
+
return (
|
|
52
|
+
<WebUIProvider>
|
|
53
|
+
<Button>Save</Button>
|
|
54
|
+
</WebUIProvider>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Import primitives from `@imfusion/web-ui`. Do not import Base UI components or styles directly.
|
|
60
|
+
|
|
61
|
+
An existing project that already has UI can also ask the agent for an audit. `/imf-web-ui-audit` checks the project against
|
|
62
|
+
the library's conventions and reports what it finds without changing any file.
|
|
63
|
+
|
|
64
|
+
For a new project, the same setup skill can also propose routing, an app shell, and other starter pieces. It writes only what
|
|
65
|
+
you approve.
|
|
66
|
+
|
|
67
|
+
## Without an agent
|
|
68
|
+
|
|
69
|
+
Make the same two changes yourself: install the package, then add the stylesheet import and `WebUIProvider` shown above.
|
|
70
|
+
|
|
71
|
+
<PageNav />
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import { Typo } from "#/components/typo";
|
|
3
|
+
|
|
4
|
+
<Meta title="User Guide/How It's Built" />
|
|
5
|
+
|
|
6
|
+
<Typo.Hero>How it's built</Typo.Hero>
|
|
7
|
+
|
|
8
|
+
You can use the library without knowing its implementation. The snippets below are simplified from the library source.
|
|
9
|
+
|
|
10
|
+
## Behavior comes from an implementation library
|
|
11
|
+
|
|
12
|
+
Adapted interactive primitives use Base UI for focus management, keyboard behavior, and accessibility details. Web UI wraps
|
|
13
|
+
each part, takes its props from the upstream type, and adds its own class and identity:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Switch as Upstream } from "@base-ui/react/switch";
|
|
17
|
+
|
|
18
|
+
export function Root(props: React.ComponentProps<typeof Upstream.Root>) {
|
|
19
|
+
return <Upstream.Root {...props} data-imf-ui-component="Switch.Root" className={styles.root} />;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Web UI owns the public props, defaults, tokens, styles, and exports. An application imports `Switch` from `@imfusion/web-ui`
|
|
24
|
+
and never sees `@base-ui/react`, so the implementation can change without forcing a consumer migration.
|
|
25
|
+
|
|
26
|
+
## Web UI is the styled middle layer
|
|
27
|
+
|
|
28
|
+
Between the implementation library and the application, Web UI adds the look. Styles are CSS Modules that read `--imf-ui-*`
|
|
29
|
+
tokens, and two mechanisms pick which rules apply: CVA for the props a consumer sets, and data attributes for the state a
|
|
30
|
+
component is in at runtime.
|
|
31
|
+
|
|
32
|
+
### Variants with CVA
|
|
33
|
+
|
|
34
|
+
[class-variance-authority](https://cva.style/docs) (CVA) maps each variant prop to a CSS Module class. The defaults sit in
|
|
35
|
+
the component signature:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { cva } from "class-variance-authority";
|
|
39
|
+
import classes from "./button.module.css";
|
|
40
|
+
|
|
41
|
+
const button = cva(classes.root, {
|
|
42
|
+
variants: {
|
|
43
|
+
variant: { primary: classes.variantPrimary, outline: classes.variantOutline },
|
|
44
|
+
size: { sm: classes.sizeSm, md: classes.sizeMd }
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export function Button({ variant = "primary", size = "md", className, ...props }: Props) {
|
|
49
|
+
return <Upstream {...props} data-imf-ui-component="Button" className={button({ variant, size, className })} />;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A consumer `className` joins the variant classes instead of replacing them.
|
|
54
|
+
|
|
55
|
+
### Runtime state with data attributes
|
|
56
|
+
|
|
57
|
+
State that changes while the component runs, such as checked, open, or disabled, is not a prop to map. Base UI sets it as
|
|
58
|
+
[data attributes](https://base-ui.com/react/handbook/styling#style-hooks) on each part, like `data-checked` on
|
|
59
|
+
`Switch.Root`, and the stylesheet selects them:
|
|
60
|
+
|
|
61
|
+
```css
|
|
62
|
+
@layer imf-ui.components {
|
|
63
|
+
.root {
|
|
64
|
+
background: var(--imf-ui-color-bg-minor);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.root[data-checked] {
|
|
68
|
+
background: var(--imf-ui-color-bg-primary-main);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Base UI's page for each component lists the attributes its parts expose.
|
|
74
|
+
|
|
75
|
+
### Layers and tokens
|
|
76
|
+
|
|
77
|
+
Every rule sits in the `imf-ui.components` cascade layer. Unlayered CSS always beats layered CSS, so an application rule
|
|
78
|
+
wins without `!important`. The token changes the value everywhere; the rule changes one place:
|
|
79
|
+
|
|
80
|
+
```css
|
|
81
|
+
:root {
|
|
82
|
+
--imf-ui-color-primary-hue: 30;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-imf-ui-component="Switch.Root"] {
|
|
86
|
+
border-radius: 0;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The wrapper keeps the upstream surface complete. If an upstream part or prop is useful, Web UI exposes it instead of making an
|
|
91
|
+
app reach around the library.
|
|
92
|
+
|
|
93
|
+
## Compose parts
|
|
94
|
+
|
|
95
|
+
Compound components are namespaces of parts. Instead of one component with a prop for every arrangement, an application
|
|
96
|
+
renders the parts it needs, where it needs them:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
// One component, one prop per arrangement:
|
|
100
|
+
<Field label="Study name" description="Shown in the reading queue." descriptionPosition="above" />
|
|
101
|
+
|
|
102
|
+
// Parts, arranged by the application:
|
|
103
|
+
<Field.Root>
|
|
104
|
+
<Field.Label>Study name</Field.Label>
|
|
105
|
+
<Field.Description>Shown in the reading queue.</Field.Description>
|
|
106
|
+
<Input name="study" />
|
|
107
|
+
</Field.Root>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The first form is pseudo-code; Web UI ships only the second. The
|
|
111
|
+
[library-boundary topic](../../src/llms/skills/imf-web-ui-conventions/topics/library-boundary.md) has the consumer import and
|
|
112
|
+
composition rules.
|
|
113
|
+
|
|
114
|
+
<PageNav />
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import { Typo } from "#/components/typo";
|
|
3
|
+
|
|
4
|
+
<Meta title="Tokens/Docs" />
|
|
5
|
+
|
|
6
|
+
<Typo.Hero>Tokens</Typo.Hero>
|
|
7
|
+
|
|
8
|
+
The library's theme is a set of CSS custom properties under `--imf-ui-*`.
|
|
9
|
+
|
|
10
|
+
## Change a family
|
|
11
|
+
|
|
12
|
+
Most customization uses a control token. Controls feed the semantic tokens consumed by components:
|
|
13
|
+
|
|
14
|
+
```css
|
|
15
|
+
:root {
|
|
16
|
+
--imf-ui-color-brand-hue: 210;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Brand and primary are related. Primary hue and chroma follow brand until their own controls are changed; primary luma is
|
|
21
|
+
independent. Surface controls work the same way: `main`, `support`, and `minor` start as one ladder and can be split when
|
|
22
|
+
needed.
|
|
23
|
+
|
|
24
|
+
Use a semantic token for a one-off role. That changes one result without changing the rest of its family.
|
|
25
|
+
|
|
26
|
+
## Families
|
|
27
|
+
|
|
28
|
+
| Family | Use |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| Brand | Identity color. |
|
|
31
|
+
| Surfaces | Canvas and panels: `main`, `support`, `minor`. |
|
|
32
|
+
| Primary | Actions and calls to action. |
|
|
33
|
+
| Status | `negative`, `warning`, `positive`, and `info`. |
|
|
34
|
+
| Accents | Three independent accent slots. |
|
|
35
|
+
| Fonts | Shared font stacks and text roles. |
|
|
36
|
+
| Shape | Radius and corner controls. |
|
|
37
|
+
| Shadow | The shared elevation model. |
|
|
38
|
+
|
|
39
|
+
The live token controls and exact names are on the [token reference](../../src/tokens/token-reference.stories.tsx).
|
|
40
|
+
|
|
41
|
+
## Use semantic tokens in CSS
|
|
42
|
+
|
|
43
|
+
Components and consumer CSS should use semantic roles:
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
.panel {
|
|
47
|
+
background: var(--imf-ui-color-bg-support);
|
|
48
|
+
color: var(--imf-ui-color-fg-main);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Foreground tokens are for text, icons, borders, and focus rings. Background tokens are for fills. `fg-oncolor` is for text on
|
|
53
|
+
saturated fills.
|
|
54
|
+
|
|
55
|
+
## Color schemes
|
|
56
|
+
|
|
57
|
+
The provider sets the active scheme on the document element:
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<html data-imf-ui-color-scheme="light">
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Scheme-aware controls have light and dark values. Application CSS can select the attribute when a rule itself must change.
|
|
64
|
+
|
|
65
|
+
## Fonts, shape, and shadow
|
|
66
|
+
|
|
67
|
+
The font controls define the editorial and utility type roles. Radius controls plain rounded corners; chamfer is a separate
|
|
68
|
+
brand shape axis. Shadow controls share one lighting model across components:
|
|
69
|
+
|
|
70
|
+
- `--imf-ui-shadow-angle` sets the sun direction; the default `315deg` makes shadows fall down and right.
|
|
71
|
+
- `--imf-ui-shadow-hardness` moves from diffuse (`0`) to crisp (`1`) edges without changing the elevation level.
|
|
72
|
+
- `--imf-ui-shadow-spread` adds pixel spread to every shadow.
|
|
73
|
+
- `--imf-ui-shadow-intensity` sets the opacity of every elevation level.
|
|
74
|
+
- `--imf-ui-shadow-color` sets the cast color per scheme.
|
|
75
|
+
|
|
76
|
+
Components consume these values through tokens. `node_modules/@imfusion/web-ui/src/llms/tokens.gen.json` lists the shipped
|
|
77
|
+
token names and authored defaults.
|
|
78
|
+
|
|
79
|
+
## Explore
|
|
80
|
+
|
|
81
|
+
In Storybook, the Showcase and Reference pages show the token controls in a side panel on larger screens and behind the
|
|
82
|
+
`Tokens` button in the bottom-right corner on smaller ones. Other stories open the same drawer from that button. Changes
|
|
83
|
+
update the preview live; to keep a value, set that token in your application CSS.
|
|
84
|
+
|
|
85
|
+
- [Showcase](../../src/tokens/showcase.stories.tsx) applies the controls to real components.
|
|
86
|
+
- [Reference](../../src/tokens/token-reference.stories.tsx) lists every generated token.
|
|
87
|
+
|
|
88
|
+
<PageNav />
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
import { Typo } from "#/components/typo";
|
|
3
|
+
|
|
4
|
+
<Meta title="User Guide/Usage Patterns" />
|
|
5
|
+
|
|
6
|
+
<Typo.Hero>Usage patterns</Typo.Hero>
|
|
7
|
+
|
|
8
|
+
## Build with components
|
|
9
|
+
|
|
10
|
+
Import components and the provider from `@imfusion/web-ui`, and icons from `@imfusion/web-ui/icons`. Multi-part
|
|
11
|
+
primitives are namespaces: render the parts a screen needs, in the order the component documents.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Field, Input } from "@imfusion/web-ui";
|
|
15
|
+
|
|
16
|
+
export function StudyName() {
|
|
17
|
+
return (
|
|
18
|
+
<Field.Root>
|
|
19
|
+
<Field.Label>Study name</Field.Label>
|
|
20
|
+
<Input name="study" />
|
|
21
|
+
<Field.Description>Shown in the reading queue.</Field.Description>
|
|
22
|
+
</Field.Root>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The same pattern scales to an overlay. A drawer is a namespace too, and the field sits inside it unchanged:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Button, Drawer, Field, Input, Stack } from "@imfusion/web-ui";
|
|
31
|
+
import { Icon, Settings } from "@imfusion/web-ui/icons";
|
|
32
|
+
|
|
33
|
+
export function StudySettings() {
|
|
34
|
+
return (
|
|
35
|
+
<Drawer.Root>
|
|
36
|
+
<Drawer.Trigger render={<Button variant="secondary" startIcon={<Icon glyph={Settings} />}>Settings</Button>} />
|
|
37
|
+
<Drawer.Portal>
|
|
38
|
+
<Drawer.Backdrop />
|
|
39
|
+
<Drawer.Viewport>
|
|
40
|
+
<Drawer.Popup>
|
|
41
|
+
<Drawer.Content>
|
|
42
|
+
<Stack gap="4">
|
|
43
|
+
<Drawer.Title>Study settings</Drawer.Title>
|
|
44
|
+
<Field.Root>
|
|
45
|
+
<Field.Label>Study name</Field.Label>
|
|
46
|
+
<Input name="study" />
|
|
47
|
+
<Field.Description>Shown in the reading queue.</Field.Description>
|
|
48
|
+
</Field.Root>
|
|
49
|
+
<Drawer.Close render={<Button>Save</Button>} />
|
|
50
|
+
</Stack>
|
|
51
|
+
</Drawer.Content>
|
|
52
|
+
</Drawer.Popup>
|
|
53
|
+
</Drawer.Viewport>
|
|
54
|
+
</Drawer.Portal>
|
|
55
|
+
</Drawer.Root>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Every part comes from `@imfusion/web-ui`, including less common ones such as `Drawer.Indent`, `Drawer.SwipeArea`, and
|
|
61
|
+
`Field.Description`. Do not import Base UI or another implementation package directly; the library's parts carry the styles,
|
|
62
|
+
defaults, and stable identity that the rest of this page relies on.
|
|
63
|
+
|
|
64
|
+
## Change the look
|
|
65
|
+
|
|
66
|
+
Start as broad as the change is, then narrow down: a token changes a whole family, a CSS rule changes one place, and a state
|
|
67
|
+
attribute changes one state.
|
|
68
|
+
|
|
69
|
+
### With tokens
|
|
70
|
+
|
|
71
|
+
The theme is a set of `--imf-ui-*` custom properties. A control token changes a related family of semantic tokens at once:
|
|
72
|
+
|
|
73
|
+
```css
|
|
74
|
+
:root {
|
|
75
|
+
--imf-ui-color-primary-hue: 30;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
[Tokens](./Tokens.mdx) lists the families, the controls, and how to try them live in Storybook.
|
|
80
|
+
|
|
81
|
+
### With CSS
|
|
82
|
+
|
|
83
|
+
Consumer CSS outside `@layer imf-ui.components` overrides the library without `!important`:
|
|
84
|
+
|
|
85
|
+
```css
|
|
86
|
+
.my-button {
|
|
87
|
+
border-radius: 0;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Components carry `data-imf-ui-component` on their roots, so it is a stable selector. CSS Module class names are internal.
|
|
92
|
+
|
|
93
|
+
### By state
|
|
94
|
+
|
|
95
|
+
Components expose runtime state through attributes such as `data-checked`, `data-disabled`, and `data-popup-open`:
|
|
96
|
+
|
|
97
|
+
```css
|
|
98
|
+
[data-imf-ui-component="Switch.Root"][data-checked] {
|
|
99
|
+
outline: var(--imf-ui-border-size-2) solid var(--imf-ui-color-fg-positive);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use the attribute instead of maintaining a second state class.
|
|
104
|
+
|
|
105
|
+
### By color scheme
|
|
106
|
+
|
|
107
|
+
`WebUIProvider` sets `data-imf-ui-color-scheme="light"` or `"dark"` on `<html>`. Select it when an application rule needs to
|
|
108
|
+
change with the scheme:
|
|
109
|
+
|
|
110
|
+
```css
|
|
111
|
+
[data-imf-ui-color-scheme="dark"] .hero {
|
|
112
|
+
background-image: url("/hero-dark.png");
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The provider follows the OS by default. An application whose own surfaces are a fixed palette pins the scheme instead, so
|
|
117
|
+
component colors cannot disagree with them:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<WebUIProvider colorScheme="dark">{children}</WebUIProvider>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
<PageNav />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imfusion/web-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The official Web UI component library for ImFusion web apps",
|
|
5
5
|
"author": "ImFusion GmbH",
|
|
6
6
|
"homepage": "https://imfusion.com",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"module": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"bin": {
|
|
23
|
-
"web-ui
|
|
23
|
+
"web-ui": "dist/web-ui-cli.js"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"types": "./dist/integrations/*/index.d.ts",
|
|
32
32
|
"import": "./dist/integrations/*.js"
|
|
33
33
|
},
|
|
34
|
-
"./
|
|
35
|
-
"types": "./dist/
|
|
36
|
-
"import": "./dist/
|
|
34
|
+
"./vite": {
|
|
35
|
+
"types": "./dist/vite/index.d.ts",
|
|
36
|
+
"import": "./dist/vite.js"
|
|
37
37
|
},
|
|
38
38
|
"./icons": {
|
|
39
39
|
"types": "./dist/icons/index.d.ts",
|
|
@@ -42,28 +42,31 @@
|
|
|
42
42
|
"./styles.css": "./dist/style.css",
|
|
43
43
|
"./docgen.json": "./src/docgen/doc.gen.json",
|
|
44
44
|
"./llms.txt": "./src/llms/llms.gen.txt",
|
|
45
|
+
"./assets/*": "./src/assets/public/*",
|
|
45
46
|
"./*": null
|
|
46
47
|
},
|
|
47
48
|
"files": [
|
|
48
49
|
"dist",
|
|
50
|
+
"src/assets/public",
|
|
49
51
|
"docs/assets/imfusion-banner.svg",
|
|
52
|
+
"docs/user-guide",
|
|
53
|
+
"CHANGELOG.md",
|
|
50
54
|
"THIRD_PARTY_NOTICES.md",
|
|
51
55
|
"src/llms/install-templates",
|
|
52
56
|
"src/docgen/doc.gen.json",
|
|
53
57
|
"src/llms/llms.gen.txt",
|
|
54
58
|
"src/llms/icon-catalog.gen.json",
|
|
55
59
|
"src/llms/tokens.gen.json",
|
|
56
|
-
"src/llms/skills"
|
|
57
|
-
"bin/install.js"
|
|
60
|
+
"src/llms/skills"
|
|
58
61
|
],
|
|
59
62
|
"scripts": {
|
|
60
63
|
"dev": "tsx scripts/dev.ts",
|
|
61
64
|
"dev:host": "tsx scripts/dev.ts --host",
|
|
62
65
|
"dev:lib": "concurrently -n codegen,lib -c yellow,blue \"npm run codegen:watch\" \"vite build --watch\"",
|
|
63
|
-
"build": "npm run codegen && rm -rf dist && vite build && npm run codegen:docgen && npm run codegen:llms && npm run codegen:tokens",
|
|
66
|
+
"build": "npm run codegen && rm -rf dist && vite build && chmod +x dist/web-ui-cli.js && npm run codegen:docgen && npm run codegen:llms && npm run codegen:tokens",
|
|
64
67
|
"build:storybook": "npm run codegen:storybook && storybook build",
|
|
65
68
|
"ci:status": "teamcity run list --job WebSDK_WebUI_BuildTest --limit 3 --json=id,number,status,state,branchName,buildType.name,triggered.type,triggered.user.name,startDate,finishDate,webUrl | tsx scripts/ci-status.ts",
|
|
66
|
-
"storybook": "npm run codegen:storybook && storybook dev -p 6006 --no-open",
|
|
69
|
+
"storybook": "npm run codegen:storybook && storybook dev -p 6006 --no-open --ci",
|
|
67
70
|
"storybook:free-ports": "tsx scripts/free-storybook-ports.ts",
|
|
68
71
|
"codegen": "tsx src/codegen/run.ts",
|
|
69
72
|
"codegen:watch": "tsx watch src/codegen/run.ts",
|
|
@@ -87,16 +90,17 @@
|
|
|
87
90
|
"test:unit": "vitest run --project unit",
|
|
88
91
|
"test:stories": "vitest run --project storybook",
|
|
89
92
|
"test:watch": "vitest",
|
|
90
|
-
"skills:eval": "
|
|
91
|
-
"skills:eval:dev": "WEB_UI_SKILL_EVAL_ROOT=/private/tmp/web-ui-dev-skill-evals WEB_UI_SKILL_EVAL_RESULTS_DIR=.agents/evals/results WEB_UI_SKILL_EVAL_REPORT_PATH=.agents/evals/REPORT.md WEB_UI_SKILL_EVAL_SKILL_FAMILY=web-ui-dev WEB_UI_SKILL_EVAL_WORKSPACE_LABEL='development repository'
|
|
92
|
-
"skills:eval:compare": "
|
|
93
|
-
"skills:eval:
|
|
93
|
+
"skills:eval": "tsx src/llms/evals/runner/run.ts",
|
|
94
|
+
"skills:eval:dev": "WEB_UI_SKILL_EVAL_ROOT=/private/tmp/web-ui-dev-skill-evals WEB_UI_SKILL_EVAL_RESULTS_DIR=.agents/evals/results WEB_UI_SKILL_EVAL_REPORT_PATH=.agents/evals/REPORT.md WEB_UI_SKILL_EVAL_SKILL_FAMILY=web-ui-dev WEB_UI_SKILL_EVAL_WORKSPACE_LABEL='development repository' tsx src/llms/evals/runner/run.ts --scenarios-dir .agents/evals/scenarios --setup .agents/evals/setup-env.sh",
|
|
95
|
+
"skills:eval:compare": "tsx src/llms/evals/runner/compare.ts",
|
|
96
|
+
"skills:eval:affected": "tsx src/llms/evals/runner/affected.ts",
|
|
97
|
+
"skills:eval:report": "tsx src/llms/evals/runner/report.ts",
|
|
94
98
|
"git:config": "git config core.hooksPath .githooks && git config pull.rebase true && git config merge.ff only"
|
|
95
99
|
},
|
|
96
100
|
"peerDependencies": {
|
|
97
101
|
"@imfusion/sdk": "^1.0.0 || >=1.1.1-dev.0 <1.1.1",
|
|
98
102
|
"@imfusion/sdk-react": "^1.0.0 || >=1.1.1-dev.0 <1.1.1",
|
|
99
|
-
"@tanstack/highlight": "^0.0
|
|
103
|
+
"@tanstack/highlight": "^0.1.0",
|
|
100
104
|
"react": "^19.0.0",
|
|
101
105
|
"react-dom": "^19.0.0"
|
|
102
106
|
},
|
|
@@ -115,6 +119,7 @@
|
|
|
115
119
|
"@base-ui/react": "1.6.0",
|
|
116
120
|
"@clack/prompts": "1.7.0",
|
|
117
121
|
"class-variance-authority": "0.7.1",
|
|
122
|
+
"commander": "15.0.0",
|
|
118
123
|
"iconoir-react": "7.12.1"
|
|
119
124
|
},
|
|
120
125
|
"devDependencies": {
|
|
@@ -122,12 +127,12 @@
|
|
|
122
127
|
"@eslint/js": "9.39.4",
|
|
123
128
|
"@imfusion/sdk": "1.0.0",
|
|
124
129
|
"@imfusion/sdk-react": "1.0.0",
|
|
125
|
-
"@storybook/addon-a11y": "10.
|
|
126
|
-
"@storybook/addon-docs": "10.
|
|
127
|
-
"@storybook/addon-mcp": "
|
|
128
|
-
"@storybook/addon-vitest": "10.
|
|
129
|
-
"@storybook/react-vite": "10.
|
|
130
|
-
"@tanstack/highlight": "0.0
|
|
130
|
+
"@storybook/addon-a11y": "10.6.0",
|
|
131
|
+
"@storybook/addon-docs": "10.6.0",
|
|
132
|
+
"@storybook/addon-mcp": "10.6.0",
|
|
133
|
+
"@storybook/addon-vitest": "10.6.0",
|
|
134
|
+
"@storybook/react-vite": "10.6.0",
|
|
135
|
+
"@tanstack/highlight": "0.1.0",
|
|
131
136
|
"@tanstack/react-pacer": "0.22.1",
|
|
132
137
|
"@types/culori": "4.0.1",
|
|
133
138
|
"@types/mdx": "2.0.13",
|
|
@@ -148,11 +153,12 @@
|
|
|
148
153
|
"jiti": "2.7.0",
|
|
149
154
|
"knip": "6.14.2",
|
|
150
155
|
"lightningcss": "1.32.0",
|
|
151
|
-
"
|
|
156
|
+
"mermaid": "12.0.0",
|
|
152
157
|
"playwright": "1.60.0",
|
|
153
158
|
"prettier": "3.8.3",
|
|
154
159
|
"react-docgen-typescript": "2.4.0",
|
|
155
|
-
"
|
|
160
|
+
"remark-gfm": "4.0.1",
|
|
161
|
+
"storybook": "10.6.0",
|
|
156
162
|
"tsx": "4.21.0",
|
|
157
163
|
"typescript": "6.0.3",
|
|
158
164
|
"typescript-eslint": "8.59.3",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
2
|
+
<rect width="512" height="512" fill="#245EFF" />
|
|
3
|
+
<g transform="translate(72 152) scale(1.168)">
|
|
4
|
+
<path d="M320 180H0V159.715L237.082 128.105L320 65.916V180Z" fill="#FFFFFF" />
|
|
5
|
+
<path d="M320 20.2832L82.918 51.8945L0 114.082V0H320V20.2832Z" fill="#FFFFFF" />
|
|
6
|
+
</g>
|
|
7
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|