Documentation
¶
Overview ¶
Package theme is the look an Outpost shares with its apps: a preset, each with a light and a dark rendition, optionally adjusted by the operator, resolved into a fixed set of tokens. The gateway serves the result on every app's host as CSS custom properties (--op-*) and as JSON, and the portal's own stylesheet is written against the same tokens. See docs/design/themes.md and outpost-service-spec.md §18.
The package is pure: no I/O, so config can validate with it and the gateway can render with it.
Index ¶
Constants ¶
const ( ModeAuto = "auto" ModeLight = "light" ModeDark = "dark" )
Modes. Auto follows the viewer's device, through prefers-color-scheme.
const DefaultName = "night"
DefaultName is the theme an Outpost has until its operator picks one: the portal's own Service Line, so nothing changes for anyone who doesn't.
Variables ¶
var Tokens = []string{
"bg",
"surface",
"surface-raised",
"rule",
"text",
"text-press",
"text-dim",
"field-edge",
"accent",
"on-accent",
"focus",
"focus-core",
"danger",
"danger-plate",
"on-danger",
"danger-ink",
"ok",
"warn",
"font-sans",
"font-mono",
"radius",
"radius-pill",
}
Tokens are the names an app can rely on, in the order they're written. Adding one is backward compatible; renaming or removing one is a change to the contract.
Functions ¶
func DefaultMode ¶
DefaultMode is the mode a preset takes when none is chosen, or "" for a name that isn't one.
Types ¶
type Theme ¶
Theme is a resolved theme: every token set in both renditions.
func Resolve ¶
Resolve builds a theme from a preset's name ("" for the default), a mode ("" for the preset's own), and the operator's overrides for each rendition, keyed by token name without the --op- prefix.
func (Theme) CSS ¶
CSS is the stylesheet: the tokens as --op-* custom properties on :root. With the mode on auto the light rendition is the base and the dark one takes over under prefers-color-scheme: dark, saying so with its own color-scheme, since an app may read the computed value to learn which rendition it got.
func (Theme) ThemeColor ¶
ThemeColor is the browser chrome colour for a rendition, for a page's theme-color meta.