theme

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 10 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 SSHYard's design tokens: the brand color, the light and dark palettes of the interface and of the terminal, and how a mode (auto, light, dark) chooses between them.

Index

Constants

View Source
const (
	RadiusSmall   float32 = 6   // icon buttons, menu items, chips
	RadiusControl float32 = 8   // inputs, list rows, selects, banners
	RadiusCard    float32 = 12  // panes, settings groups, popovers
	RadiusSheet   float32 = 16  // dialogs and sheets
	Capsule       float32 = 999 // pill buttons, segmented tracks
)

Radii are the corner radii, small to large. Shapes nest concentrically: a shape inside another with padding p has the outer radius minus p.

View Source
const (
	Caption  float32 = 11 // details, counts, secondary lines
	Footnote float32 = 12 // pane headers, banners
	Body     float32 = 13 // everything else
	Title3   float32 = 15 // the sidebar's app name, page headers
	Title2   float32 = 17 // dialog titles
	Title1   float32 = 22 // the settings page title, the welcome
)

The type scale, in DIPs, after Apple's text styles on the Mac.

View Source
const BrandHex = "#1984FC"

BrandHex is SSHYard's fixed brand color.

View Source
const CustomPrefix = "custom:"

CustomPrefix starts the ID of an imported scheme.

View Source
const DenseUnit float32 = 3

DenseUnit is MyGo's spacing step in dense lists, as a files table: its rows and header are 24 DIPs, not 32.

View Source
const MaxITermColors = 256 << 10

MaxITermColors bounds the file read: a scheme is a few kilobytes.

View Source
const SpaceUnit float32 = 4

SpaceUnit is the step of the spacing scale: Space(n) is n steps.

Variables

View Source
var Brand = ui.Hex(BrandHex)

Brand is the brand color.

View Source
var ErrNotITermColors = errors.New("theme: not an .itermcolors color scheme")

ErrNotITermColors is a file that is no .itermcolors color scheme.

View Source
var Modes = []Mode{Auto, Light, Dark}

Modes lists the modes in the order the settings show them.

View Source
var Schemes = []Scheme{
	{ID: "dracula", Name: "Dracula", Foreground: "#F8F8F2", Background: "#282A36", Cursor: "#F8F8F2", Selection: "#44475A",
		ANSI: [16]string{"#21222C", "#FF5555", "#50FA7B", "#F1FA8C", "#BD93F9", "#FF79C6", "#8BE9FD", "#F8F8F2",
			"#6272A4", "#FF6E6E", "#69FF94", "#FFFFA5", "#D6ACFF", "#FF92DF", "#A4FFFF", "#FFFFFF"}},
	{ID: "solarized-dark", Name: "Solarized Dark", Foreground: "#839496", Background: "#002B36", Cursor: "#93A1A1", Selection: "#073642",
		ANSI: [16]string{"#073642", "#DC322F", "#859900", "#B58900", "#268BD2", "#D33682", "#2AA198", "#EEE8D5",
			"#002B36", "#CB4B16", "#586E75", "#657B83", "#839496", "#6C71C4", "#93A1A1", "#FDF6E3"}},
	{ID: "solarized-light", Name: "Solarized Light", Foreground: "#657B83", Background: "#FDF6E3", Cursor: "#586E75", Selection: "#EEE8D5",
		ANSI: [16]string{"#073642", "#DC322F", "#859900", "#B58900", "#268BD2", "#D33682", "#2AA198", "#EEE8D5",
			"#002B36", "#CB4B16", "#586E75", "#657B83", "#839496", "#6C71C4", "#93A1A1", "#FDF6E3"}},
	{ID: "nord", Name: "Nord", Foreground: "#D8DEE9", Background: "#2E3440", Cursor: "#D8DEE9", Selection: "#434C5E",
		ANSI: [16]string{"#3B4252", "#BF616A", "#A3BE8C", "#EBCB8B", "#81A1C1", "#B48EAD", "#88C0D0", "#E5E9F0",
			"#4C566A", "#BF616A", "#A3BE8C", "#EBCB8B", "#81A1C1", "#B48EAD", "#8FBCBB", "#ECEFF4"}},
	{ID: "one-dark", Name: "One Dark", Foreground: "#ABB2BF", Background: "#282C34", Cursor: "#528BFF", Selection: "#3E4451",
		ANSI: [16]string{"#282C34", "#E06C75", "#98C379", "#E5C07B", "#61AFEF", "#C678DD", "#56B6C2", "#ABB2BF",
			"#5C6370", "#E06C75", "#98C379", "#E5C07B", "#61AFEF", "#C678DD", "#56B6C2", "#FFFFFF"}},
	{ID: "one-light", Name: "One Light", Foreground: "#383A42", Background: "#FAFAFA", Cursor: "#526FFF", Selection: "#E5E5E6",
		ANSI: [16]string{"#383A42", "#E45649", "#50A14F", "#C18401", "#4078F2", "#A626A4", "#0184BC", "#A0A1A7",
			"#696C77", "#E45649", "#50A14F", "#C18401", "#4078F2", "#A626A4", "#0184BC", "#FAFAFA"}},
	{ID: "gruvbox-dark", Name: "Gruvbox Dark", Foreground: "#EBDBB2", Background: "#282828", Cursor: "#EBDBB2", Selection: "#504945",
		ANSI: [16]string{"#282828", "#CC241D", "#98971A", "#D79921", "#458588", "#B16286", "#689D6A", "#A89984",
			"#928374", "#FB4934", "#B8BB26", "#FABD2F", "#83A598", "#D3869B", "#8EC07C", "#EBDBB2"}},
	{ID: "tokyo-night", Name: "Tokyo Night", Foreground: "#C0CAF5", Background: "#1A1B26", Cursor: "#C0CAF5", Selection: "#33467C",
		ANSI: [16]string{"#15161E", "#F7768E", "#9ECE6A", "#E0AF68", "#7AA2F7", "#BB9AF7", "#7DCFFF", "#A9B1D6",
			"#414868", "#F7768E", "#9ECE6A", "#E0AF68", "#7AA2F7", "#BB9AF7", "#7DCFFF", "#C0CAF5"}},
	{ID: "monokai", Name: "Monokai", Foreground: "#F8F8F2", Background: "#272822", Cursor: "#F8F8F0", Selection: "#49483E",
		ANSI: [16]string{"#272822", "#F92672", "#A6E22E", "#F4BF75", "#66D9EF", "#AE81FF", "#A1EFE4", "#F8F8F2",
			"#75715E", "#F92672", "#A6E22E", "#F4BF75", "#66D9EF", "#AE81FF", "#A1EFE4", "#F9F8F5"}},
	{ID: "catppuccin-mocha", Name: "Catppuccin Mocha", Foreground: "#CDD6F4", Background: "#1E1E2E", Cursor: "#F5E0DC", CursorText: "#1E1E2E", Selection: "#585B70",
		ANSI: [16]string{"#45475A", "#F38BA8", "#A6E3A1", "#F9E2AF", "#89B4FA", "#F5C2E7", "#94E2D5", "#BAC2DE",
			"#585B70", "#F38BA8", "#A6E3A1", "#F9E2AF", "#89B4FA", "#F5C2E7", "#94E2D5", "#A6ADC8"}},
}

Schemes are the built-in color schemes, as their authors publish them.

View Source
var TintNames = []string{"green", "orange", "teal", "purple", "indigo", "pink", "red", "blue"}

TintNames name the Tints, in order: what a host saves as its color.

View Source
var Tints = [][2]ui.Color{
	{ui.Hex("#28B14C"), ui.Hex("#30D158")},
	{ui.Hex("#F59100"), ui.Hex("#FF9F0A")},
	{ui.Hex("#14A3BE"), ui.Hex("#40C8E0")},
	{ui.Hex("#AF52DE"), ui.Hex("#BF5AF2")},
	{ui.Hex("#5856D6"), ui.Hex("#5E5CE6")},
	{ui.Hex("#FF2D55"), ui.Hex("#FF375F")},
	{ui.Hex("#FF3B30"), ui.Hex("#FF453A")},
	{ui.Hex("#007AFF"), ui.Hex("#0A84FF")},
}

Tints are Apple's system colors, light then dark, for the tiles that tell hosts apart; the brand blue stays the accent.

Functions

func Contrast

func Contrast(a, b ui.Color) float64

Contrast is the WCAG contrast ratio of two opaque colors.

func Dense added in v0.0.19

func Dense(base ui.Theme) *ui.Theme

Dense is a copy of base for dense lists, for ui.Themed: MyGo's widgets inside take the DenseUnit step and the Footnote size.

func Luminance

func Luminance(c ui.Color) float64

Luminance is the relative luminance of c (WCAG 2), ignoring alpha.

func Space

func Space(n float32) float32

Space is n steps of the spacing scale (4, 8, 12, 16, 20, 24 …).

Types

type Mode

type Mode string

Mode is the appearance the user chose.

const (
	Auto  Mode = "auto"  // follow the system
	Light Mode = "light" // always light
	Dark  Mode = "dark"  // always dark
)

func (Mode) IsDark

func (m Mode) IsDark(systemDark bool) bool

IsDark resolves the mode against the system's appearance.

func (Mode) Valid

func (m Mode) Valid() bool

Valid reports whether m is one of the known modes.

type Scheme added in v0.0.9

type Scheme struct {
	// ID names the scheme in the settings: a built-in's own, or
	// CustomPrefix and the name of an imported one.
	ID         string `json:"id"`
	Name       string `json:"name"`
	Foreground string `json:"foreground"`
	Background string `json:"background"`
	// Cursor, CursorText and Selection may be empty: the foreground, the
	// background and the foreground faded stand in.
	Cursor     string `json:"cursor,omitempty"`
	CursorText string `json:"cursorText,omitempty"`
	Selection  string `json:"selection,omitempty"`
	// ANSI are the 16 colors of SGR 30–37 and 90–97.
	ANSI [16]string `json:"ansi"`
}

Scheme is a terminal color scheme, its colors as #RRGGBB: one of the built-in Schemes, or one the user imported (kept in the settings). Search matches keep the app's colors.

func FindScheme added in v0.0.9

func FindScheme(id string, custom []Scheme) (Scheme, bool)

FindScheme is the scheme with id, built-in or among custom.

func ParseITermColors added in v0.0.9

func ParseITermColors(name string, data []byte) (Scheme, error)

ParseITermColors reads an iTerm2 color scheme (an .itermcolors property list, as the iTerm2-Color-Schemes collection publishes them) named name. The foreground, the background and the 16 colors are required.

func (Scheme) Custom added in v0.0.9

func (s Scheme) Custom() bool

Custom reports a scheme the user imported.

func (Scheme) Dark added in v0.0.9

func (s Scheme) Dark() bool

Dark reports a scheme whose background is dark.

func (Scheme) Terminal added in v0.0.9

func (s Scheme) Terminal(base Terminal) Terminal

Terminal is the scheme as the terminal's palette; base gives what the scheme does not set (the search matches).

func (Scheme) Valid added in v0.0.9

func (s Scheme) Valid() bool

Valid reports a scheme with a name and colors that all parse.

type Shadow

type Shadow struct {
	X, Y, Blur, Spread float32
	Color              ui.Color
}

Shadow is one soft drop shadow.

func (Shadow) On

func (s Shadow) On(e ui.Element) ui.Element

On gives e the shadow.

type Terminal

type Terminal struct {
	Foreground, Background, Cursor, CursorText, Selection, Match, MatchCurrent ui.Color
	// ANSI are the 16 colors of SGR 30–37 and 90–97.
	ANSI [16]ui.Color
}

Terminal is the palette of the terminal view.

type Tokens

type Tokens struct {
	Dark                                      bool
	Background, Surface, SurfaceHover         ui.Color
	SurfacePressed, Border, Text, TextMuted   ui.Color
	Accent, AccentHover, AccentPressed        ui.Color
	AccentText, Danger, Warning, Success      ui.Color
	Selection, Focus, Sidebar, TabActive      ui.Color
	Inverse, InverseText, Scrollbar           ui.Color
	Radius, Spacing, FontSize, ScrollbarWidth float32

	// Canvas is the content area behind the panes, beside the sidebar.
	Canvas ui.Color
	// Inset is the fill of what sits on the canvas: panes, cards, the
	// selected tab, menus.
	Inset ui.Color
	// Glass is the translucent fill of the toolbar and of the controls
	// floating on content; GlassEdge is its hairline.
	Glass, GlassEdge ui.Color
	// Line is a hairline separator; Hover and Press tint a control under
	// the pointer and pressed, over any fill.
	Line, Hover, Press ui.Color
	// Fill is the quiet fill of capsule controls at rest.
	Fill ui.Color
	// Card is the shadow of a card on the canvas, Lift that of a sheet
	// or popover floating over the window.
	Card, Lift Shadow
	Terminal   Terminal
}

Tokens are the colors and metrics of one appearance.

func DarkTokens

func DarkTokens() Tokens

DarkTokens are the tokens of the dark appearance.

func For

func For(m Mode, systemDark bool) Tokens

For returns the tokens of the mode under the system's appearance.

func LightTokens

func LightTokens() Tokens

LightTokens are the tokens of the light appearance.

func (Tokens) Apply

func (t Tokens) Apply(base ui.Theme) *ui.Theme

Apply writes the tokens over a copy of base, the theme MyGo made, and returns it, for Context.SetTheme.

func (Tokens) Material

func (t Tokens) Material(base ui.Theme) *ui.Theme

Material is the theme for content drawn on the window's material (vibrancy), whose own fill must stay clear for the material to show.

func (Tokens) SidebarTheme

func (t Tokens) SidebarTheme(base ui.Theme, clear bool) *ui.Theme

SidebarTheme returns the theme of the sidebar: rounded rows, a quiet hover and an unfocused selection in gray, on the sidebar's own fill (or the clear material, when clear).

func (Tokens) Tint

func (t Tokens) Tint(name string) ui.Color

Tint is the system color picked for name, the same for every run.

func (Tokens) TintAt

func (t Tokens) TintAt(i int) ui.Color

TintAt returns the i-th system tint for the mode: 0 green, 1 orange, 2 teal, 3 purple, 4 indigo, 5 pink, 6 red, 7 blue.

func (Tokens) TintNamed

func (t Tokens) TintNamed(name string) (c ui.Color, ok bool)

TintNamed is the tint of a name of TintNames for the mode; ok is false for any other name, "" too.

Jump to

Keyboard shortcuts

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