theme

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 13 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 holds Matinee's colour themes: the ones built in, and ones an admin adds by putting a theme file in the data directory's themes folder.

A theme is a small JSON file of colours and font names, never code, so it is safe to share. The server sends every client the full set of colours; the colours a file leaves out are worked out from the ones it gives (see Resolve). docs/themes.md describes the format for people making themes.

Index

Constants

View Source
const Default = "matinee"

Default is the theme people see until they or an admin pick another.

Variables

View Source
var (
	DisplayFonts = []string{"fraunces", "inter", "orbitron"}
	BodyFonts    = []string{"inter"}
)

DisplayFonts and BodyFonts are the typefaces bundled with the web player and the apps. Adding one means adding it to every client.

Functions

func Contrast

func Contrast(a, b Color) float64

Contrast is the WCAG contrast ratio of two opaque colours, from 1 to 21.

Types

type Color

type Color struct {
	R, G, B uint8
	A       float64
}

Color is an sRGB colour with alpha from 0 to 1.

func ParseColor

func ParseColor(s string) (Color, error)

ParseColor reads #rgb, #rrggbb, #rrggbbaa, rgb(r,g,b) or rgba(r,g,b,a).

func (Color) Alpha

func (c Color) Alpha(a float64) Color

Alpha is the colour with another opacity.

func (Color) String

func (c Color) String() string

type Colors

type Colors struct {
	// Required.
	Ink     string `json:"ink"`     // the page behind everything
	Surface string `json:"surface"` // panels and bars
	Raised  string `json:"raised"`  // cards, inputs and buttons on a panel
	Line    string `json:"line"`    // borders and dividers
	Text    string `json:"text"`    // body text and titles
	Muted   string `json:"muted"`   // secondary text
	Faint   string `json:"faint"`   // hints and the least important text
	Accent  string `json:"accent"`  // the main button, links, what has focus

	// Optional; Resolve works them out from the ones above.
	AccentStrong string `json:"accentStrong"` // the accent when pressed or hovered
	OnAccent     string `json:"onAccent"`     // text on an accent button
	Danger       string `json:"danger"`       // errors and deleting
	Glow         string `json:"glow"`         // the halo around what has focus on a TV
	Glass        string `json:"glass"`        // frosted buttons over artwork
	GlassFocused string `json:"glassFocused"` // a frosted button with focus
	Scrim        string `json:"scrim"`        // behind the video player
	Track        string `json:"track"`        // a progress bar's unplayed part
	Shade        string `json:"shade"`        // dark wash under text on artwork
	Veil         string `json:"veil"`         // tints a backdrop towards the page
}

Colors are CSS colours: #rgb, #rrggbb, #rrggbbaa or rgba(r,g,b,a).

type Fonts

type Fonts struct {
	Display string `json:"display"` // titles and headings
	Body    string `json:"body"`    // everything else
}

Fonts name typefaces from the set every client ships (DisplayFonts and BodyFonts), since a TV can't load fonts from a theme.

type Theme

type Theme struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Author      string `json:"author,omitempty"`
	// Scheme is "dark" or "light": what the system's own controls (scroll
	// bars, keyboards, alerts) should match.
	Scheme string `json:"scheme"`
	Fonts  Fonts  `json:"fonts"`
	Colors Colors `json:"colors"`
	// BuiltIn is set by the server for the themes that ship with Matinee.
	BuiltIn bool `json:"builtIn"`
}

Theme is a theme file, and with Resolve, what the clients are sent.

func Builtin

func Builtin() []Theme

Builtin returns the themes that ship with Matinee, Default first.

func Load

func Load(dir string) (themes []Theme, problems []error)

Load returns the built-in themes and the ones in dir, which may not exist. A file that isn't a valid theme is skipped and reported in problems, so one bad file doesn't hide the rest. A file can't replace a built-in theme.

func Parse

func Parse(b []byte) (Theme, error)

Parse reads a theme file, checks it, and fills in the optional colours.

func (Theme) Check

func (t Theme) Check() []string

Check lists what's hard to read in a theme: pairs of colours below WCAG AA contrast (4.5:1 for text, 3:1 for hints). Themes with warnings still load; the built-in ones have none.

func (Theme) Resolve

func (t Theme) Resolve() Theme

Resolve fills in the optional colours and fonts of a valid theme, and writes every colour the same way, as #rrggbb or rgba(r,g,b,a), so clients only have to read two forms.

func (Theme) Validate

func (t Theme) Validate() error

Validate says what's wrong with a theme, all at once.

Jump to

Keyboard shortcuts

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