style.go (view raw)
1package main
2
3import (
4 "hash/fnv"
5
6 "github.com/charmbracelet/lipgloss"
7
8 catppuccin "github.com/catppuccin/go"
9)
10
11var Catppuccin catppuccin.Flavor = catppuccin.Mocha
12
13var catppuccinColors []string = []string{
14 Catppuccin.Red().Hex,
15 Catppuccin.Green().Hex,
16 Catppuccin.Yellow().Hex,
17 Catppuccin.Blue().Hex,
18 Catppuccin.Mauve().Hex,
19 Catppuccin.Pink().Hex,
20 Catppuccin.Flamingo().Hex,
21 Catppuccin.Teal().Hex,
22 Catppuccin.Sky().Hex,
23 Catppuccin.Sapphire().Hex,
24 Catppuccin.Maroon().Hex,
25 Catppuccin.Peach().Hex,
26 Catppuccin.Rosewater().Hex,
27 Catppuccin.Lavender().Hex,
28}
29
30var (
31 textStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(Catppuccin.Text().Hex))
32 datetimeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(Catppuccin.Subtext0().Hex))
33 summaryStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(Catppuccin.Lavender().Hex))
34 bodyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(Catppuccin.Text().Hex))
35)
36
37func getAppNameStyle(appName string) lipgloss.Style {
38 color := deterministicRandomString(appName, catppuccinColors)
39 return lipgloss.NewStyle().Background(lipgloss.Color(color)).Foreground(lipgloss.Color(Catppuccin.Base().Hex)).Padding(0, 1)
40}
41
42func deterministicRandomString(key string, array []string) string {
43 hasher := fnv.New32a()
44 hasher.Write([]byte(key))
45 hashValue := hasher.Sum32()
46
47 index := int(hashValue) % len(array)
48 return array[index]
49}