ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

templ: version: v0.3.1070

templ: version: v0.3.1070

Package ui renders the admin's pages. The handlers fill these view structs; the templ components only lay them out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(p DeletePage) templ.Component

func DeleteDialog

func DeleteDialog(p DeletePage) templ.Component

DeleteDialog is the same confirmation as a dialog over the page.

func FlashFragment

func FlashFragment(f *Flash) templ.Component

Flash patches the message area alone.

func Form

func Form(p FormPage) templ.Component

func FormFragment

func FormFragment(p FormPage) templ.Component

FormFragment is the form alone, which a Datastar save patches with its errors. The id is on a wrapper: an input named after a column called id would shadow the form's own id property, and the patch would find no target.

func History

func History(p HistoryPage) templ.Component

func Index

func Index(p IndexPage) templ.Component

func List

func List(p ListPage) templ.Component

func ListFragment

func ListFragment(p ListPage) templ.Component

ListFragment is what a Datastar search, filter, sort or page patches: the filters the search form keeps, and the results with their sidebar.

func Log

func Log(p LogPage) templ.Component

func Login

func Login(p LoginPage) templ.Component

func LoginError

func LoginError(text string) templ.Component

LoginError is the login form's message, patched alone after a failed Datastar sign-in.

func Logout

func Logout(p LoginPage) templ.Component

func Message

func Message(p MessagePage) templ.Component

MessagePage is a page that only says something: not found, forbidden.

func Static

func Static() fs.FS

Static is the stylesheet and datastar.js, served under BasePath/static/.

Types

type Cell

type Cell struct {
	Kind    CellKind
	Text    string
	Title   string // the whole value, when Text is cut or formatted
	Bool    bool
	Mono    bool
	Numeric bool
	Href    string // a link to a related row
	Note    string // the related row's name, beside its key
}

Cell is one value in a list or a read-only row.

type CellKind

type CellKind int

CellKind is how a value is drawn.

const (
	CellText CellKind = iota
	CellNull
	CellBool
	CellMuted
)

type Chrome

type Chrome struct {
	SiteTitle string
	Base      string // BasePath, without the trailing slash
	PageTitle string
	User      string // username, "" on the login page
	LogoutURL string // "" when the Authenticator serves no logout
	Nav       []NavGroup
	Active    string // slug of the model the page is about
	Crumbs    []Crumb
	Flash     *Flash
}

Chrome is what every page around its content shows.

func (Chrome) StaticURL

func (c Chrome) StaticURL(name string) string

StaticURL is the address of a static file.

type Crumb

type Crumb struct {
	Label, URL string // the last crumb has no URL
}

type DeleteObject

type DeleteObject struct {
	Label, URL string
}

type DeletePage

type DeletePage struct {
	Chrome    Chrome
	Heading   string
	Objects   []DeleteObject
	Action    string
	CancelURL string
	Keys      []string // the primary keys a bulk delete posts back
	Bulk      bool
	Dialog    bool // shown over the page by Datastar, not as a page
	Label     string
	Plural    string
}

type Filter

type Filter struct {
	Label   string
	Note    string
	Options []FilterOption
}

type FilterOption

type FilterOption struct {
	Label, URL string
	Active     bool
}

type Flash

type Flash struct {
	Error bool
	Text  string
}

Flash is a message after a redirect.

type FormField

type FormField struct {
	Name     string
	Label    string
	Help     string
	Note     string // a hint the type adds: UTC, one per line, NULL
	Error    string
	Input    InputKind
	Value    string
	Checked  bool
	Required bool
	Mono     bool
	Options  []Option
	Cell     Cell // what a read-only field shows
	Related  *Cell
}

type FormPage

type FormPage struct {
	Chrome     Chrome
	Heading    string
	Action     string
	FormError  string
	Fields     []FormField
	Adding     bool
	CanSave    bool
	DeleteURL  string
	HistoryURL string
	Inlines    []InlineList
	SaveLabel  string
}

type HistoryPage

type HistoryPage struct {
	Chrome  Chrome
	Heading string
	Entries []LogEntry
	Empty   string
}

type IndexPage

type IndexPage struct {
	Chrome  Chrome
	Groups  []NavGroup
	Recent  []LogEntry
	LogURL  string
	Audited bool
}

type InlineList

type InlineList struct {
	Plural  string
	Columns []string
	Rows    []ListRow
	Total   int64
	AllURL  string
	AddURL  string
}

type InputKind

type InputKind int

InputKind is the input a form field renders.

const (
	InputText InputKind = iota
	InputTextarea
	InputNumber
	InputDecimal
	InputCheckbox
	InputNullBool
	InputSelect
	InputDateTime
	InputDate
	InputPassword
	InputReadOnly
)

type ListColumn

type ListColumn struct {
	Label   string
	SortURL string // "" when the column does not sort
	Sorted  string // "asc", "desc" or ""
	Numeric bool
}

type ListPage

type ListPage struct {
	Chrome      Chrome
	Plural      string
	Label       string
	ListURL     string
	AddURL      string
	Search      *Search
	Hidden      []Param // the filters and order the search form keeps
	Columns     []ListColumn
	Rows        []ListRow
	Filters     []Filter
	Total       int64
	Pager       Pager
	CanDelete   bool
	ClearURL    string // "" when nothing is filtered or searched
	ResultLabel string
}

type ListRow

type ListRow struct {
	PK    string
	URL   string
	Label string // the row's name, for the checkbox's label
	Cells []Cell
}

type LogEntry

type LogEntry struct {
	Time, User, Action, Model, Object, ObjectURL, Message string
	ActionClass                                           string // add, change, delete
}

type LogPage

type LogPage struct {
	Chrome  Chrome
	Entries []LogEntry
	Pager   Pager
	Empty   string
}

type LoginPage

type LoginPage struct {
	Chrome   Chrome
	Action   string
	Next     string
	Username string
	Error    string
}

type MessagePage

type MessagePage struct {
	Chrome  Chrome
	Heading string
	Text    string
}
type NavGroup struct {
	Name   string
	Models []NavModel
}
type NavModel struct {
	Slug, Plural, URL, AddURL string
}

type Option

type Option struct {
	Value, Label string
	Selected     bool
}
type PageLink struct {
	Label, URL string
	Current    bool
	Gap        bool
}

type Pager

type Pager struct {
	Page, Pages int
	PrevURL     string
	NextURL     string
	Links       []PageLink
}

type Param

type Param struct{ Name, Value string }
type Search struct {
	Value, Placeholder string
}

Jump to

Keyboard shortcuts

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