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
- Variables
- func Contrast(a, b ui.Color) float64
- func Dense(base ui.Theme) *ui.Theme
- func Luminance(c ui.Color) float64
- func Space(n float32) float32
- type Mode
- type Scheme
- type Shadow
- type Terminal
- type Tokens
- func (t Tokens) Apply(base ui.Theme) *ui.Theme
- func (t Tokens) Material(base ui.Theme) *ui.Theme
- func (t Tokens) SidebarTheme(base ui.Theme, clear bool) *ui.Theme
- func (t Tokens) Tint(name string) ui.Color
- func (t Tokens) TintAt(i int) ui.Color
- func (t Tokens) TintNamed(name string) (c ui.Color, ok bool)
Constants ¶
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.
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.
const BrandHex = "#1984FC"
BrandHex is SSHYard's fixed brand color.
const CustomPrefix = "custom:"
CustomPrefix starts the ID of an imported scheme.
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.
const MaxITermColors = 256 << 10
MaxITermColors bounds the file read: a scheme is a few kilobytes.
const SpaceUnit float32 = 4
SpaceUnit is the step of the spacing scale: Space(n) is n steps.
Variables ¶
var Brand = ui.Hex(BrandHex)
Brand is the brand color.
var ErrNotITermColors = errors.New("theme: not an .itermcolors color scheme")
ErrNotITermColors is a file that is no .itermcolors color scheme.
var Modes = []Mode{Auto, Light, Dark}
Modes lists the modes in the order the settings show them.
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.
var TintNames = []string{"green", "orange", "teal", "purple", "indigo", "pink", "red", "blue"}
TintNames name the Tints, in order: what a host saves as its color.
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 Dense ¶ added in v0.0.19
Dense is a copy of base for dense lists, for ui.Themed: MyGo's widgets inside take the DenseUnit step and the Footnote size.
Types ¶
type Mode ¶
type Mode string
Mode is the appearance the user chose.
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
FindScheme is the scheme with id, built-in or among custom.
func ParseITermColors ¶ added in v0.0.9
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.
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 (Tokens) Apply ¶
Apply writes the tokens over a copy of base, the theme MyGo made, and returns it, for Context.SetTheme.
func (Tokens) Material ¶
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 ¶
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).