Documentation
¶
Overview ¶
Package styles holds the kontrolplane palette as it applies to the terminal.
The values come from the brand tokens (github.com/kontrolplane/assets, tokens/color.json and tokens/semantic.json). Terminals cannot blend alpha, so every rule and tint is the solid mix the token describes. A detected theme keeps the terminal's own background; both themes paint cornsilk and black forest text with olive accents on top of it. A theme chosen with --theme paints its own background as well (see Paint).
Index ¶
- Variables
- func Accent(s string) string
- func Body(s string) string
- func Bold(s string) string
- func Button(label string, focused bool, tone Tone) string
- func Clean(s string) string
- func CleanBlock(s string) string
- func Faint(s string) string
- func Fg(t Tone) lipgloss.Style
- func Key(k, desc string) string
- func Muted(s string) string
- func Render(spans ...Span) string
- func SectionHeader(title string, width int, focused bool) string
- func SectionHeaderWith(title, meta string, width int) string
- func TextInput() textinput.Styles
- func Use(dark bool)
- type Palette
- type Span
- type Tone
Constants ¶
This section is empty.
Variables ¶
var Dark = Palette{ Dark: true, Base: lipgloss.Color("#1A1A1A"), Surface: lipgloss.Color("#353532"), Selection: lipgloss.Color("#3A3F28"), Rule: lipgloss.Color("#3E3E3A"), RuleBold: lipgloss.Color("#716F65"), Text: cornsilk, Body: lipgloss.Color("#ECE8D0"), Muted: lipgloss.Color("#C3C0AD"), Faint: lipgloss.Color("#979587"), Accent: lipgloss.Color("#9FA57B"), Warm: lipgloss.Color("#D0975D"), Success: lipgloss.Color("#00C389"), Warning: lipgloss.Color("#F7AB1B"), Info: lipgloss.Color("#53A2FF"), Danger: lipgloss.Color("#FF6467"), }
Dark sits on the terminal's own dark ground. Tints mix cornsilk into a neutral dark so only the accent reads as olive.
var Light = Palette{ Dark: false, Base: cornsilk, Surface: lipgloss.Color("#F3F0D6"), Selection: lipgloss.Color("#D7D7BC"), Rule: lipgloss.Color("#D3D3B8"), RuleBold: lipgloss.Color("#BEBFA4"), Text: blackForest, Body: lipgloss.Color("#3D4A2C"), Muted: lipgloss.Color("#60694C"), Faint: lipgloss.Color("#6C7558"), Accent: lipgloss.Color("#606C38"), Warm: lipgloss.Color("#A16223"), Success: lipgloss.Color("#007E4E"), Warning: lipgloss.Color("#9C6000"), Info: lipgloss.Color("#0067C7"), Danger: lipgloss.Color("#E7000B"), }
Light is the cornsilk stock. Hierarchy is a tint of black forest, never a grey.
var P = Dark
P is the active palette.
var Paint bool
Paint is set when the theme was chosen rather than detected. The palette then paints its own ground, since the terminal's may be the opposite of what the theme was made for.
Functions ¶
func Button ¶
Button renders a dialog button. A focused button takes the primary treatment, or the given tone when the action it confirms is destructive.
func Clean ¶
Clean makes text from the server safe to draw: control characters (C0, DEL, C1) are shown escaped.
func CleanBlock ¶
CleanBlock is Clean for multi-line text, keeping newlines; tabs become 4 spaces.
func SectionHeader ¶
SectionHeader renders a lowercase label followed by a hairline, filling width.
func SectionHeaderWith ¶
SectionHeaderWith renders a section header with meta text right aligned in the rule.
Types ¶
type Palette ¶
type Palette struct {
Dark bool
Base color.Color // the plate or the stock
Surface color.Color // raised surfaces, unfocused buttons
Selection color.Color // the row under the cursor
Rule color.Color // hairlines and borders
RuleBold color.Color // a rule that has to read as a division
Text color.Color // headings and anything that carries the page
Body color.Color // values and body copy
Muted color.Color // labels and meta
Faint color.Color // hints, punctuation, empty values
Accent color.Color // olive: the brand's highlight, wildcards and indices
Warm color.Color // copper: numbers in payloads
Success color.Color
Warning color.Color
Info color.Color
Danger color.Color
}
Palette is one theme of the brand, resolved to solid colours.