theme

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 3 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 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 Modes = []Mode{Auto, Light, Dark}

Modes lists the modes in the order the settings show 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 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 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