tags.go (776B)
1 package tui 2 3 import ( 4 "strings" 5 6 "git.prime8.dev/moncheeta/prime8dev/internal/utils" 7 "github.com/charmbracelet/lipgloss" 8 ) 9 10 // untagged labels: reverse video in the dim color, readable in any theme 11 var tagDefaultStyle = lipgloss.NewStyle().Foreground(colorDim).Reverse(true).Padding(0, 1) 12 13 func renderTag(label string) string { 14 style := tagDefaultStyle 15 if t, ok := utils.LookupTag(label); ok { 16 style = lipgloss.NewStyle().Background(lipgloss.Color(t.BG)).Foreground(lipgloss.Color(t.FG)).Padding(0, 1) 17 } 18 return style.Render(label) 19 } 20 21 func renderTagList(labels []string) string { 22 out := make([]string, 0, len(labels)) 23 for _, label := range labels { 24 if strings.TrimSpace(label) != "" { 25 out = append(out, renderTag(label)) 26 } 27 } 28 return strings.Join(out, " ") 29 }