118 lines
15 KiB
Plaintext
118 lines
15 KiB
Plaintext
page wrnexusui {
|
||
seo {
|
||
title = "@wrnexus/ui"
|
||
description = "Themeable server-rendered UI components and CSS."
|
||
}
|
||
|
||
view {
|
||
<div class="docs-shell">
|
||
<header class="topbar">
|
||
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
|
||
<nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
|
||
<button data-wire-theme-toggle class="theme-button" aria-label="Toggle theme">Theme</button>
|
||
</header>
|
||
<main class="page package-page">
|
||
<aside class="sidebar"><a href="/packages">← All packages</a><span class="category">Frontend</span><h1>@wrnexus/ui</h1><p>Themeable server-rendered UI components and CSS.</p><code>bun add @wrnexus/ui@0.2.12</code><nav><a href="#guide">Guide</a><a href="#api">Complete API</a></nav></aside>
|
||
<article class="documentation"><section class="doc-intro"><span class="eyebrow">Frontend</span><h1>@wrnexus/ui</h1><p>Themeable server-rendered UI components and CSS.</p><pre><code>bun add @wrnexus/ui@0.2.12</code></pre></section><section id="guide" class="prose"><blockquote>First-party Wire UI component library — a set of themeable <code>.wrn</code> components plus a single tokenized stylesheet.</blockquote>
|
||
<p>Part of the <strong>WRNexusJS</strong> framework — an SSR-first, Bun-native full-stack web framework.</p>
|
||
<h3 id="overview">Overview</h3>
|
||
<p><code>@wrnexus/ui</code> ships a library of server-rendered <code>.wrn</code> components (layout, form controls, and feedback UI) together with one themeable stylesheet, <code>ui.css</code>. The components are <strong>auto-discovered</strong> by the framework router — you don't import them in code. Once the package's component directory is on the router's scan path, you mount any component in a page with <code>data-component="<name>"</code>. Every visual is driven by <code>var(--wire-*)</code> theme tokens, so components restyle instantly when the theme changes. The tiny JS surface (<code>src/index.ts</code>) exists only so the toolchain (CLI build + dev server) can locate the component directory and stylesheet.</p>
|
||
<h3 id="installation">Installation</h3>
|
||
<pre data-language="bash"><code>bun add @wrnexus/ui</code></pre>
|
||
<blockquote>Private package — the machine must be authenticated to the <code>wrnexus</code> npm org</blockquote>
|
||
<blockquote>(a read token in <code>~/.npmrc</code>). Requires <strong>Bun</strong> (Node is not supported).</blockquote>
|
||
<p>In practice you rarely install this directly: <code>@wrnexus/cli</code> and <code>@wrnexus/dev-server</code> already depend on it and wire it into the router for you (see [Auto-discovery](#auto-discovery)).</p>
|
||
<h3 id="components">Components</h3>
|
||
<p>Components live as <code>.wrn</code> files under <code>packages/ui/components/</code>. The mount name is the <strong>lowercase file basename</strong> (e.g. <code>button.wrn</code> → <code>data-component="button"</code>). Each accepts a <code>class</code> prop (appended to its root element) and most render their body from either a named prop or the default slot.</p>
|
||
<h4 id="layout">Layout</h4>
|
||
<div class="table-wrap"><table>
|
||
<thead><tr><th>Name</th><th>Purpose</th><th>Key props</th></tr></thead>
|
||
<tbody><tr><td><code>container</code></td><td>Max-width centered content wrapper</td><td><code>class</code></td></tr><tr><td><code>stack</code></td><td>Vertical column with gap</td><td><code>gap</code> (0–8)</td></tr><tr><td><code>hstack</code></td><td>Horizontal row with gap</td><td><code>gap</code> (0–8)</td></tr><tr><td><code>grid</code></td><td>CSS grid container</td><td>see source</td></tr><tr><td><code>divider</code></td><td>Horizontal rule</td><td><code>class</code></td></tr><tr><td><code>spacer</code></td><td>Flexible/empty spacing element</td><td>see source</td></tr></tbody></table></div>
|
||
<h4 id="core-feedback">Core / feedback</h4>
|
||
<div class="table-wrap"><table>
|
||
<thead><tr><th>Name</th><th>Purpose</th><th>Key props</th></tr></thead>
|
||
<tbody><tr><td><code>button</code></td><td>Button</td><td><code>label</code>, <code>variant</code> (<code>default</code>\</td><td><code>primary</code>\</td><td><code>danger</code>\</td><td><code>ghost</code>), <code>size</code> (<code>sm</code>\</td><td><code>md</code>\</td><td><code>lg</code>), <code>type</code></td></tr><tr><td><code>input</code></td><td>Text input</td><td>see source</td></tr><tr><td><code>textarea</code></td><td>Multi-line input</td><td>see source</td></tr><tr><td><code>checkbox</code></td><td>Checkbox</td><td>see source</td></tr><tr><td><code>badge</code></td><td>Small status badge</td><td><code>label</code>, <code>variant</code></td></tr><tr><td><code>alert</code></td><td>Callout box</td><td><code>variant</code> (<code>info</code>\</td><td><code>success</code>\</td><td><code>danger</code>\</td><td><code>warning</code>), <code>title</code>, <code>message</code></td></tr><tr><td><code>card</code></td><td>Padded, bordered surface</td><td><code>class</code></td></tr><tr><td><code>avatar</code></td><td>User avatar</td><td>see source</td></tr><tr><td><code>spinner</code></td><td>Loading indicator</td><td>see source</td></tr><tr><td><code>disclosure</code></td><td>Expandable details/summary</td><td>see source</td></tr><tr><td><code>theme-toggle</code></td><td>Theme switch button (binds <code>data-wire-theme-toggle</code>)</td><td><code>label</code></td></tr></tbody></table></div>
|
||
<h4 id="additional-controls-data-display">Additional controls & data display</h4>
|
||
<p>Also shipped: <code>select</code>, <code>radio</code>, <code>switch</code>, <code>progress</code>, <code>tag</code>, <code>skeleton</code>, <code>tooltip</code>, and <code>table</code>.</p>
|
||
<p>The authoritative, always-current list is <code>uiComponentNames()</code> (below), which reads the component directory at runtime.</p>
|
||
<h3 id="api">API</h3>
|
||
<p>The JS module (<code>@wrnexus/ui</code>) exposes four helpers used by the build tooling to locate the component assets. There is no component code to import — the components are <code>.wrn</code> files rendered server-side.</p>
|
||
<div class="table-wrap"><table>
|
||
<thead><tr><th>Export</th><th>Signature</th><th>Returns</th></tr></thead>
|
||
<tbody><tr><td><code>uiComponentsDir</code></td><td><code>() => string</code></td><td>Absolute path to the <code>.wrn</code> component directory (feed to <code>buildRouter</code>'s <code>componentDirs</code>).</td></tr><tr><td><code>uiCssPath</code></td><td><code>() => string</code></td><td>Absolute path to <code>ui.css</code>.</td></tr><tr><td><code>uiCss</code></td><td><code>() => string</code></td><td>The <code>ui.css</code> file contents (all <code>.wire-*</code> classes, themed via tokens).</td></tr><tr><td><code>uiComponentNames</code></td><td><code>() => string[]</code></td><td>Sorted list of built-in component names (e.g. for <code>wrnexus eject</code> listing).</td></tr></tbody></table></div>
|
||
<h4 id="ui-css-asset-export"><code>./ui.css</code> asset export</h4>
|
||
<p><code>package.json</code> also exposes the raw stylesheet as a subpath asset:</p>
|
||
<pre data-language="json"><code>"exports": {
|
||
".": "./src/index.ts",
|
||
"./ui.css": "./ui.css"
|
||
}</code></pre>
|
||
<p>The framework serves this stylesheet once at <code>/__wrnexus/ui.css</code>, so pages get all component styles from a single request.</p>
|
||
<h3 id="usage">Usage</h3>
|
||
<h4 id="auto-discovery">Auto-discovery</h4>
|
||
<p>The router scans extra <code>componentDirs</code> (in addition to the app's own <code>app/components</code>) and keys components by name. Library dirs are scanned <strong>first</strong> and <code>app/components</code> <strong>last</strong>, so an app component of the same name shadows the library's. The CLI build (<code>@wrnexus/cli</code>) and dev server (<code>@wrnexus/dev-server</code>) both wire the UI directory in for you:</p>
|
||
<pre data-language="ts"><code>import { buildRouter } from "@wrnexus/router";
|
||
import { uiComponentsDir } from "@wrnexus/ui";
|
||
|
||
const router = buildRouter(appDir, { componentDirs: [uiComponentsDir()] });</code></pre>
|
||
<h4 id="mounting-components-in-a-page">Mounting components in a page</h4>
|
||
<p>Once discovered, mount any component by name via <code>data-component</code>. Quoted attributes (other than <code>data-component</code>) become string props:</p>
|
||
<pre data-language="html"><code><div data-component="card">
|
||
<div data-component="badge" label="New"></div>
|
||
<button data-component="button" label="Save" variant="primary" size="lg"></button>
|
||
<div data-component="alert" variant="success" title="Done" message="Saved."></div>
|
||
</div></code></pre>
|
||
<h3 id="overrides">Overrides</h3>
|
||
<p>Ways to customize the components, in increasing order of power:</p>
|
||
<p>1. <strong>Theme tokens</strong> — override CSS custom properties such as <code>--wire-color-primary</code>, <code>--wire-color-surface</code>, <code>--wire-radius-sm</code>, etc. Every component style resolves through <code>var(--wire-*)</code>, so changing a token restyles everything instantly (including across theme switches). 2. <strong>App CSS</strong> — redefine a <code>.wire-*</code> class in your own stylesheet, which is loaded after <code>ui.css</code> and therefore wins. 3. <strong><code>class</code> prop</strong> — pass a <code>class</code> prop to a component; it is appended to the component's root element, letting you add per-instance classes without touching the base styles. 4. <strong><code>wrnexus eject <name></code></strong> — copy the component's <code>.wrn</code> source into your <code>app/components</code>, where (because app components shadow library ones) you fully own and can edit it. Use <code>uiComponentNames()</code> for the list of ejectable names.</p>
|
||
<h3 id="requirements-notes">Requirements / Notes</h3>
|
||
<ul>
|
||
<li><strong>Bun-only</strong> — the package uses standard fs/path/url APIs but is published and</li>
|
||
<p>consumed within the Bun-native WRNexusJS toolchain (Node is not supported).</p>
|
||
<li>Peer packages: components are discovered and rendered by</li>
|
||
<p>[<code>@wrnexus/router</code>](../router) (via <code>componentDirs</code>) and served by [<code>@wrnexus/dev-server</code>](../dev-server) / built by [<code>@wrnexus/cli</code>](../cli).</p>
|
||
<li>Depends on [<code>@wrnexus/core</code>](../core) (<code>dependencies</code>).</li>
|
||
<li><code>theme-toggle</code> relies on the framework's theme runtime, which binds the</li>
|
||
<p><code>data-wire-theme-toggle</code> attribute — no per-component JS is required.</p>
|
||
</ul></section><section id="api" class="prose api"><h2>Complete TypeScript API</h2><p>This declaration is generated from the exact published package and lists its exported functions, classes, interfaces, and types.</p><pre data-language="typescript"><code>/**
|
||
* @wrnexus/ui — the Wire UI component library.
|
||
*
|
||
* Components are `.wrn` files under `components/`, auto-discovered by the
|
||
* framework (the router scans this directory in addition to the app's own
|
||
* `app/components`). Mount them in any page with `data-component="<name>"`.
|
||
* Their styles live in a single themeable stylesheet, `ui.css`, served once at
|
||
* `/__wrnexus/ui.css` — every class uses `var(--wire-*)` theme tokens.
|
||
*
|
||
* Override, in increasing order of power:
|
||
* 1. theme tokens (change `--wire-color-primary`, etc.)
|
||
* 2. redefine a `.wire-*` class in your own CSS (loaded after ui.css)
|
||
* 3. pass a `class` prop (appended to the component root)
|
||
* 4. `wrnexus eject <name>` to copy the component into `app/components` and own it
|
||
*/
|
||
/** Absolute path to the directory of Wire UI component `.wrn` files. */
|
||
declare function uiComponentsDir(): string;
|
||
/** Absolute path to the Wire UI stylesheet. */
|
||
declare function uiCssPath(): string;
|
||
/** The Wire UI stylesheet contents (all `.wire-*` classes, themed via tokens). */
|
||
declare function uiCss(): string;
|
||
/** Names of the built-in components (e.g. for `wrnexus eject` listing). */
|
||
declare function uiComponentNames(): string[];
|
||
|
||
export { uiComponentNames, uiComponentsDir, uiCss, uiCssPath };
|
||
</code></pre></section><section id="examples" class="prose examples"><h2>Examples</h2><p>Copy-ready examples taken from this package's published documentation.</p><div class="example-grid"><article class="example-card"><h3>Example 1</h3><pre data-language="bash"><code>bun add @wrnexus/ui</code></pre></article><article class="example-card"><h3>Example 2</h3><pre data-language="json"><code>"exports": {
|
||
".": "./src/index.ts",
|
||
"./ui.css": "./ui.css"
|
||
}</code></pre></article><article class="example-card"><h3>Example 3</h3><pre data-language="ts"><code>import { buildRouter } from "@wrnexus/router";
|
||
import { uiComponentsDir } from "@wrnexus/ui";
|
||
|
||
const router = buildRouter(appDir, { componentDirs: [uiComponentsDir()] });</code></pre></article><article class="example-card"><h3>Example 4</h3><pre data-language="html"><code><div data-component="card">
|
||
<div data-component="badge" label="New"></div>
|
||
<button data-component="button" label="Save" variant="primary" size="lg"></button>
|
||
<div data-component="alert" variant="success" title="Done" message="Saved."></div>
|
||
</div></code></pre></article></div></section></article>
|
||
<aside class="on-this-page"><h2>On this page</h2><nav><a class="toc-level-2" href="#guide">Guide</a><a class="toc-level-3" href="#overview">Overview</a><a class="toc-level-3" href="#installation">Installation</a><a class="toc-level-3" href="#components">Components</a><a class="toc-level-4" href="#layout">Layout</a><a class="toc-level-4" href="#core-feedback">Core / feedback</a><a class="toc-level-4" href="#additional-controls-data-display">Additional controls & data display</a><a class="toc-level-3" href="#api">API</a><a class="toc-level-4" href="#ui-css-asset-export">./ui.css asset export</a><a class="toc-level-3" href="#usage">Usage</a><a class="toc-level-4" href="#auto-discovery">Auto-discovery</a><a class="toc-level-4" href="#mounting-components-in-a-page">Mounting components in a page</a><a class="toc-level-3" href="#overrides">Overrides</a><a class="toc-level-3" href="#requirements-notes">Requirements / Notes</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
|
||
</main>
|
||
<footer>WRNexusJS 0.2.12 · SSR-first · Bun-native · Documentation generated from published package APIs.</footer>
|
||
</div>
|
||
}
|
||
}
|