Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions color/palette.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ var Accents = []string{
"love", "gold", "rose", "pine", "foam", "iris",
}

var colorAliases = map[string]string{
"black": "overlay",
"brightBlack": "muted",
"red": "love",
"brightRed": "love",
"green": "pine",
"brightGreen": "pine",
"yellow": "gold",
"brightYellow": "gold",
"blue": "foam",
"brightBlue": "foam",
"magenta": "iris",
"brightMagenta": "iris",
"cyan": "rose",
"brightCyan": "rose",
"white": "text",
"brightWhite": "text",
}

var (
MainPalette = Palette{
Base: Color{
Expand Down Expand Up @@ -286,6 +305,10 @@ var Variants = []VariantMeta{
}

func (p *Palette) Get(role string) (*Color, bool) {
if aliasTarget, isAlias := colorAliases[role]; isAlias {
return p.Get(aliasTarget)
}

switch role {
case "base":
return &p.Base, true
Expand Down Expand Up @@ -369,5 +392,14 @@ func (p *Palette) Iter() iter.Seq2[string, *Color] {
if !yield("highlightHigh", &p.HighlightHigh) {
return
}

// Add aliases
for alias, target := range colorAliases {
if color, ok := p.Get(target); ok {
if !yield(alias, color) {
return
}
}
}
}
}