Content
cardk-card
- takes
- props title, style; slot: the body; reads card.heading, card.text
- actions
- card_open, card_dismiss (the demo's buttons)
- keys
- tab, enter
- needs
- k-btn, k-title
Template: k-card in kit.tui
<!-- k-card: a titled panel. Props: title, style. Slot: the body. A card
whose title comes from data is the class markup,
<box class="k-card" title="{PATH}">. -->
<template id="k-card" props="title style">
<box class="k-card" title="{$title}" style="{$style}">
<slot/>
</box>
</template>In use: components/card.tui
<!-- k-card · Contract: props title, style; slot: the body; reads card.heading, card.text · Actions: card_open, card_dismiss (the demo's buttons) · Keys: tab, enter · Requires: k-btn, k-title -->
<tui theme="auto">
<include src="../kit.tui"/>
<screen id="demo" focus="#card__open">
<col width="1fr" height="1fr" gap="1" pad="1">
<text class="k-title">card / panel</text>
<!-- COPY: a card is a titled box; what you write inside the use is its
body, with your own paths, ids and actions. The border turns to
the focus color while anything inside holds focus. It wraps its
content; style="height: 10" (or 1fr) fixes it. A title from data
is the class markup: <box class="k-card" title="{PATH}">. -->
<use template="k-card" title="Deploy">
<text class="k-card-title">{card.heading}</text>
<text class="k-card-muted">{card.text}</text>
<row class="k-card-actions">
<button id="card__open" class="k-btn primary" label="Open" on:click="card_open"/>
<button id="card__dismiss" class="k-btn ghost" label="Dismiss" on:click="card_dismiss"/>
</row>
</use>
<!-- COPY: side-by-side cards share the row; each takes `1fr`. -->
<row width="1fr" height="auto" gap="1">
<use template="k-card" title="Left">
<text class="k-card-text">First card</text>
</use>
<use template="k-card" title="Right">
<text class="k-card-text">Second card</text>
</use>
</row>
</col>
</screen>
</tui>key / valuek-kv
- takes
- props label, style; with="PATH as v" reads v, the value
- needs
- k-card, k-title
Template: k-kv in kit.tui
<!-- k-kv: one key / value row, in a card. Props: label, style.
with="PATH as v": the value. -->
<template id="k-kv" props="label style">
<row class="k-kv" style="{$style}">
<text class="k-kv-label">{$label}</text>
<text class="k-kv-value">{v}</text>
</row>
</template>In use: components/kv.tui
<!-- k-kv · Contract: props label, style; with="PATH as v" reads v, the value · Actions: none · Keys: none · Requires: k-card, k-title -->
<tui theme="auto">
<include src="../kit.tui"/>
<screen id="demo">
<col width="1fr" height="1fr" gap="1" pad="1">
<text class="k-title">key / value</text>
<!-- COPY: one row per field, in a card: the label is literal, the
value is a path. The label column is 8 wide; a sheet rule
(.k-kv-label { width: 10; }) widens it for every row. -->
<use template="k-card" title="Service">
<use template="k-kv" label="Name" with="svc.name as v"/>
<use template="k-kv" label="Owner" with="svc.owner as v"/>
<use template="k-kv" label="Region" with="svc.region as v"/>
<use template="k-kv" label="Version" with="svc.version as v"/>
</use>
</col>
</screen>
</tui>alertk-alert
- takes
- props title, icon, text (each optional) and style; slot: more body, after the text; reads build.retry
- needs
- k-title
Template: k-alert in kit.tui
<!-- k-alert: a callout. Props: title, icon, text, style. Slot: more body,
after the text (a dynamic line, a button). Variant: info, ok, warn,
danger. -->
<template id="k-alert" props="title icon text style">
<box class="k-alert" title="{$title}" style="{$style}">
<row class="k-alert-row">
<text class="k-alert-icon">{$icon}</text>
<col class="k-alert-body">
<text class="k-alert-text">{$text}</text>
<slot/>
</col>
</row>
</box>
</template>In use: components/alert.tui
<!-- k-alert · Contract: props title, icon, text (each optional) and style; slot: more body, after the text; reads build.retry · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
<include src="../kit.tui"/>
<screen id="demo">
<col width="1fr" height="1fr" gap="0" pad="1">
<text class="k-title">alert / callout</text>
<!-- USE: one <use> of the k-alert template per alert, with its
variant as the use's class (info, ok, warn, danger) and its text
as props (title, icon, text; each optional). The title is the box
title; the text wraps; the variant colors the frame and the icon.
What you write inside the <use> (the last alert) is more body,
after the text, with the paths of this document. -->
<use template="k-alert" class="info" title="Heads up" icon="i" text="Deploys are paused until 09:00 UTC."/>
<use template="k-alert" class="ok" title="Saved" icon="✓" text="Your changes are live in every region."/>
<use template="k-alert" class="warn" title="Quota" icon="!" text="You have used 92% of this month's build minutes."/>
<use template="k-alert" class="danger" title="Build failed" icon="✗" text="Step 3 exited with code 1: tests failed in pkg/router.">
<text>{build.retry}</text>
</use>
</col>
</screen>
</tui>badgek-badge
- takes
- reads build.number, build.status, build.ok
- needs
- k-title
Markup: components/badge.tui
<!-- k-badge · Contract: reads build.number, build.status, build.ok · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
<!-- The kit: its sheets, its overlay keys and its templates. Your own
sheet, if any, comes after it. -->
<include src="../kit.tui"/>
<screen id="demo">
<col width="1fr" height="1fr" gap="1" pad="1">
<text class="k-title">badge</text>
<!-- COPY: a badge is one text with two classes: `k-badge` and a
modifier. Modifiers: accent, ok, warn, danger, info (none =
neutral). The label is literal text or a {path}. -->
<row width="1fr" height="1" gap="1">
<text class="k-badge">draft</text>
<text class="k-badge accent">new</text>
<text class="k-badge ok">passing</text>
</row>
<row width="1fr" height="1" gap="1">
<text class="k-badge warn">flaky</text>
<text class="k-badge danger">failed</text>
<text class="k-badge info">{build.number}</text>
</row>
<!-- COPY: choose the modifier from data with class:NAME guards on the
same node (the guards are paths the host keeps true or false). -->
<row width="1fr" height="1" gap="1">
<text class="k-badge" class:ok="build.ok" class:danger="!build.ok">{build.status}</text>
</row>
</col>
</screen>
</tui>statk-stat
- takes
- props title, min, max (the sparkline range), style; with="PATH as s" reads s.value, s.delta, s.hist[] (numbers), and the flags s.good and s.bad
- needs
- k-title
Template: k-stat in kit.tui
<!-- k-stat: a KPI card. Props: title, min, max (the sparkline's range),
style. with="PATH as s": s.value, s.delta, s.hist (numbers); flags
s.good and s.bad color the change. -->
<template id="k-stat" props="title min max style">
<box class="k-stat" title="{$title}" style="{$style}">
<text class="k-stat-value">{s.value}</text>
<row class="k-stat-row">
<text class="k-stat-delta" class:good="s.good" class:bad="s.bad">{s.delta}</text>
<sparkline class="k-stat-spark" bind="s.hist" min="{$min}" max="{$max}"/>
</row>
</box>
</template>In use: components/stat.tui
<!-- k-stat · Contract: props title, min, max (the sparkline range), style; with="PATH as s" reads s.value, s.delta, s.hist[] (numbers), and the flags s.good and s.bad · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
<include src="../kit.tui"/>
<screen id="demo">
<col width="1fr" height="1fr" gap="1" pad="1">
<text class="k-title">stat / KPI card</text>
<!-- USE: the k-stat template: the `title` prop as the box title, the
value in bold, and a row with the change and a sparkline of s.hist. The
flags s.good and s.bad turn the change green or red (whether a
rise is good depends on the metric, so the host decides). `min`
and `max` fix the sparkline's range (without them it comes from
the values). Put
stats in a row; each takes `1fr` of the width. -->
<row width="1fr" height="auto" gap="1">
<use template="k-stat" title="Requests" with="stats.req as s"/>
<use template="k-stat" title="Errors" min="0" with="stats.err as s"/>
</row>
</col>
</screen>
</tui>labeled progressk-meter
- takes
- props label, style; with="PATH as m" reads m.text, m.pct (0 to 100), and the flags m.ok, m.warn and m.danger
- needs
- k-title
Template: k-meter in kit.tui
<!-- k-meter: a labeled progress bar. Props: label, style. with="PATH as m":
m.text, m.pct (0 to 100); flags m.ok, m.warn, m.danger. Variant: ok,
warn, danger. -->
<template id="k-meter" props="label style">
<col class="k-meter" style="{$style}">
<row class="k-meter-head">
<text class="k-meter-label">{$label}</text>
<spacer/>
<text class="k-meter-value">{m.text}</text>
</row>
<progress class="k-meter-bar" class:ok="m.ok" class:warn="m.warn" class:danger="m.danger" bind="m.pct"/>
</col>
</template>In use: components/meter.tui
<!-- k-meter · Contract: props label, style; with="PATH as m" reads m.text, m.pct (0 to 100), and the flags m.ok, m.warn and m.danger · Actions: none · Keys: none · Requires: k-title -->
<tui theme="auto">
<include src="../kit.tui"/>
<screen id="demo">
<col width="1fr" height="1fr" gap="1" pad="1">
<text class="k-title">labeled progress</text>
<!-- USE: the k-meter template: a head row (the label on the left, the
value text on the right) over a progress bar of m.pct, a number
from 0 to 100. Color the bar with a variant on the use (ok, warn,
danger), or from data with the flags m.ok, m.warn and m.danger.
The host updates the number (and the text) as the work
advances. -->
<use template="k-meter" label="Uploading artifact.tar" with="meters.upload as m"/>
<use template="k-meter" label="Disk" with="meters.disk as m"/>
<use template="k-meter" class="ok" label="Tests" with="meters.tests as m"/>
</col>
</screen>
</tui>empty statek-empty
- takes
- props icon, title, text (icon and text optional); slot: the call to action, your button and your action
- actions
- deploy_create (the demo's button)
- keys
- enter on the button
- needs
- k-btn, k-title
Template: k-empty in kit.tui
<!-- k-empty: an empty state, centered in the space left. Props: icon,
title, text, style. Slot: the call to action (your button, your
action). -->
<template id="k-empty" props="icon title text style">
<col class="k-empty" style="{$style}">
<text class="k-empty-icon">{$icon}</text>
<text class="k-empty-title">{$title}</text>
<text class="k-empty-text">{$text}</text>
<slot/>
</col>
</template>In use: components/empty.tui
<!-- k-empty · Contract: props icon, title, text (icon and text optional); slot: the call to action, your button and your action · Actions: deploy_create (the demo's button) · Keys: enter on the button · Requires: k-btn, k-title -->
<tui theme="auto">
<include src="../kit.tui"/>
<screen id="demo" focus="#deploy__create">
<col width="1fr" height="1fr" pad="1">
<text class="k-title">empty state</text>
<!-- USE: the k-empty template fills the space left and centers an
icon, a title and one line of help, all props (the icon and the
text are optional), then its content: the call to action. The
button, its id and its action are yours (deploy__create fires
deploy_create), so the use needs no id and reads no data. Show it
with `if="!items.any"` on the <use>, next to the list it
replaces. -->
<use template="k-empty" icon="◌" title="No deployments yet" text="Push a commit or create one by hand.">
<button id="deploy__create" class="k-btn primary" label="New deployment" on:click="deploy_create"/>
</use>
</col>
</screen>
</tui>log panelk-log
- takes
- with="PATH as l" reads l.title and l.lines[] {n, text, debug, info, warn, err}; the host appends lines and writes the title
- actions
- log_append (the host's key)
- keys
- j and k scroll, g top, G follow
- needs
- k-hints
Template: k-log in kit.tui
<!-- k-log: a scrolling log that follows its end. Props: style.
with="PATH as l": l.title and l.lines, an array of {n, text, debug,
info, warn, err}. Its scroll is U__view. -->
<template id="k-log" props="style">
<scroll id="view" class="k-log" stick="bottom" focusable="true" title="{l.title}" style="{$style}">
<col class="k-log-lines" each="l.lines as line" key="line.n">
<text class="k-log-line" class:muted="line.debug" class:info="line.info" class:warn="line.warn" class:danger="line.err">{line.text}</text>
</col>
</scroll>
</template>In use: components/log.tui
<!-- k-log · Contract: with="PATH as l" reads l.title and l.lines[] {n, text, debug, info, warn, err}; the host appends lines and writes the title · Actions: log_append (the host's key) · Keys: j and k scroll, g top, G follow · Requires: k-hints -->
<tui theme="auto">
<include src="../kit.tui"/>
<!-- The log's scroll is log__view (the use's id, then the template's
`view`): a keymap names it to give it keys. -->
<keymap when="#log__view">
<bind keys="j" action="move-next" keycap="j/k" label="scroll"/>
<bind keys="k" action="move-prev"/>
<bind keys="G" action="move-last" label="follow"/>
<bind keys="g" action="move-first" label="top"/>
</keymap>
<screen id="demo" focus="#log__view">
<col width="1fr" height="1fr" gap="0">
<!-- USE: the k-log template is a focusable scroll with
`stick="bottom"`: it follows the end of its content as lines are
appended, until you scroll up to read; `move-last` (or scrolling
to the end) makes it follow again. Each line is colored by its
flags (debug, info, warn, err): every line carries all four,
`false` for the ones it is not. The host appends lines to the
array and writes the title (see examples/kit-gallery). -->
<use id="log" template="k-log" with="log as l"/>
<hints class="k-hints"/>
</col>
</screen>
</tui>