Fix UDA colors

This commit is contained in:
Martin
2024-05-31 13:40:49 +02:00
parent 035d09900e
commit 9aa7b04b98
8 changed files with 110 additions and 39 deletions

View File

@ -15,6 +15,7 @@ type Common struct {
TW taskwarrior.TaskWarrior
Keymap *Keymap
Styles *Styles
Udas []string
pageStack *Stack[Component]
width int
@ -27,6 +28,7 @@ func NewCommon(ctx context.Context, tw taskwarrior.TaskWarrior) *Common {
TW: tw,
Keymap: NewKeymap(),
Styles: NewStyles(tw.GetConfig()),
Udas: tw.GetUdas(),
pageStack: NewStack[Component](),
}

View File

@ -29,6 +29,8 @@ type Styles struct {
ColumnBlurred lipgloss.Style
ColumnInsert lipgloss.Style
Colors map[string]lipgloss.Style
// TODO: make color config completely dynamic to account for keyword., project., tag. and uda. colors
Active lipgloss.Style
Alternate lipgloss.Style
@ -114,10 +116,12 @@ func NewStyles(config *taskwarrior.TWConfig) *Styles {
func parseColors(config map[string]string) *Styles {
styles := Styles{}
colors := make(map[string]lipgloss.Style)
for key, value := range config {
if strings.HasPrefix(key, "color.") {
_, colorValue, _ := strings.Cut(key, ".")
colors[colorValue] = parseColorString(value)
switch colorValue {
case "active":
styles.Active = parseColorString(value)
@ -217,6 +221,8 @@ func parseColors(config map[string]string) *Styles {
}
}
styles.Colors = colors
return &styles
}