Help us shape the future of Go! Take the 2026 Go Developer Survey

brand

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrColors         = errors.New("brand: colors must use #RRGGBB")
	ErrFont           = errors.New("brand: invalid font")
	ErrWidth          = errors.New("brand: invalid page width")
	ErrTextContrast   = errors.New("brand: text needs at least 4.5:1 contrast against the background")
	ErrButtonContrast = errors.New("brand: no readable label color reaches AA on this accent; choose a less mid-toned accent")
)

Functions

func CSS

func CSS(identity Identity) string

CSS emits only validated tokens, shared by live themes and sandbox previews.

func OnAccent added in v0.18.0

func OnAccent(accent string) string

OnAccent is the label color for a fill of accent: white when it reaches WCAG AA 4.5:1, else near-black, else black. For any opaque color white and black multiply to a contrast of 21, so one always reaches at least sqrt(21) ~= 4.58:1 — a readable label always exists, and a light accent such as amber keeps readable labels instead of being rejected. The builder's brand CSS uses this; the theme identity layer applies the same rule and will share this implementation in a later change. accent must be #RRGGBB (as Validate requires); other input returns white.

func Validate

func Validate(identity Identity) error

Types

type Identity

type Identity struct {
	Accent     string `json:"accent"`
	Background string `json:"background"`
	Text       string `json:"text"`
	Font       string `json:"font"`
	Width      string `json:"width"`
}

func Default

func Default() Identity

Jump to

Keyboard shortcuts

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