{{/* The component kit: one {{define}} per partial of docs/plans/panel-redesign.md
§ Three layers. This is the only file besides layout.html in which an sp-
component class is written; a page calls a partial and passes the struct
that components.go declares for it (a page never builds the input with
dict), and it never rebuilds the markup. The reference for every partial in
every state is the mockup components page,
docs/assets/panel-redesign/panel/src/components.html — the markup here is
that markup, element for element and class for class, and the kit page
(GET /server/components, kit.html) renders it all from fixtures.
Go templates have no slots, so a component that wraps the page's own
content is an open/close pair: box_open … box_close, body_open …
body_close, record_open … record_close. Between the two the page writes
Bulma markup (a table in its table-container, a form) or calls another
partial. */}}
{{/* ---- inline content: the text a struct field carries */}}
{{/* inline renders a Text (components.go): plain text, links, code, mono
values, strong, emphasis, tags and line breaks, all escaped. It is how a
lead, a box's end slot or a fact's value can hold a link or a code span
without any field being trusted HTML. */}}
{{define "inline"}}{{range .}}{{if .Break}}
{{else if .Tag}}{{template "tag" .Tag}}{{else if .Href}}{{template "inline_leaf" .}}{{else}}{{template "inline_leaf" .}}{{end}}{{end}}{{end}}
{{define "inline_leaf"}}{{if .Code}}{{.Text}}{{else if .Mono}}{{.Text}}{{else if .Strong}}{{.Text}}{{else if .Em}}{{.Text}}{{else}}{{.Text}}{{end}}{{end}}
{{/* tag is a status tag (input: Tag). The colour comes from status_tag, the one
mapping of status to Bulma classes; the label defaults to the status. */}}
{{define "tag"}}{{if .Label}}{{.Label}}{{else}}{{.Status}}{{end}}{{end}}
{{/* sheet_tag is a status tag that opens a sheet (input: Sheet): the tag as a
button, and the sheet it names right after it. sheet is what opens: the tag
again, a title, the cross that closes it, and a table of name and value.
The browser's popover does the rest - no script. */}}
{{define "sheet_tag"}}{{template "sheet" .}}{{end}}
{{define "sheet"}}
| {{.Label}} | {{range $i, $line := .Lines}}{{if $i}} {{end}}{{$line}}{{end}} |
|---|
{{range $i, $c := .Crumbs}}{{if $i}} {{end}}{{if $c.Href}}{{$c.Label}}{{else}}{{$c.Label}}{{end}} /{{end}}
{{else if .Kicker}}{{.Kicker}}
{{end}}{{template "inline" .Lead}}
{{end}}{{range .}}{{if .Arrow}}{{else if .Tag}}{{template "tag" .Tag}}{{else}}{{.Text}}{{end}}{{end}}
{{end}} {{/* flash is the result of the last action, between page_head and the first box (input: Flash). A field's own error stays in help is-danger. */}} {{define "flash"}}{{template "inline" .Problem}}
{{end}}{{template "inline" .Help}}
{{end}}{{range .}}{{if .Time}}{{.Time}} {{end}}{{if eq .Level "warn"}}{{.Text}}{{else if eq .Level "error"}}{{.Text}}{{else}}{{.Text}}{{end}}
{{end}}{{end}}
{{/* empty_state says what is absent and why that is fine (input: EmptyState). */}}
{{define "empty_state"}}{{template "inline" .}}
{{end}}