Skip to content
KaaS-teamPublic

About

KaaS ui

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

KaaS UI

The KaaS design system. One set of tokens, one stylesheet and one set of server-rendered components, shared by every KaaS product so a page in factory looks like a page in qa, dx or kaasbot.

It ships as two packages from this repo:

  • The Go module github.com/KaaS-team/ui: the CSS embedded and served at /_ui/, the html/template partials, a catalogue page and a terminal theme.
  • The npm package @kaas-team/ui: the CSS only, for front ends that are not Go.

Tokens

Every value the system uses is a CSS custom property named --ui-*, written once in css/tokens.css. Nothing else in the repo writes a colour; it reads a token with var(--ui-*).

Group Tokens Dark values
colour --ui-bg, --ui-surface, --ui-raised, --ui-hover, --ui-border, --ui-border-strong, --ui-text, --ui-muted, --ui-accent, --ui-accent-hover, --ui-on-accent, --ui-focus yes
status --ui-pass, --ui-wait, --ui-fail, --ui-info, each with a -bg pair yes
space --ui-space-1 up to --ui-space-8 no
radius --ui-radius-sm, --ui-radius-md, --ui-radius-lg, --ui-radius-pill no
type --ui-type-xs up to --ui-type-2xl, --ui-leading no
font --ui-font-sans, --ui-font-mono no
shadow --ui-shadow-sm, --ui-shadow-md, --ui-ring yes
motion --ui-ease, --ui-dur-quick, --ui-dur-gentle no

tokens.json lists the same names by group. It holds no values: it is the contract the tests and the terminal theme check against.

The theme is light by default and dark under prefers-color-scheme: dark. Setting data-theme="light" or data-theme="dark" on <html> forces one.

Components

css/ui.css imports tokens.css, then base.css, then one layer per component family: shell, table, controls, chip, log and timeline.

The Go module renders each component from a partial in templates/. Every partial takes one data struct from data.go:

Partial Data What it draws
head ui.Head the <head> of every page, linking /_ui/ui.css
shell ui.Shell a whole page: the nav rail beside the main column
nav ui.Nav the product name and its links
chip ui.Chip a status label
table ui.Table a data table, with empty, loading and error states
empty ui.Empty what a list says when it has nothing yet, and the action that fills it
log ui.Log run output as an ARIA log region
attention ui.Attention an item that needs a person, with what they can do about it
approval ui.Approval a decision a person approves or rejects with a POST
timeline ui.Timeline events in order, each with a status
form ui.Form labelled fields with errors and hints
button ui.Button a button or a link styled as one
stat ui.Stat one number with its label and an optional change

The status a chip, stat, log line or timeline event carries is a ui.Status: pass, wait, fail, info, or empty for neutral.

The catalogue at /_ui/catalogue renders every partial in every state it has. Run it locally with:

go run ./cmd/catalogue -addr 127.0.0.1:8080

Using it from Go (factory, dx, kaasbot)

Add the module, mount the CSS and clone the partials before parsing your own pages:

import "github.com/KaaS-team/ui"

mux.Handle(ui.Prefix, ui.Handler()) // serves /_ui/ui.css and the layers

t := template.Must(ui.Partials.Clone())
template.Must(t.ParseFS(pages, "*.tmpl"))

A page template then calls the partials by name, for example {{template "shell" .}} with a ui.Shell. Mount ui.Catalogue() at ui.CataloguePath as well to get the catalogue inside your own server.

Terminal UIs read the same colour and status tokens through github.com/KaaS-team/ui/term:

style := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor(term.Default.Text))
fg, bg := term.Default.Status(ui.StatusFail)

Using it from the browser (qa)

The QA dashboard takes the CSS only. Depend on the package from this repo and import the stylesheet once:

@import '@kaas-team/ui';            /* css/ui.css: tokens and every layer */
@import '@kaas-team/ui/tokens.css'; /* or only the tokens */

@kaas-team/ui/tokens.json is exported too, for tooling that needs the token names. The package has no runtime dependencies.

Checks

just check is the gate, and CI runs it on every push to main and every pull request. It must end with zero errors and zero warnings.

Step What it checks
fmt, vet, test Go formatting, vet, and the partials, catalogue and terminal theme tests
tokens tokens.css and tokens.json agree, dark groups are redefined, no raw colour outside tokens.css, contrast holds
prose house prose rules on every Markdown file
audit .agents/repo.json maps every tracked file to the checks it reaches, and the push hook matches the kit
axe axe-core finds no violation on the catalogue, light and dark, 1280 and 390 wide, and no view scrolls sideways
shots full-page screenshots of the catalogue in the same views match catalogue/baseline/, and no view scrolls sideways

Glyphs rasterise differently from machine to machine, so the screenshot step draws text transparent and marks each run of text with a solid bar in its own colour. Fonts are pinned to DejaVu Sans and DejaVu Sans Mono 2.37, taken from catalogue/fonts/ rather than from the machine, so the check needs no installed font (macOS ships no DejaVu) and line breaks match. On Linux they reach Chromium through fontconfig, so they get the same hinting as installed fonts; elsewhere they load as web fonts. Layout and every colour token, text colours included, still land in the images. A change that moves pixels fails shots until the baselines are rewritten with just shots-update. Commit the new images with the change that moved them, so the review shows both. When it fails it prints a folder holding the actual image and a diff with changed pixels in red.

Licence

Apache-2.0. See LICENSE and THIRD_PARTY_NOTICES.md.

About

KaaS ui

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages