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
- Variables
- func AboutBody(page Page) templ.Component
- func AboutDialog(page Page) templ.Component
- func Actions(p ActionsProps) templ.Component
- func Banner(p BannerProps) templ.Component
- func Bind(ctx context.Context, tr Translator, opts Options) context.Context
- func Chart(p ChartProps) templ.Component
- func CheckAssets() templ.Component
- func Combobox(p ComboboxProps) templ.Component
- func ComboboxAssets() templ.Component
- func Crumbs(crumbs []Crumb) templ.Component
- func CrumbsRow(crumbs []Crumb, ret *Link) templ.Component
- func Dual(p DualProps) templ.Component
- func EditorAssets() templ.Component
- func Empty(p EmptyProps) templ.Component
- func File(p FileProps) templ.Component
- func FiltersFoot(resetURL string) templ.Component
- func FormActions(p FormActionsProps) templ.Component
- func Header(page Page) templ.Component
- func Health(p HealthProps) templ.Component
- func Icon(name string, classes ...string) templ.Component
- func IconsURL(ctx context.Context) string
- func LeaveDialog() templ.Component
- func LinkCard(p LinkCardProps) templ.Component
- func LiveAssets() templ.Component
- func NavClosedOf(r *http.Request) []string
- func NoticeOf(n Notice) templ.Component
- func Pager(p PagerProps) templ.Component
- func Password(p PasswordProps) templ.Component
- func Plain(page Page, body templ.Component) templ.Component
- func Query(base string, kv ...any) string
- func Render(ctx context.Context, w io.Writer, tr Translator, opts Options, ...) error
- func RichText(p RichTextProps) templ.Component
- func SelectCell(p SelectCellProps) templ.Component
- func SelectHead(form string) templ.Component
- func Selection(p SelectionProps) templ.Component
- func Shell(page Page, body templ.Component) templ.Component
- func Sidebar(page Page) templ.Component
- func SkeletonRows(p SkeletonRowsProps) templ.Component
- func SortableAssets() templ.Component
- func SortableBar(p SortableBarProps) templ.Component
- func SortableGrip(name string) templ.Component
- func StaticURL(ctx context.Context, path string) string
- func StatusOf(s Status) templ.Component
- func T(ctx context.Context, key string, args ...any) string
- func Tags(p TagsProps) templ.Component
- func Th(p ThProps) templ.Component
- func Tile(p TileProps) templ.Component
- func TreeCell(p TreeCellProps) templ.Component
- func TreeRowAttrs(r TreeRow) templ.Attributes
- func URL(ctx context.Context, path string) string
- func VarList(p VarListProps) templ.Component
- func WithOptions(ctx context.Context, opts Options) context.Context
- func WithTranslator(ctx context.Context, tr Translator) context.Context
- type About
- type Action
- type ActionsProps
- type BannerProps
- type ChartGroup
- type ChartProps
- type Check
- type Choice
- type ComboChoice
- type ComboGroup
- type ComboboxProps
- type Crumb
- type DualProps
- type EmptyProps
- type FileProps
- type FormActionsProps
- type HealthItem
- type HealthProps
- type Language
- type Link
- type LinkCardProps
- type NavGroup
- type NavItem
- type NavState
- type Notice
- type Options
- type Page
- type PagerProps
- type PasswordProps
- type RichTextProps
- type SelectCellProps
- type SelectionAction
- type SelectionProps
- type SelectionState
- type Serie
- type SkeletonRowsProps
- type SortableBarProps
- type Status
- type TagsProps
- type ThProps
- type TileProps
- type Translator
- type TreeCellProps
- type TreeRow
- type Var
- type VarGroup
- type VarListProps
- type VarToken
Constants ¶
NavCookie carries the choice: "1" for the rail, "0" for the full width.
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 ¶
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.
var Languages = []string{"fr", "en"}
Languages the kit translates.
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.
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
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
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 ¶ added in v0.6.0
func Banner(p BannerProps) templ.Component
Banner: persistent message (see BannerProps).
func Bind ¶ added in v0.6.0
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
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
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
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
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
Dual: dual list (see DualProps). Without JavaScript it stays a plain multiple select.
func EditorAssets ¶ added in v0.9.0
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
File: file field that says its state (see FileProps). Without JavaScript: the native field alone.
func FiltersFoot ¶ added in v0.6.0
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 ¶ added in v0.6.0
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
Icon renders an icon of the sprite (see Options.IconHTML).
func IconsURL ¶ added in v0.6.0
IconsURL is the URL of the sprite when the icons are external, else "".
func LeaveDialog ¶ added in v0.15.0
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
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 ¶ added in v0.23.0
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
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
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
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
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
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
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 ¶ added in v0.6.0
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
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
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
StaticURL is a static file of the kit, under the static prefix.
func StatusOf ¶ added in v0.6.0
StatusOf: shape + colour + label, never colour alone.
func T ¶ added in v0.6.0
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
Tags: an ordered multiple choice as tags with suggestions (see TagsProps). Without JavaScript: a multiple select.
func Th ¶ added in v0.6.0
Th: sortable column header (see ThProps).
func Tile ¶ added in v0.6.0
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
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
WithOptions returns a context carrying the options of the product.
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 ¶
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
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
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
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
Message is what a field says of a value that does not fit (check.<kind> in the catalogue of the kit).
type Choice ¶ added in v0.6.0
Choice is an option of a select: Dual lists the chosen ones first.
type ComboChoice ¶ added in v0.14.0
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 ¶
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
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
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 ¶
Link is a labelled URL, with an optional icon.
type LinkCardProps ¶ added in v0.6.0
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 NavState ¶ added in v0.22.0
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 ( )
type Notice ¶ added in v0.2.0
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
OptionsOf returns the options bound to the context, or the zero options.
func (Options) IconHTML ¶ added in v0.6.0
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
IconsURL is the URL of the sprite when the icons are external, else "".
func (Options) StaticURL ¶ added in v0.6.0
StaticURL is a static file of the kit, under the static prefix.
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")
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
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
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
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
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
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
SkeletonRowsProps feeds SkeletonRows: the number of rows and of columns (at least one of each).
type SortableBarProps ¶ added in v0.14.0
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 ¶
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
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
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 ¶
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
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
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
VarGroup is a titled group of a VarList.
type VarListProps ¶ added in v0.9.0
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.
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. |