75 lines
3.2 KiB
Markdown
75 lines
3.2 KiB
Markdown
# Runnable HTML and CSS examples in native TSX
|
|
|
|
The maintained [dashboard project](../examples/dashboard/README.md) translates
|
|
common HTML patterns into a native application: sidebar navigation, KPI cards,
|
|
a searchable list, settings, loading, empty and error states. Its application
|
|
entry is [`src/app.tsx`](../examples/dashboard/src/app.tsx); the complete
|
|
screen composition and event wiring live in
|
|
[`src/dashboard.tsx`](../examples/dashboard/src/dashboard.tsx).
|
|
|
|
Run it from `examples/dashboard/` with the normal project commands:
|
|
|
|
```sh
|
|
ziran fetch --locked
|
|
ziran build
|
|
ziran run
|
|
```
|
|
|
|
The same TSX screen builds through the declared portable or browser profile:
|
|
|
|
```sh
|
|
ziran tool kryon build portable
|
|
ziran tool kryon build web
|
|
```
|
|
|
|
The native model in [`src/model.zi`](../examples/dashboard/src/model.zi)
|
|
contains records and filtering rules. Persistent edit buffers and actions
|
|
live in [`src/dashboard_state.zi`](../examples/dashboard/src/dashboard_state.zi).
|
|
The screen imports those checked declarations directly. Its native
|
|
[`src/styles.zi`](../examples/dashboard/src/styles.zi) parses and installs the
|
|
CSS, including theme tokens, focus, hover and responsive rules.
|
|
|
|
For example, the screen's layout uses ordinary typed components:
|
|
|
|
```tsx
|
|
import { Session } from "kryon/session";
|
|
import { Column, Row } from "kryon/tsx/layout";
|
|
import { Button } from "kryon/tsx/button";
|
|
import { Text } from "kryon/tsx/text";
|
|
|
|
export function SearchActions(session: Session): void {
|
|
<Column session={session} props={{padding: s32(16), padding_override: true}}>
|
|
<Text session={session} props={{text: "Filter cluster nodes"}}/>
|
|
<Row session={session} props={{gap: s32(12), gap_override: true}}>
|
|
<Button session={session} props={{label: "Apply"}}/>
|
|
<Button session={session} props={{label: "Settings"}}/>
|
|
</Row>
|
|
</Column>;
|
|
}
|
|
```
|
|
|
|
The complete dashboard connects activations to real model actions, binds its
|
|
`TextField` to stable native storage and scopes its settings modal. Copy that
|
|
screen and model together when starting an application; the fragment above
|
|
only illustrates composition.
|
|
|
|
Generate deterministic native previews, including each state and viewport:
|
|
|
|
```sh
|
|
mkdir -p build/previews
|
|
ziran tool kryon preview default --theme light --width 460,768,1120 --height 760 --output build/previews/dashboard
|
|
ziran tool kryon preview settings --theme dark --width 460 --height 760 --output build/previews/settings
|
|
ziran tool kryon preview responsive --width 460,768,1120 --height 760 --output build/previews/responsive
|
|
```
|
|
|
|
Each preview writes a PNG and the same retained semantic tree as JSON. The
|
|
[responsive fixture](../examples/dashboard/previews/responsive.tsx) demonstrates
|
|
measured grids, full-row cards and a horizontal ledger. Its
|
|
[stylesheet](../examples/dashboard/previews/responsive_styles.zi) defines the
|
|
tracks and breakpoints. The existing `tests/responsive_dashboard_test.py`
|
|
checks placement, semantics and native/portable parity from the Kryon root;
|
|
the dashboard README documents the complete verification commands.
|
|
|
|
Use [HTML_TO_KRYON.md](HTML_TO_KRYON.md) for the component mapping and supported
|
|
CSS subset, or load [ui-map.json](ui-map.json) for its checked TSX catalogue.
|