theme

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 5 Imported by: 0 modules, 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.

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

View Source
const (
	ModeAuto  = "auto"
	ModeLight = "light"
	ModeDark  = "dark"
)

Modes. Auto follows the viewer's device, through prefers-color-scheme.

View Source
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

View Source
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

func DefaultMode(name string) string

DefaultMode is the mode a preset takes when none is chosen, or "" for a name that isn't one.

func Describe

func Describe(name string) string

Describe is a preset's description, or "" for a name that isn't one.

func Names

func Names() []string

Names lists the presets, the default first.

func SwatchCSS

func SwatchCSS() string

SwatchCSS is a stylesheet that previews every preset, in both renditions and without anyone's overrides, as --sw-* properties on an element with data-sw="<name>-<light|dark>". It's a file because the portal's CSP refuses inline styles.

Types

type Rendition

type Rendition map[string]string

Rendition is one complete set of token values.

type Theme

type Theme struct {
	Name  string
	Mode  string
	Light Rendition
	Dark  Rendition
}

Theme is a resolved theme: every token set in both renditions.

func Default

func Default() Theme

Default is the theme with no settings.

func Resolve

func Resolve(name, mode string, light, dark map[string]string) (Theme, error)

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

func (t Theme) CSS() string

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) Header

func (t Theme) Header() string

Header is the value of X-Outpost-Theme on a request the gateway forwards.

func (Theme) JSON

func (t Theme) JSON() []byte

JSON is the theme as a document for apps that don't read CSS.

func (Theme) ThemeColor

func (t Theme) ThemeColor(dark bool) string

ThemeColor is the browser chrome colour for a rendition, for a page's theme-color meta.

Jump to

Keyboard shortcuts

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