gui

package module
v0.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Waarp GUI kit

Shared web UI kit of the Waarp products: the design tokens and CSS primitives of the Waarp chart, native JavaScript helpers, fonts, an icon sprite, and the templ components of the common page shell and of the widgets. Embedded Go module; its only runtime dependency is templ (since 0.6.0: the components are typed Go code generated from .templ sources).

import gui "code.waarp.fr/lib/gui"

Chart version: Waarp graphic chart 2026, application system. Kit version: see CHANGELOG.md; products pin a tag, never a commit nor a replace directive, and pin the same templ version as the kit (go.mod).

Contents

Path What it is
static/tokens.css Design tokens (--...) and @font-face of the self-hosted fonts. Single source of truth for every colour, radius, shadow, spacing and type size.
static/kit.css Base styles and w-* primitives. Never copied into a product: served by the module.
static/kit.js Progressive helpers: sidebar toggle and groups (their choices in the cookies w-nav and w-nav-groups, that the server renders), tabs, notifications (server-rendered and scripted), row actions popover, pager, filters applied on change (form[data-autosubmit]), the clear button of a search field (label.w-search wrapped in a span.w-search-box, a button.w-search__clear beside it, named by the shell's <meta name="w-search-clear">), blocks shown by a choice (select[data-switch] / [data-case]), dual lists (select[multiple][data-dual]), action page buttons, row selection for a grouped action (form.w-selection, input[data-select-row], input[data-select-page]), tree tables (table.w-tree, folded and unfolded by their toggles, [data-tree-expand] and [data-tree-collapse], the folding chosen in the page kept through a replacement). Everything a replaced part may hold (tabs included since 0.31.1) is armed by window.wEnhance(element), that live.js calls on each part it puts in place.
static/editor.css, static/editor.js The rich text field and the variables list, loaded only by the pages that use them (gui.EditorAssets() in Page.Head).
static/editor-frame.css The style of the document of the frame of the rich text field (0.34.0). editor.js links it from the frame, at the address of the tokens.css link of the page (same directory), so that a product that serves the kit under a prefix has nothing to configure; the kit writes no stylesheet in a document, and the field suits a content security policy that refuses them (default-src 'self').
static/live.js The live list: a list refreshed in place, in parts read in parallel, loaded only by the pages that use it (gui.LiveAssets() in Page.Head); since 0.16.0, its filters form (data-live-filter) is applied in place too, data-live-period="0" is a list read on the user's actions only, and the parts a user's action brings fade in (view transition); since 0.31.1 the fragment of the address (#tab) survives a navigation in place; since 0.33.0, a reading the user asked for that is answered by a redirection reloads the page, so that the browser follows it (a session that ended leads to the sign-in page), while the readings the page asks for itself (its period, the return of the tab, the pending parts of a frame) keep the banner, and a link followed in place brings the fields of its filters form (form[data-live-filter]) in step with the parameters of the new address, so that the action of the empty state of a search, which clears it, empties the search field too.
static/combobox.css, static/combobox.js The list to type in: one choice among many, found by typing, each with its label, its code and what it does, loaded only by the pages that use it (gui.ComboboxAssets() in Page.Head).
static/leave.js The warning before a changed form[method="post"] is left, loaded by the shell on every page: the dialog of the kit (gui.LeaveDialog, #w-leave) for a link of the page or another form, the leave dialog of the browser for closing the tab, going back or reloading; data-leave on a link, data-noguard on a form.
static/check.js The typed fields: the message of a value that does not fit, as soon as the user leaves the field (gui.CheckAssets() in Page.Head).
static/sortable.css, static/sortable.js The ordered list: items moved by their grip, dragged or with the arrows, then the new order posted, loaded only by the pages that use it (gui.SortableAssets() in Page.Head).
static/favicon.svg, static/favicon.ico The Waarp pictogram (the W and its antennas) of the graphic chart, declared by Shell as the icon of every page in the browser tab.
static/icons.svg Icon sprite (<use href=".../icons.svg#name">). Substitute line icons until the Font Awesome sprite.
static/fonts/ Lato 400/700/900 and Comfortaa (woff2, latin).
static/waarp-logo-white.svg, static/waarp-banner.png Waarp banner for the light sidebar foot, with the version; the header carries the product name alone. The white logo stays available for a dark surface such as a sign-in page.
layout.templ Shell, Plain (a page outside a session, since 0.19.0), Header, Sidebar, Crumbs, CrumbsRow (the breadcrumb line with the return link to the page of origin, Page.Return, since 0.30.0), AboutDialog, AboutBody, LeaveDialog.
components.templ StatusOf, Tile, Banner, Empty, Pager, Actions, Th, NoticeOf, FiltersFoot, Dual, Tags, File, Password, FormActions, LinkCard, RichText, VarList, EditorAssets, LiveAssets, SortableAssets, SortableBar, SortableGrip, Combobox, ComboboxAssets, CheckAssets, SkeletonRows; Icon lives in gui.go; Chart in chart.templ, its props and geometry in chart.go; Selection, SelectHead, SelectCell in selection.templ, their props and ParseSelection in selection.go; TreeCell in tree.templ, its props, TreeRow and TreeRowAttrs in tree.go.
*_templ.go The Go code generated from the .templ sources, committed so that go build needs no tool; the CI checks that it matches the sources.
i18n/fr.yaml, i18n/en.yaml Strings used by the kit components, one file per language with the same key tree (parity checked by the tests), to merge into the product catalogue of that language.
tools/ Quality gates run by the CI: contrast report, visual regression of the showcase, DOM comparison of two renderings.
cmd/vitrine/ Showcase: renders every component in every state with sample data (reference of the visual regression).

Using the kit in a product

// Serve the static files under <base>/static/gui/.
r.PathPrefix("/static/gui/").Handler(http.StripPrefix(base+"/static/gui/", http.FileServerFS(gui.Static)))

// Per request: bind the translator of the language and the options of the product to the context, fill the
// chrome, render the shell around the component of the screen.
opts := gui.Options{BasePath: base, StaticPath: "/static/gui"}
page := gui.Page{Lang: lang, Title: t("services.title"), Product: productName /* ... */}
err := gui.Render(r.Context(), w, catalog.Translator(lang), opts, gui.Shell(page, services.Page(data)))

A screen is a templ component of the product (services.Page(data) above), written next to its handler with its typed data; it reads the translator and the options from the context through the helpers of the kit:

templ Page(d Data) {
	<div class="w-page-header">
		<div class="w-page-header__text">
			<h1 class="w-page-header__title">{ gui.T(ctx, "services.title") }</h1>
		</div>
		<div class="w-page-header__actions"><a class="w-btn w-btn--outline-dark" href={ templ.SafeURL(gui.URL(ctx, "/services")) }>@gui.Icon("rotate") { gui.T(ctx, "action.refresh") }</a></div>
	</div>
	@gui.StatusOf(gui.Status{State: "ok", Label: gui.T(ctx, "state.running")})
}

Generate the Go code of the components with the pinned tool, go tool templ generate (the kit and the product pin the same github.com/a-h/templ version; go tool templ fmt . formats the sources). Two rules of templ to know: a @Component() call directly followed by { opens its children block, so a label that follows an icon goes on the next line (@gui.Icon("plus") then { label } renders "icon label"); and a text immediately followed by @ is plain text, so write the text as an expression ({ "Label" }@mark()).

Rules that do not bend (see the design system): no colour, radius or shadow written in a product component, only tokens; no CDN; a status is a shape plus a label, never a colour alone; permissions are checked by the server, the component only hides; every action that needs input or confirmation is a page, never a modal.

Page contract

gui.Page carries the chrome: language, title, product and instance, user, navigation already filtered by the user rights, breadcrumb (every ancestor with a URL is a link), documentation and account links, notices, and the optional Head and Scripts components a screen adds to <head> and to the end of <body>. gui.Shell(page, body) renders the whole page around the component of the screen. Page.Wide (0.25.0) lets the content take the whole width of the main area, the gutters unchanged, for an operations screen with many columns or cards side by side; otherwise the content is bound to 1280 px. Page.NavState, read from the request by gui.NavStateOf(r), renders the sidebar in the state the user chose, that kit.js keeps in the cookie w-nav (Path=/, one year): the first frame of the page already shows the rail, nothing slides at a navigation; without a choice the stylesheet decides (full width, hidden under 1024 px). Page.NavClosed, read by gui.NavClosedOf(r), renders closed the groups the user folded, that kit.js keeps in the cookie w-nav-groups (their keys separated by |); the group of the current page and every group of the rail render open; nil leaves the choice to the script, as before. gui.Plain(page, body) renders a page outside a session (a sign-in page) with the same head and no chrome: the language switcher in the top right corner when Page.Languages is set, the component in the main landmark, the notifications; the showcase page connexion.html shows the composition (banner, w-plain__card, w-plain__title, w-plain__submit).

Components

Every component takes a typed value: its props struct (gui.TileProps…) or a value of the kit (gui.Status, gui.Notice). A field left at its zero value is simply absent from the markup, so a caller that fills the required fields only renders, whatever the kit adds later.

Component Props
gui.StatusOf(gui.Status) State (ok, ko, warn, off), Label; optional: Strong (the label alone, in bold and in the colour of its state, without the shape)
gui.Tile(gui.TileProps) Label, Value; optional: Code (the label as code: a path in the monospace font, not uppercased), Variant (ok, ko, warn, info), Total, SR (accessible sentence), Statuses ([]gui.Status), Foot (text) or Links ([]gui.Link, the foot as links: the tile is then a block whose main link stretches over it), Href, Controls and Selected (tile as a tab)
gui.TreeRowAttrs(gui.TreeRow) ID, Depth; optional: Parent (the id of the parent row, empty on a root), HasChildren (a node), Open (the initial state of a node). The attributes of a row of a tree table (table.w-table.w-table--one-line.w-tree[data-tree="<id>"]), spread on the tr (<tr { gui.TreeRowAttrs(r)... }>): its id, data-tree-id, data-tree-parent, data-depth, the --depth variable and the class w-tree__node. The server renders the whole tree and decides the state of every node at each render; kit.js folds and unfolds (click, Enter, Space, ArrowLeft, ArrowRight), [data-tree-expand="<id>"] and [data-tree-collapse="<id>"] (tree.expand_all, tree.collapse_all) act on the table they name; the folding the user chose is kept in the page, by data-tree then data-tree-id (never beyond the page), and taken back node by node when the table is replaced in place (a node without a choice keeps the state rendered, a node gone is forgotten); without JavaScript every row is visible
gui.TreeCell(gui.TreeCellProps) Row (gui.TreeRow), Label (the text of the node, relative to its parent); optional: Count (the figure after the label of a node, "81 dossiers"), Title (the tooltip of the cell: the whole path), Mono (the label in the monospace font). The first cell of a row of a tree table: the toggle of a node (aria-expanded, named tree.expand or tree.collapse with the label) or the placeholder of a leaf, the label (bold on a node), the count
gui.Banner(gui.BannerProps) Kind (ok, warn, ko), Title; optional: Icon, Text, Action (*gui.Link)
gui.Empty(gui.EmptyProps) Title; optional: Icon, Text, Action (*gui.Link)
gui.Pager(gui.PagerProps) Info, Page, Pages; optional: PrevURL, NextURL, Hidden (map of the current filters), Sizes and Size (rows-per-page choices and the current one)
gui.Actions(gui.ActionsProps) ID, Name, Items ([]gui.Action): one item renders an icon button, two or more a "⋯" popover menu; optional: Menu (the "⋯" menu for a single item too: the secondary actions of a page header)
gui.FormActions(gui.FormActionsProps) CancelURL; optional: Danger, Required, Title, NeedsNote (the submit button stays disabled, that sentence shown next to it, while a field marked Needed is empty). The "Cancel" link carries data-leave: leaving through it asks nothing
gui.Th(gui.ThProps) Label, Key, Sort, Dir, Base; optional: Num. Sortable column header (link + aria-sort), rendered by the server from ?sort=&dir=
gui.NoticeOf(gui.Notice) Kind (ok, ko, info), Title; optional: Text. Rendered by the shell from Page.Notices
gui.FiltersFoot(resetURL) "Apply filters" without JavaScript, "Reset" as a link
gui.Dual(gui.DualProps) ID, Name, Choices ([]gui.Choice, the chosen ones first); optional: Describe (id of the hint). Dual list with kit.js, plain multiple select without
gui.Tags(gui.TagsProps) ID, Name, Choices ([]gui.Choice, the chosen ones first, in order of preference); optional: Describe (id of the hint). With kit.js: the chosen values as numbered tags (each a button beside its Remove button, never around it; reordered by drag or by Alt + arrow, Delete removes) and a combobox that suggests the remaining ones (typing filters, arrow down browses, Enter adds, Backspace on an empty field removes the last tag); the hidden select is reordered to the order of the tags, so the form sends the preference order; the help on the gestures once per fieldset (or per form without one). Plain multiple select without JavaScript. Empty means everything is accepted: say it in the hint
gui.File(gui.FileProps) ID, Name; optional: Current (non-secret summary of what is in place), Accept, Required, Describe, Multiple (several files at once, named with their sizes), Needed with Paste (the content must come from the file or from that textarea before the form sends; see FormActionsProps.NeedsNote). File field that says its state; a multipart form read by the server
gui.Password(gui.PasswordProps) ID, Name; optional: Autocomplete (current-password, new-password), Describe, Required, Invalid. A password field with the button that shows or hides what is typed (aria-pressed, name and icon follow); kit.js enables the button, hidden without JavaScript. No value is ever rendered
gui.LinkCard(gui.LinkCardProps) Label, URL; optional: Icon, Text. A card that is a link, for a navigation page (the home page): the icon and the name of the screen side by side, a sentence under the name saying what it holds; stacked in a section card with w-stack
gui.Chart(gui.ChartProps) ID, Title, Desc, Labels, Series ([]gui.Serie: Label, Values; optional Kind ok or ko, Unit); optional: Names. A bar chart the server renders as SVG, no script, no library: the series stacked, the ko one hatched with its value written above the bar, grid and axis labels computed, a title per bar, role="img" with title and description, the legend under the chart; above twelve slots a narrow rendering (the slots grouped by two) replaces the wide one when the chart's box has less than 480 px (container query). The exact values belong to a table next to the chart: Desc says so
gui.Selection(gui.SelectionProps) ID, Objects (the plural name of the objects, "transferts"), Total (the objects matching the current filter, all pages), Actions ([]gui.SelectionAction{Label, Action, Get}); optional: Hidden (the current filters, as hidden fields). The bar of the rows selected for a grouped action, under the toolbar: a POST form the row checkboxes belong to (their form attribute), the live count, the checkbox that takes the whole filter, the actions as neutral buttons (each with its own address, Get for one that opens its confirmation page), "Deselect all". Sends ids= (the rows checked) or all=1 with except= (the whole filter minus the rows unchecked): gui.ParseSelection(r.Form) reads it as a gui.SelectionState. Without JavaScript the bar stays visible, the form sends the rows checked or the whole filter, and the bar says so (<noscript>); kit.js hides it until a row is checked, keeps the count, checks the page from the header checkbox, keeps the state through the refreshes of a live list and reads the total from an element marked data-select-total="<ID>" with data-total (the toolbar count, in a live part)
gui.SelectHead(form) The header cell of the selection column (w-table__select): the name of the column and the checkbox that checks or unchecks the rows of the page, enabled by kit.js. The table carries w-table--select
gui.SelectCell(gui.SelectCellProps) Form, Value, Name (the object, as the accessible name says it: "le transfert 1042"); optional: Checked. The checkbox of a row, the whole cell being its label
gui.RichText(gui.RichTextProps) ID, Name; optional: Value (HTML), Describe, Vars (id of a VarList), Required, Invalid. With editor.js: visual editing in a frame isolated by sandbox, a toolbar (bold, italic, underline, heading, paragraph, lists, link, table (rows, columns, heading row, inline styles without colour for mail clients, a bar of cell tools, Tab between cells), clear formatting, "HTML source"), markers shown as tags, paste reduced to the structure of the text; the hidden textarea carries the value. The textarea of the HTML source without JavaScript. The page loads gui.EditorAssets()
gui.VarList(gui.VarListProps) ID, Groups ([]gui.VarGroup: Label, Vars []gui.Var{Name, Label, Param, Tokens}). JSON data offered in every field whose data-vars names it: # opens the list at the caret, typing filters, Enter or Tab inserts #Name#, a parameter is selected and its tokens offered; a "Variables" button opens it too. Plain fields without JavaScript
gui.EditorAssets() The editor.css and editor.js links, for Page.Head
gui.LiveAssets() The live.js link, for Page.Head of a live list (see "Live list" in the CHANGELOG of 0.13.0)
gui.SortableAssets() The sortable.css and sortable.js links and the texts of the announcements, for Page.Head of an ordered list (see "Ordered list" in the CHANGELOG of 0.14.0)
gui.SortableBar(gui.SortableBarProps) ID (named by the data-sortable of the list and the form attribute of the inputs of the items), Action. The bar of the order not yet saved: "Cancel", then the submit button; its children go into the form. Hidden until the order changes
gui.Combobox(gui.ComboboxProps) ID, Name, Groups ([]gui.ComboGroup: Label, Choices []gui.ComboChoice{Value, Label, Code, Text, Selected}); optional: Placeholder, Required, Invalid, Describe, Switch, Into and Suffix (the choice written on a new line of a multi-line field, which stays editable), CodeFirst (the code of a choice before its label, in the list and in the field, for a list known by its codes). With combobox.js: a field to type in and the list of the choices by group (label in bold, code, text; the code first with CodeFirst); without, the select. The page loads gui.ComboboxAssets()
gui.Check CheckEmail, CheckEmails, CheckDuration, CheckOctal: Valid(value) on the server, Attributes(ctx) on the input ({ c.Attributes(ctx)... }), Message(ctx); the page loads gui.CheckAssets()
gui.SortableGrip(name) The grip of an item of an ordered list, named after its item; hidden without JavaScript
gui.SkeletonRows(gui.SkeletonRowsProps) Rows, Cols: the rows of a table whose content is still read
gui.Icon(name, classes...) An icon of the sprite, decorative (aria-hidden), with the class i and the given classes
gui.AboutBody(page) the gui.Page (Product, About): one definition list in sections (w-about), the labels on one shared column: the build (version, date, revision); the support sentence after the editor's name and the licence; the useful links, each with its Icon when set. A section without content is not rendered. Rendered by the shell inside the AboutDialog when Page.About is set (the "About" entry of the account menu opens it with kit.js); a product renders it again on its "About" page, the fallback the entry links to without JavaScript (Page.AboutURL)

Helpers of the context: gui.T(ctx, key, args...) translates with the bound translator (and returns the key without one), gui.URL(ctx, path) and gui.StaticURL(ctx, path) build the addresses of the product, gui.Query(base, kv...) appends query parameters. No prop takes raw HTML: a component that needs a nested element takes a value (gui.Status, gui.Link) and renders it itself, so that user data is always escaped.

Two patterns are plain markup, styled and remembered by kit.js:

<!-- foldable section: open by default, state remembered per data-key, summary of the group in the header -->
<details class="w-fold" data-key="local-servers" open>
	<summary>@gui.Icon("chevron-right")<h2 class="w-fold__title">Local servers</h2>
		<span class="w-fold__meta"><span>4 / 6 running</span>@gui.StatusOf(gui.Status{State: "ko", Label: "1 in error"})</span></summary>
	... table ...
</details>

<!-- foldable card, for the secondary blocks of a long form: the server opens it when it holds a value or an
     error (no browser memory: nothing filled is ever hidden), the summary says the gist of the folded content -->
<details class="w-card w-card--fold" open>
	<summary>@gui.Icon("chevron-right")<span class="w-card__title">Local address</span><span class="w-fold__meta">10.20.30.40:6000</span></summary>
	<div class="w-card__body"> ... fields ... </div>
</details>

The sidebar collapses to a rail of icons with the button of the header (since 0.17.0: the groups open, each entry reduced to its icon with its label as a tooltip and kept for assistive technologies, the foot hidden; since 0.24.0 the icons measure --rail-icon, 20 px, and the tooltip opens beside them) (aria-expanded, state remembered, animated, collapsed by default under 1024 px). Icons are functional only: never in front of a title, never in a text button except "+" to add and "←" to go back; the first column of a table is named after the object, never "Name".

Sobriety is the rule: a reading screen shows its data and its actions, nothing that accompanies them without serving. When groups are alternatives, gui.Tile with Controls turns the tiles into tabs: each tile carries the count and statuses of its group and shows its table, one at a time (?group= is the server fallback, the hash keeps the selection). Beyond 10 rows a table gets the gui.Pager foot (10 rows per page by default).

Quality gates

go tool templ generate && git diff --exit-code -- '*_templ.go' && go tool templ fmt -fail .   # generated code matches the sources
go vet ./... && go test ./...        # files, budgets (kit.css <= 66 KB, kit.js <= 48 KB, editor.css <= 6 KB, editor.js <= 36 KB, fonts <= 30 KB), forbidden patterns, rendering
python tools/contrast.py             # WCAG contrast of every pair in use; exits 1 below the thresholds
go run ./cmd/vitrine -out build/vitrine && python tools/visual.py   # DOM checks and captures of the showcase
python tools/domdiff.py <reference> build/vitrine                    # two renderings of the showcase, compared as DOM trees
go run ./cmd/vitrine -serve 127.0.0.1:8091 & python tools/scenarios.py   # the served showcase driven in Chromium: the kit's scripts against a server; stop the server afterwards

The CI runs them on every push. The scenarios job plays tools/scenarios.py against the binary the showcase job builds: what a capture cannot check, the live list meeting a session that ends or a reading that fails, and, under the content security policy the served showcase sends on every answer, the frame of the rich text field styled by the linked editor-frame.css; a refusal the browser reports fails the scenario. The visual job compares the captures of the showcase with the baseline, that is the captures of the last successful job on the default branch, made by the same image and the same renderer: a difference above the tolerance fails a merge request pipeline, and the merged change becomes the new baseline. Animations are frozen before each capture (finite ones at their end, infinite ones cancelled): a capture never depends on the phase of a movement. Captures depend on the machine (fonts, anti-aliasing), so no reference image is versioned: locally, python tools/visual.py --update keeps your own references in vitrine/reference/ (ignored by git). tools/domdiff.py proved the 0.6.0 switch to templ: the showcase of 0.5.0 and the one of 0.6.0 give the same DOM on every page, whitespace between inline elements included.

Governance

The chart specifies, the kit implements, the products consume. A new component is specified in the chart, then added here with its showcase state and its contrast pairs, then used by a product. The four ihm-waarp-* skills of the Waarp workstation describe the method, the architecture, the design system and the glossary.

License: MIT (see LICENSE).

Documentation

Overview

templ: version: v0.3.1070

templ: version: v0.3.1070

Package gui is the shared web UI kit of the Waarp products: the design tokens and the stylesheet, the behaviours (kit.js), the icons, the fonts, the common translations and the templ components of the chrome (shell, header, sidebar, breadcrumb, "About") and of the widgets (status, tile, banner, pager, actions...). A product embeds it, serves Static under its own prefix and renders Shell around the component of a screen.

Since 0.6.0 the components are templ components: typed parameters, compile-time checks, the same HTML as the html/template fragments of 0.5.0. The translator and the options of the product travel in the context (Bind), so that a component never needs them as parameters.

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

Index

Constants

View Source
const NavCookie = "w-nav"

NavCookie carries the choice: "1" for the rail, "0" for the full width.

View Source
const NavGroupsCookie = "w-nav-groups"

NavGroupsCookie carries the keys of the sidebar groups the user closed (0.23.0), separated by "|"; kit.js writes it when a group is opened or closed. The shell renders those groups closed, so that the first frame of a page is right: applied by a script once the page was painted, the state folded the groups under the eyes of the user at each navigation.

Variables

View Source
var I18n = mustSub(i18nFS, "i18n")

I18n holds the common catalogues, one YAML file per language (fr.yaml, en.yaml), same keys in the same order; a product merges the file of the current language into its own catalogue.

View Source
var Languages = []string{"fr", "en"}

Languages the kit translates.

View Source
var Sprite = string(mustRead(staticFS, "static/icons.svg"))

Sprite is the inline SVG sprite of the icons, inlined by Shell unless Options.ExternalIcons is set.

View Source
var Static = mustSub(staticFS, "static")

Static holds tokens.css, kit.css, kit.js, icons.svg, the logos and the fonts, to serve under the product's static prefix.

Functions

func AboutBody added in v0.6.0

func AboutBody(page Page) templ.Component

AboutBody: the build of the product (version, date, revision), the support sentence after the editor's name linked to its site, the licence sentence, the useful links (new tab, marked as external). Since 0.7.0 (20/10/2026): one definition list in sections (build; support and licence; links) whose labels share one column; a section without content is not rendered.

func AboutDialog added in v0.6.0

func AboutDialog(page Page) templ.Component

About: the "About" dialog of the account menu, rendered by the shell when Page.About is set and opened by the entry of the menu (data-dialog, kit.js). Native <dialog>: closed by the cross, "Close", Escape or the backdrop. Its content, AboutBody, is shared with the "About" page a product serves as the fallback without JavaScript (Page.AboutURL).

func Actions added in v0.6.0

func Actions(p ActionsProps) templ.Component

Actions: the actions of a row (see ActionsProps).

func Banner(p BannerProps) templ.Component

Banner: persistent message (see BannerProps).

func Bind added in v0.6.0

func Bind(ctx context.Context, tr Translator, opts Options) context.Context

Bind returns a context carrying the translator of the request and the options of the product: the components read both from the context (T, URL, StaticURL, Icon), a product binds them once per request before rendering.

func Chart added in v0.20.0

func Chart(p ChartProps) templ.Component

Chart: a bar chart rendered as SVG (see ChartProps): in a box that is a size container, the wide rendering and, above twelve slots, the narrow one the stylesheet shows in its place under 480 px of box; then the legend, one entry per series (swatch and label). With groups, a dashed line at each boundary and the label of each group under the axis (0.28.0).

func CheckAssets added in v0.14.0

func CheckAssets() templ.Component

CheckAssets: the script of the typed fields (check.js, see Check), for the Page.Head of the pages that use them; the other pages do not load it. Since 0.14.0.

func Combobox added in v0.14.0

func Combobox(p ComboboxProps) templ.Component

Combobox: one choice among many that the user finds by typing (see ComboboxProps): a select, which combobox.js turns into a field to type in and the list of the choices by group, each with its label in bold, its code (first, with CodeFirst) and what it does; without JavaScript, the select itself. Since 0.14.0.

func ComboboxAssets added in v0.14.0

func ComboboxAssets() templ.Component

ComboboxAssets: the stylesheet and the script of the Combobox (combobox.css, combobox.js), for the Page.Head of the pages that use it. Since 0.14.0.

func Crumbs added in v0.6.0

func Crumbs(crumbs []Crumb) templ.Component

Crumbs: breadcrumb. Every ancestor with a URL is a link (an action page always leads back to its list); the last item is the current page, not clickable.

func CrumbsRow added in v0.30.0

func CrumbsRow(crumbs []Crumb, ret *Link) templ.Component

CrumbsRow (0.30.0): the breadcrumb line, with the return link to the page of origin at its right end when the product gives one. The link is not an item of the breadcrumb list: it says where the user comes from, the list says where the page sits. Under 1024 px the link wraps under the list, still to the right; kit.js measures the height of the line (--crumbs-h) for the sticky page header.

func Dual added in v0.6.0

func Dual(p DualProps) templ.Component

Dual: dual list (see DualProps). Without JavaScript it stays a plain multiple select.

func EditorAssets added in v0.9.0

func EditorAssets() templ.Component

EditorAssets: the stylesheet and the script of RichText and VarList, for the Page.Head of the pages that use them; the other pages do not load them. Since 0.9.0.

func Empty added in v0.6.0

func Empty(p EmptyProps) templ.Component

Empty: empty state (see EmptyProps).

func File added in v0.6.0

func File(p FileProps) templ.Component

File: file field that says its state (see FileProps). Without JavaScript: the native field alone.

func FiltersFoot added in v0.6.0

func FiltersFoot(resetURL string) templ.Component

FiltersFoot: foot of a filters panel (a filter applies as soon as it changes, kit.js). Without JavaScript an "Apply filters" button appears; "Reset" is a link to the bare list.

func FormActions added in v0.6.0

func FormActions(p FormActionsProps) templ.Component

FormActions: foot of an action page (see FormActionsProps).

func Header(page Page) templ.Component

Header: orange 72 px header (since 0.6.1; dark before). Identity (the product name alone: the Waarp banner stands at the sidebar foot), instance and environment, language switcher, documentation, account menu.

func Health added in v0.28.0

func Health(p HealthProps) templ.Component

Health: the health strip of a node (see HealthProps): a cell per figure, a link when it leads somewhere, its state as a status (shape and word).

func Icon added in v0.6.0

func Icon(name string, classes ...string) templ.Component

Icon renders an icon of the sprite (see Options.IconHTML).

func IconsURL added in v0.6.0

func IconsURL(ctx context.Context) string

IconsURL is the URL of the sprite when the icons are external, else "".

func LeaveDialog added in v0.15.0

func LeaveDialog() templ.Component

LeaveDialog: the dialog leave.js opens before a changed form is left by a link of the page or another form: "Stay on the page" (focused, closes it) and "Leave without saving". Rendered on every page, closed.

func LinkCard added in v0.6.0

func LinkCard(p LinkCardProps) templ.Component

LinkCard: a card that is a link (see LinkCardProps).

func LiveAssets added in v0.13.0

func LiveAssets() templ.Component

LiveAssets: the script of the live list (live.js), for the Page.Head of the pages that use it; the other pages do not load it. The list declares its parts with data attributes: data-live on the list (data-live-period, the seconds between two refreshes), data-live-part="name" and an id on every element of a part, data-live-paged on the parts that change with the page, data-live-pending on the parts rendered empty (read at once), data-live-status, data-live-hold, data-live-refresh, data-live-carry and a template data-live-error. Since 0.13.0.

func NavClosedOf(r *http.Request) []string

NavClosedOf reads the keys from the request. No cookie gives an empty, non-nil slice: the choice is known, nothing is closed; a nil Page.NavClosed means the page is rendered without the choice and leaves it to the script. A key is a word of letters, digits, "-" and "_"; anything else is dropped.

func NoticeOf added in v0.6.0

func NoticeOf(n Notice) templ.Component

NoticeOf: notification rendered by the server, the result of the previous action (Post/Redirect/Get). "ko" is an alert that stays until closed, the others close after five seconds (kit.js).

func Pager added in v0.6.0

func Pager(p PagerProps) templ.Component

Pager: list foot (see PagerProps).

func Password added in v0.19.0

func Password(p PasswordProps) templ.Component

Password: a password field with its show-or-hide button (see PasswordProps). The button says what it does (aria-label and title), its state (aria-pressed) and carries both labels for kit.js, which swaps them with the icon.

func Plain added in v0.19.0

func Plain(page Page, body templ.Component) templ.Component

Plain (0.19.0): the complete page of a screen outside a session, the sign-in page first: the same <head> as Shell (without leave.js), no header, no sidebar, no breadcrumb and no skip link (nothing to skip: the focus starts in the first field of the screen); the language switcher of the header in the top right corner when Page.Languages is set; the component of the screen in the main landmark; the notifications region; Page.Scripts. The title is "<screen> · <product>": Page.Instance is not known before a session.

func Query added in v0.6.0

func Query(base string, kv ...any) string

Query appends name/value pairs to a URL or a query string: Query("?group=servers", "sort", "name", "dir", "asc") gives "?group=servers&sort=name&dir=asc", Query("/servers", "sort", "name") gives "/servers?sort=name"; an empty base starts with "?". Values are URL-escaped.

func Render added in v0.6.0

func Render(ctx context.Context, w io.Writer, tr Translator, opts Options, c templ.Component) error

Render writes a component with the translator and the options bound.

func RichText added in v0.9.0

func RichText(p RichTextProps) templ.Component

RichText: the field of an HTML text (see RichTextProps). Without JavaScript: the textarea of the HTML source.

func SelectCell added in v0.21.0

func SelectCell(p SelectCellProps) templ.Component

SelectCell: the checkbox of a row (see SelectCellProps), in a cell the whole of which is its label. Since 0.21.0.

func SelectHead added in v0.21.0

func SelectHead(form string) templ.Component

SelectHead: the header cell of the selection column (see Selection): the name of the column for assistive technologies and the checkbox that checks or unchecks the rows of the page, enabled by kit.js (hidden without JavaScript). The argument is the id of the Selection. Since 0.21.0.

func Selection added in v0.21.0

func Selection(p SelectionProps) templ.Component

Selection: the bar of the rows selected for a grouped action (see SelectionProps). A form the row checkboxes (SelectCell) belong to through their form attribute: the current filters as hidden fields, the live count (filled and shown by kit.js), the checkbox that takes the whole filter, the actions as neutral buttons, each sending the form to its own address, and "Deselect all". Without JavaScript the bar stays visible and the form sends the rows checked (ids) or the whole filter (all=1), and says so (noscript); kit.js hides the bar until a row is checked, keeps the count and the total, checks the page from the header checkbox and, once the whole filter is taken, sends the rows unchecked as exceptions (except). ParseSelection reads what the form sends. Since 0.21.0.

func Shell added in v0.6.0

func Shell(page Page, body templ.Component) templ.Component

Shell: the complete page. A product renders it with the Page of the chrome and the component of its screen; Page.Head and Page.Scripts complete the <head> and the end of <body>.

func Sidebar(page Page) templ.Component

Sidebar: white 280 px sidebar, collapsible groups (the ones the user closed come from Page.NavClosed, kit.js keeps the choice in a cookie), active entry as a pill. Page.Nav is already filtered by the user rights: the server never relies on the template for a permission.

func SkeletonRows added in v0.13.0

func SkeletonRows(p SkeletonRowsProps) templ.Component

SkeletonRows: the rows of a table whose content is still read, as many cells as the table has columns (see SkeletonRowsProps). Since 0.13.0.

func SortableAssets added in v0.14.0

func SortableAssets() templ.Component

SortableAssets: the stylesheet, the texts and the script of the ordered list (sortable.css, sortable.js), for the Page.Head of the pages that use it; the other pages do not load them. The list is an ol.w-sortable whose data-sortable names the id of its SortableBar; every item, an li.w-sortable__item with data-sortable-name, holds a SortableGrip, may hold an element with data-sortable-rank (numbered again on every move) and carries the hidden inputs the bar posts (form="<bar id>"), in the order of the list. Since 0.14.0.

func SortableBar added in v0.14.0

func SortableBar(p SortableBarProps) templ.Component

SortableBar: the bar of an ordered list (see SortableBarProps), shown by sortable.js once the order differs from the one rendered: "Cancel" puts the rendered order back, the submit button posts the new order. Its children go into the form (hidden fields). Hidden without JavaScript. Since 0.14.0.

func SortableGrip added in v0.14.0

func SortableGrip(name string) templ.Component

SortableGrip: the grip of an item of an ordered list, named after its item (the name the announcements of the moves read in data-sortable-name); hidden until sortable.js runs. Since 0.14.0.

func StaticURL added in v0.6.0

func StaticURL(ctx context.Context, path string) string

StaticURL is a static file of the kit, under the static prefix.

func StatusOf added in v0.6.0

func StatusOf(s Status) templ.Component

StatusOf: shape + colour + label, never colour alone.

func T added in v0.6.0

func T(ctx context.Context, key string, args ...any) string

T translates a key with the translator of the context; without one, it returns the key itself (the behaviour of the "t" placeholder of 0.5.0).

func Tags added in v0.8.0

func Tags(p TagsProps) templ.Component

Tags: an ordered multiple choice as tags with suggestions (see TagsProps). Without JavaScript: a multiple select.

func Th added in v0.6.0

func Th(p ThProps) templ.Component

Th: sortable column header (see ThProps).

func Tile added in v0.6.0

func Tile(p TileProps) templ.Component

Tile: key figure (see TileProps). No icon: the label and the border say it.

func TreeCell added in v0.31.0

func TreeCell(p TreeCellProps) templ.Component

TreeCell: the first cell of a row of a tree table (see TreeCellProps), indented by the depth of its row: on a node, the toggle (a 24 px icon button, aria-expanded in the initial state the server decides, its name "Expand <label>" or "Collapse <label>", kit.js swapping them); on a leaf, a placeholder of the same width; then the label (bold on a node, monospace with Mono) and, on a node, the count. The tooltip of the cell is its Title (the whole path). Without JavaScript the toggle is inert and every row is visible. Since 0.31.0.

func TreeRowAttrs added in v0.31.0

func TreeRowAttrs(r TreeRow) templ.Attributes

TreeRowAttrs returns the attributes of the `tr` of a row of a tree table, spread on the element (`<tr { gui.TreeRowAttrs(r)... }>`): its id, `data-tree-id`, `data-tree-parent` (on a child), `data-depth` and the `--depth` variable the stylesheet indents by, and the class `w-tree__node` on a node.

func URL added in v0.6.0

func URL(ctx context.Context, path string) string

URL is a page of the product: the base path followed by the path.

func VarList added in v0.9.0

func VarList(p VarListProps) templ.Component

VarList: the variables of the text fields (see VarListProps), as data read by editor.js.

func WithOptions added in v0.6.0

func WithOptions(ctx context.Context, opts Options) context.Context

WithOptions returns a context carrying the options of the product.

func WithTranslator added in v0.6.0

func WithTranslator(ctx context.Context, tr Translator) context.Context

WithTranslator returns a context carrying the translator.

Types

type About added in v0.4.0

type About struct {
	Version   string // "0.17.0"
	Date      string // build date, as the product formats it; empty hides the row
	Revision  string // short commit; empty hides the row
	EditorURL string // the editor's site, linked from its name
	Support   string // the support sentence, after the editor's name ("fournit un support … pour <le produit>.")
	License   string // the licence sentence, as the product states it
	Links     []Link // useful links (downloads, documentation, forum, contact), opened in a new tab
}

About is the content of the "About" dialog and page: the build of the product and the useful links. Texts are already translated by the product.

type Action

type Action struct {
	Icon    string
	Label   string
	URL     string
	Action  string
	Command string
	Danger  bool
}

Action is one entry of the actions of a row (Actions): a link (URL), a POST form (Action) or, since 0.27.0, a button the product's script listens to (Command, set on the button as data-command; the menu closes after it like after the others), the destructive one marked Danger.

type ActionsProps added in v0.6.0

type ActionsProps struct {
	ID    string
	Name  string
	Items []Action
	Menu  bool
}

ActionsProps feeds Actions, the actions of a row: one action renders an icon button, two or more a round "⋯" button opening a native popover that lists them, the destructive one last after a separator. ID is unique in the page, Name is the row name for the accessible label. Menu (optional, 0.10.0) renders the "⋯" menu for a single action too: the secondary actions of a page header, next to its primary button. An entry run by a script (Action.Command, 0.27.0) is a plain button the product listens to; a row whose script adds it in place enhances it with wEnhance, which also places its menu.

type BannerProps added in v0.6.0

type BannerProps struct {
	Kind   string
	Title  string
	Icon   string
	Text   string
	Action *Link
}

BannerProps feeds Banner, a persistent message: the kind (ok, warn, ko; ko is an alert), the title, and the optional icon, text and action.

type ChartGroup added in v0.28.0

type ChartGroup struct {
	Label string
	Slots int
}

ChartGroup is a group of consecutive slots of a Chart (0.28.0): its Label, written under the axis, centred under its Slots. The groups are drawn when every one has slots and their slots sum up to the slots of the chart; otherwise they are ignored.

type ChartProps added in v0.20.0

type ChartProps struct {
	ID     string
	Title  string
	Desc   string
	Labels []string
	Names  []string
	Series []Serie
	Groups []ChartGroup
}

ChartProps feeds Chart (0.20.0): a bar chart the server renders as SVG, one bar per slot (the hours of a day, the days of a week), no script and no library. ID is unique in the page: the ids of the title, of the description and of the hatch pattern derive from it. Title names what the chart shows and Desc says where the exact values are (the table next to the chart): assistive technology reads both (role img). Labels are the axis labels of the slots ("17h"), one in two or three written when they are many; Names (optional) are the full names of the slots, in the title of their bars ("17:00"), Labels otherwise. Series are stacked from the bottom: the first plain, the second hatched with its value written above the bar, so that the colour never carries the information alone. Above twelve slots a narrow rendering is made too, the slots grouped by two, which the stylesheet shows in place of the wide one when the chart has less than 480 px (a container query on the box around the renderings: a half-width card on a small screen, a phone), so that the labels stay readable: the wide rendering is drawn for 600 px (12 px labels at that width, 9.8 px in a half-width card at 1440 px), the narrow one for 360 px. Groups (0.28.0, optional) split the slots in consecutive groups (the hours of yesterday, those of today): a dashed line at each boundary, the label of each group under the axis, and the pairs of the narrow rendering made within each group.

type Check added in v0.14.0

type Check string

Check is a kind of value a field checks (0.14.0): the same rule on the server (Valid) and in the page, where the field carries it as its type or its pattern and check.js shows its message as soon as the user leaves it (CheckAssets). The page only helps: the server keeps the last word.

const (
	// CheckEmail is an email address as the browsers check a field of type
	// email: a host name after "@" (letters, digits and hyphens, separated by
	// dots), where the syntax of the mail standard would admit "?" or "!".
	CheckEmail Check = "email"
	// CheckEmails is a list of such addresses, separated by commas.
	CheckEmails Check = "emails"
	// CheckDuration is a duration as Go writes it: 30s, 5m, 1h30m, 1.5h.
	CheckDuration Check = "duration"
	// CheckOctal is permissions in octal, three or four digits: 640, 0750.
	CheckOctal Check = "octal"
)

func (Check) Attributes added in v0.14.0

func (c Check) Attributes(ctx context.Context) templ.Attributes

Attributes are the attributes of the input of the field: its type or its pattern, the keyboard it opens, and the message check.js shows.

func (Check) Message added in v0.14.0

func (c Check) Message(ctx context.Context) string

Message is what a field says of a value that does not fit (check.<kind> in the catalogue of the kit).

func (Check) Valid added in v0.14.0

func (c Check) Valid(value string) bool

Valid says whether a value fits the check; an empty value does (whether a field is required is another check).

type Choice added in v0.6.0

type Choice struct {
	Value    string
	Label    string
	Selected bool
}

Choice is an option of a select: Dual lists the chosen ones first.

type ComboChoice added in v0.14.0

type ComboChoice struct {
	Value    string
	Label    string
	Code     string
	Text     string
	Selected bool
}

ComboChoice is a choice of a Combobox: its value, its label (in bold in the list), its code (beside, in monospace) and what it does (under it); the code and the text are optional.

type ComboGroup added in v0.14.0

type ComboGroup struct {
	Label   string
	Choices []ComboChoice
}

ComboGroup is a group of the choices of a Combobox; without label, a flat list.

type ComboboxProps added in v0.14.0

type ComboboxProps struct {
	ID          string
	Name        string
	Groups      []ComboGroup
	Placeholder string
	Required    bool
	Invalid     bool
	Describe    string
	Switch      string
	Into        string
	Suffix      string
	CodeFirst   bool
}

ComboboxProps feeds Combobox (0.14.0), one choice among many that the user finds by typing: ID, Name, Groups; optional: Placeholder (the empty choice of the list without JavaScript), Required, Invalid, Describe (the id of the hint), Switch (the data-switch of the blocks the choice shows).

Into (optional) is the id of a multi-line field where a choice is written on a new line, followed by Suffix ("=" for key=value lines), instead of being kept: the field stays editable, the choices already at the start of one of its lines are no longer offered, and the select has no name (it holds no value; Name is not used). Without JavaScript, the select lists the choices.

CodeFirst (optional, 0.24.2): the code of a choice comes before its label, in the list, in the field once a choice is made ("CODE · label") and in the select without JavaScript, for a list whose choices the users know by their code; the product sorts such a list by code.

type Crumb

type Crumb struct {
	Label string
	URL   string
}

Crumb is an item of the breadcrumb: every ancestor with a URL is a link, the last item is the current page.

type DualProps added in v0.6.0

type DualProps struct {
	ID       string
	Name     string
	Choices  []Choice
	Describe string
}

DualProps feeds Dual, a multiple select that kit.js turns into two lists, "Available" and "Chosen", with Add / Remove; empty means everything is accepted (say it in the hint). Describe is the id of the hint.

type EmptyProps added in v0.6.0

type EmptyProps struct {
	Title  string
	Icon   string
	Text   string
	Action *Link
}

EmptyProps feeds Empty, an empty state: the title names the absence, the optional text orients and the optional action leads to the creation.

type FileProps added in v0.6.0

type FileProps struct {
	ID       string
	Name     string
	Current  string
	Accept   string
	Describe string
	Required bool
	// Multiple (0.18.0): the field takes several files at once (a certificate
	// and its intermediates); the state names them all.
	Multiple bool
	// Needed (0.18.0): the content is needed before the form can be sent,
	// from this field or from the text field Paste (the id of a textarea
	// where the same content can be pasted). With FormActionsProps.NeedsNote
	// on the form, the submit button stays disabled while it is missing; a
	// browser cannot show a chosen file again, so the form never comes back
	// refused for that. Without JavaScript the server refuses as usual.
	Needed bool
	Paste  string
}

FileProps feeds File, a file field that says its state: what is already in place (Current, a non-secret summary), the native input, the chosen file (name and size, kit.js) and a Remove button.

type FormActionsProps added in v0.6.0

type FormActionsProps struct {
	CancelURL string
	Danger    bool
	Required  bool
	Title     string
	Label     string
	// NeedsNote (0.18.0): the sentence shown next to the buttons while a
	// field marked FileProps.Needed is empty; the submit button is then
	// disabled. Empty: the form sends whatever it holds.
	NeedsNote string
}

FormActionsProps feeds FormActions, the foot of an action page: "Cancel" then "Save", or "Cancel" then "Delete" with Danger; Required shows the mandatory-fields note; Title completes the accessible name of the button. Label (optional, 21/10/2026) replaces "Save" or "Delete" when the action is another verb ("Disable", "Revoke"); the title of the page then names that action.

type HealthItem added in v0.28.0

type HealthItem struct {
	Label string
	Value string
	Unit  string
	State string
	Text  string
	Title string
	Href  string
}

HealthItem is a cell of a Health strip. Required: its Label (a short name, written in capitals) and its Value (the figure). Optional: the Unit written small after the value ("ms", "/ 26"); the State (ok, ko, warn, off; off when empty), the shape and colour of its status, the value coloured for ko and warn, never alone; the Text of its status, under the value; the Title, its tooltip (the detail); the Href that makes the cell a link to the screen that details it.

type HealthProps added in v0.28.0

type HealthProps struct {
	ID    string
	Items []HealthItem
}

HealthProps feeds Health (0.28.0), the health strip of a node: a bordered row of cells, eight columns on a wide screen, four under 1 800 px, two under 700 px, each cell a figure of the node read at a glance (uptime, services, database, processor, disk space, network, certificates, monitors). ID is the id of the strip, optional. Items are its cells, in order.

type Language

type Language struct {
	Code    string // "fr"
	Label   string // "Français"
	URL     string // link that sets this language
	Current bool
}

Language is one entry of the language switcher.

type Link struct {
	Label string
	URL   string
	Icon  string
}

Link is a labelled URL, with an optional icon.

type LinkCardProps added in v0.6.0

type LinkCardProps struct {
	Label string
	URL   string
	Icon  string
	Text  string
}

LinkCardProps feeds LinkCard, a card that is a link, for a navigation page: the icon of the screen, its name and an optional sentence saying what it holds.

type NavGroup struct {
	Key   string // persisted collapse state key, e.g. "connexions"
	Title string // group title, already translated
	Items []NavItem
}

NavGroup is a group of the sidebar.

type NavItem struct {
	Icon    string
	Label   string
	URL     string
	Current bool // aria-current="page"
}

NavItem is an entry of the sidebar.

type NavState string

NavState is the state of the sidebar a page is rendered with (0.22.0): the choice the user made with the toggle of the header, which kit.js keeps in the cookie NavCookie. The shell renders it, so that the first frame of a page already shows the rail: applied by a script once the page was painted, the state slid the sidebar from its full width to the rail at each navigation.

const (
	NavDefault   NavState = ""          // no choice: full width, hidden under 1024 px (the stylesheet decides)
	NavCollapsed NavState = "collapsed" // the rail of icons
	NavExpanded  NavState = "expanded"  // the full width, under 1024 px too
)
func NavStateOf(r *http.Request) NavState

NavStateOf reads the choice from the request: no cookie, or any other value, is NavDefault.

type Notice added in v0.2.0

type Notice struct {
	Kind  string
	Title string
	Text  string
}

Notice is a notification rendered by the shell: the result of the previous action. Kind is one of "ok", "ko", "info".

type Options

type Options struct {
	// BasePath is the prefix of every page of the product ("/webui").
	BasePath string
	// StaticPath is the prefix of the static files of the kit, under
	// BasePath ("/static/gui").
	StaticPath string
	// ExternalIcons references the icons by URL (<use href="…/icons.svg#name">)
	// instead of inlining the sprite in every page.
	ExternalIcons bool
}

Options of a product: where the pages live and where the static files of the kit are served.

func OptionsOf added in v0.6.0

func OptionsOf(ctx context.Context) Options

OptionsOf returns the options bound to the context, or the zero options.

func (Options) IconHTML added in v0.6.0

func (o Options) IconHTML(name string, classes ...string) string

IconHTML is the markup of an icon of the sprite: an inline SVG that uses the symbol, decorative (aria-hidden), with the class "i" and the given extra classes. Every part is escaped.

func (Options) IconsURL added in v0.6.0

func (o Options) IconsURL() string

IconsURL is the URL of the sprite when the icons are external, else "".

func (Options) StaticURL added in v0.6.0

func (o Options) StaticURL(path string) string

StaticURL is a static file of the kit, under the static prefix.

func (Options) URL added in v0.6.0

func (o Options) URL(path string) string

URL is a page of the product: the base path followed by the path.

type Page

type Page struct {
	Lang        string // "fr" or "en", set on <html lang>
	Title       string // <title>: "<screen> · <instance> · <product>" is built by the shell
	Product     string // name of the product, shown in the header
	ProductSlug string // slug of the product: modifier class w-header--<slug>
	Instance    string // instance name shown in the header (monospace)
	Environment string // badge next to the instance ("Production"); empty hides it
	Username    string
	UserRole    string // short sentence under the account menu title ("Connecté en tant qu'administrateur")
	Footer      string // sidebar foot: "<product> <version> · révision <sha>"

	DocURL     string // documentation link, in the current language
	AccountURL string // "Mon compte"; empty hides the entry
	AboutURL   string // "À propos" as a page (the fallback without JavaScript); empty with a nil About hides the entry
	About      *About // "À propos" as a dialog rendered by the shell (opened by the entry with kit.js); nil renders none
	LogoutURL  string // sign out, as a POST form action
	HomeURL    string // brand link

	Languages []Language // language switcher; empty hides it
	Nav       []NavGroup // sidebar groups, already filtered by the user rights
	NavState  NavState   // state of the sidebar, NavStateOf(r): rendered by the shell; the zero value leaves it to the stylesheet
	NavClosed []string   // keys of the sidebar groups the user closed, NavClosedOf(r): rendered by the shell; nil leaves it to the script
	Crumbs    []Crumb    // breadcrumb; the last item is the current page
	// Return (0.30.0): the link back to the page of origin, rendered on the
	// line of the breadcrumb, to the right ("Back to the dashboard"); the
	// product gives the label and the address, nil renders none.
	Return  *Link
	Notices []Notice // results of the previous action (Post/Redirect/Get), shown as notifications

	// Wide (0.25.0): the content takes the whole width of the main area, the
	// gutters unchanged, for an operations screen with many columns or cards
	// side by side; false keeps the bound of 1280 px.
	Wide bool

	Head    templ.Component // extra content of <head> (a stylesheet of the screen); nil renders none
	Scripts templ.Component // extra content at the end of <body> (a script of the screen); nil renders none
}

Page carries the chrome of a page: language, title, product and instance, user, navigation already filtered by the user rights, breadcrumb, documentation and account links, notices. The product renders Shell with the Page and the component of its screen; Head and Scripts complete the <head> and the end of <body> when a screen needs them.

type PagerProps added in v0.6.0

type PagerProps struct {
	Info    string
	Page    int
	Pages   int
	PrevURL string
	NextURL string
	Hidden  map[string]string
	Sizes   []int
	Size    int
}

PagerProps feeds Pager, the foot of a list: the info sentence ("Partners 1 to 10 of 537"), the current page and the number of pages, the optional previous and next links, the hidden fields that carry the current filters in the GET form, the rows-per-page choices and the current one. Nothing renders when everything fits on one page and no size choice is offered.

type PasswordProps added in v0.19.0

type PasswordProps struct {
	ID           string
	Name         string
	Autocomplete string
	Describe     string // id of the hint or of the error of the field
	Required     bool
	Invalid      bool
}

PasswordProps feeds Password (0.19.0), a password field with the button that shows or hides what is typed: the native input, never pre-filled, and the toggle kit.js enables (hidden without JavaScript, the native field being enough). Autocomplete tells the password managers which password it is ("current-password" to sign in, "new-password" to set one).

type RichTextProps added in v0.9.0

type RichTextProps struct {
	ID       string
	Name     string
	Value    string
	Describe string
	Vars     string
	Required bool
	Invalid  bool
}

RichTextProps feeds RichText, the field of an HTML text (the body of an email). With editor.js (EditorAssets): a visual editor in an isolated frame (the HTML it shows runs no script; what is pasted keeps its structure, paragraphs, headings, lists, links, emphasis, tables, and nothing else), a toolbar (bold, italic, underline, heading, paragraph, lists, link, table, clear formatting) and an "HTML source" switch; the textarea, hidden while editing visually, carries the value sent. Without JavaScript: the textarea of the HTML source. Vars (optional) is the id of the VarList offered in the field; Describe is the id of the hint (and of the error); Invalid sets aria-invalid (the w-field around it carries is-invalid, as for any field). Since 0.9.0.

type SelectCellProps added in v0.21.0

type SelectCellProps struct {
	Form    string
	Value   string
	Name    string
	Checked bool
}

SelectCellProps feeds SelectCell, the checkbox of a row: Form (the id of the Selection), Value (the identifier sent) and Name (the object, as the accessible name of the checkbox says it: "le transfert 1042"). Optional: Checked.

type SelectionAction added in v0.21.0

type SelectionAction struct {
	Label  string
	Action string
	Get    bool
}

SelectionAction is a button of a Selection: its Label and the address the selection is sent to (Action, a POST). Get sends a GET instead, for an action that opens its confirmation page with the selection in the address.

type SelectionProps added in v0.21.0

type SelectionProps struct {
	ID      string
	Objects string
	Total   int
	Actions []SelectionAction
	Hidden  map[string]string
}

SelectionProps feeds Selection (0.21.0), the bar of the rows selected for a grouped action: ID (the id of its form, which the row checkboxes name in their form attribute, SelectCell, and the header checkbox in its data-select-page, SelectHead), Objects (the plural name of the objects, as the count says it: "transferts"), Total (the objects matching the current filter, all pages; 0 hides the whole-filter checkbox; an element marked data-select-total="<ID>" with data-total, the count of the toolbar in a live part, keeps it up to date) and Actions. Optional: Hidden (the current filters, sent as hidden fields with the selection).

type SelectionState added in v0.21.0

type SelectionState struct {
	All    bool
	IDs    []string
	Except []string
}

SelectionState is what a Selection form sends, read by ParseSelection: the whole filter (All) minus the Except identifiers, or the IDs checked. The product lists the objects of its filter itself and skips the exceptions.

func ParseSelection added in v0.21.0

func ParseSelection(v url.Values) SelectionState

ParseSelection reads the state of a Selection from the values of its form (r.Form): all=1 takes the whole filter, the ids are then ignored and except lists the exclusions; otherwise the ids checked. Blank values are dropped.

func (SelectionState) Empty added in v0.21.0

func (s SelectionState) Empty() bool

Empty says whether the state selects nothing.

type Serie added in v0.20.0

type Serie struct {
	Label  string
	Unit   string
	Values []int
	Kind   string
}

Serie is one series of a Chart: its Label (the legend), its Values (one per slot, a missing or negative one counts 0), its Kind ("ok", a plain bar; "ko", a hatched bar with its value written above; "ok" when empty) and, optional, the Unit written after a value in the title of a bar ("terminés"), Label otherwise.

type SkeletonRowsProps added in v0.13.0

type SkeletonRowsProps struct {
	Rows int
	Cols int
}

SkeletonRowsProps feeds SkeletonRows: the number of rows and of columns (at least one of each).

type SortableBarProps added in v0.14.0

type SortableBarProps struct {
	ID     string
	Action string
}

SortableBarProps feeds SortableBar, the bar of an ordered list (0.14.0): ID, the id of its form, which the data-sortable of the list and the form attribute of the hidden inputs of the items name; Action, where the new order is posted.

type Status

type Status struct {
	State  string
	Label  string
	Strong bool
}

Status is a state shown by Status: a shape and a colour, always with a label. State is one of "ok", "ko", "warn", "off". Strong (optional, 0.11.0) writes the label alone, in bold and in the colour of its state, for a list read at a glance: the label says the state, the colour doubles it (without the shape since 0.12.0).

type TagsProps added in v0.8.0

type TagsProps struct {
	ID       string
	Name     string
	Choices  []Choice
	Describe string
}

TagsProps feeds Tags, a multiple select that kit.js turns into the ordered list of the chosen values as tags (numbered: the order is the order of preference; a Remove button each; reordered by drag or by Alt + arrow) and a combobox that suggests the remaining choices (typing filters, arrow down browses, Enter adds, Backspace on an empty field removes the last one). Empty means everything is accepted (say it in the hint). Describe is the id of the hint. Since 0.8.0.

type ThProps added in v0.6.0

type ThProps struct {
	Label string
	Key   string
	Sort  string
	Dir   string
	Base  string
	Num   bool
}

ThProps feeds Th, a sortable column header: the label, the column key, the current sort key and direction ("asc" | "desc"), the query string carrying the other parameters ("?group=servers"; the page goes back to 1 on a new sort) and whether the column is numeric (right aligned).

type TileProps added in v0.6.0

type TileProps struct {
	Label    string
	Code     bool
	Value    string
	Variant  string
	Total    string
	SR       string
	Statuses []Status
	Foot     string
	Links    []Link
	Href     string
	Controls string
	Selected bool
}

TileProps feeds Tile, a key figure: the label and the value, and the optional variant (ok, ko, warn, info), total ("3 / 5"), accessible sentence (SR), statuses under the value, foot text and link. With Controls (the id of a tabpanel) the tile is a tab that shows its panel, one at a time; Href is then the server fallback (?group=…) and Selected marks the initial one; kit.js handles keyboard and hash. With Links (0.29.0) the foot is made of links, each to its own address: the tile is then a block whose main link (the label and the value) stretches over the whole tile, the links of the foot standing above it, so that no link is nested; Foot is then ignored. Code (0.31.0) writes the label as code: a path, rendered in the monospace font as typed, not uppercased.

type Translator

type Translator func(key string, args ...any) string

Translator returns the string of a catalogue key in the current language, with optional named parameters given as alternating name/value pairs.

type TreeCellProps added in v0.31.0

type TreeCellProps struct {
	Row   TreeRow
	Label string
	Count string
	Title string
	Mono  bool
}

TreeCellProps feeds TreeCell, the first cell of a row of a tree table: Row, the place of the row, and Label, the text of the node, shown relative to its parent (a path, a name). Optional: Count, the figure written after the label of a node ("81 dossiers", supplied by the server); Title, the tooltip of the cell (the whole path); Mono, the label in the monospace font (a path).

type TreeRow added in v0.31.0

type TreeRow struct {
	ID          string
	Parent      string
	Depth       int
	Open        bool
	HasChildren bool
}

TreeRow places a row in a tree table (0.31.0): a table (`table.w-table.w-table--one-line.w-tree[data-tree]`) whose rows form a tree, the server rendering the whole tree and its initial state, kit.js folding and unfolding. ID is the id of the row, unique in the page, that its children name in Parent (empty on a root); Depth is its level, 0 for a root, which indents its first cell; HasChildren marks a node (the row carries `w-tree__node` and its first cell a toggle); Open is the initial state of a node, decided by the server at every render (never remembered). TreeRowAttrs renders the attributes of the row, TreeCell its first cell.

type Var added in v0.9.0

type Var struct {
	Name   string     `json:"name"`
	Label  string     `json:"label"`
	Param  string     `json:"param,omitempty"`
	Tokens []VarToken `json:"tokens,omitempty"`
}

Var is a variable as a field inserts it between two "#": its Name ("TRUEFILENAME", "TIMESTAMP(YYYY-MM-DD_HHmmss)", "TI_key") and its Label (what it gives). Param (optional) is the part of the name selected after the insertion, a parameter to replace ("YYYY-MM-DD_HHmmss", "key"). Tokens (optional) are offered while the caret stays in the parameter, each inserted at the caret (the elements of a date format).

type VarGroup added in v0.9.0

type VarGroup struct {
	Label string `json:"label"`
	Vars  []Var  `json:"vars"`
}

VarGroup is a titled group of a VarList.

type VarListProps added in v0.9.0

type VarListProps struct {
	ID     string
	Groups []VarGroup
}

VarListProps feeds VarList: the variables that text fields accept, offered by editor.js (EditorAssets) in every field whose data-vars attribute names the list, and in a RichText whose Vars does. Typing "#" opens the list at the caret, the next keys filter it (by name, then by label, accents ignored), the arrows browse it, Enter or Tab inserts the variable between two "#", Escape closes it and keeps the "#"; a "Variables" button under the field opens it too. The list renders as data, nothing visible: without JavaScript the fields stay plain fields. Since 0.9.0.

type VarToken added in v0.9.0

type VarToken struct {
	Code    string `json:"code"`
	Label   string `json:"label"`
	Example string `json:"example,omitempty"`
}

VarToken is an element of a parameter: its Code ("YYYY"), its Label ("year") and an optional Example of its value ("2026").

Source Files

  • chart.go
  • chart_templ.go
  • check.go
  • components.go
  • components_templ.go
  • gui.go
  • layout_templ.go
  • selection.go
  • selection_templ.go
  • tree.go
  • tree_templ.go

Directories

Path Synopsis
cmd
vitrine command
Command vitrine renders the kit showcase: static HTML pages that show every component in every state, with fictitious data, plus complete screens (the Waarp Gateway "Service status" and "Local servers" screens, first screens of the migration).
Command vitrine renders the kit showcase: static HTML pages that show every component in every state, with fictitious data, plus complete screens (the Waarp Gateway "Service status" and "Local servers" screens, first screens of the migration).
internal
catalog
Package catalog reads the kit's own catalogues (i18n/<lang>.yaml, one file per language, nested keys with scalar leaves) without a YAML dependency.
Package catalog reads the kit's own catalogues (i18n/<lang>.yaml, one file per language, nested keys with scalar leaves) without a YAML dependency.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL