From 28fbdbd7ddb803609f587ae56d17c4766adabfa8 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:30:22 +0530 Subject: [PATCH 01/11] update cmd_root to include themes my following commits will be adding themes to chibi --- cmd/cmd_root.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/cmd_root.go b/cmd/cmd_root.go index eb4e0eb..a1d3be8 100644 --- a/cmd/cmd_root.go +++ b/cmd/cmd_root.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/CosmicPredator/chibi/internal/theme" "github.com/CosmicPredator/chibi/internal/ui" "github.com/charmbracelet/fang" "github.com/spf13/cobra" @@ -15,6 +16,12 @@ var rootCmd = &cobra.Command{ } func Execute(version string) { + if err := theme.Load(); err != nil { + fmt.Println(ui.ErrorText(err)) + return + } + applyThemeToMessageTemplates() + rootCmd.CompletionOptions.DisableDefaultCmd = true rootCmd.AddCommand( loginCmd, @@ -25,12 +32,13 @@ func Execute(version string) { mediaUpdateCmd, mediaAddCmd, mediaInfoCmd, + themeCmd, ) if err := fang.Execute( - context.TODO(), - rootCmd, + context.TODO(), + rootCmd, fang.WithVersion(version), - ); err != nil { + ); err != nil { fmt.Println(ui.ErrorText(err)) } } From 048cb45b42ccbc53ac8686e4ae2e9c6df47d3891 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:30:43 +0530 Subject: [PATCH 02/11] update profile --- internal/ui/profile.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/ui/profile.go b/internal/ui/profile.go index fe381ba..268363d 100644 --- a/internal/ui/profile.go +++ b/internal/ui/profile.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/CosmicPredator/chibi/internal" + "github.com/CosmicPredator/chibi/internal/theme" "github.com/charmbracelet/lipgloss" ) @@ -44,8 +45,9 @@ func (p *ProfileUI) Render() error { } // define styles for both key and value string - keyStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#FF79C6")) - valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#8BE9FD")) + palette := theme.Current() + keyStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(palette.KeyText)) + valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(palette.ValueText)) var sb strings.Builder @@ -54,13 +56,13 @@ func (p *ProfileUI) Render() error { for _, kv := range dataSlice { if internal.CanSupportKittyGP() { fmt.Fprintf(&sb, "%*s%s : %s\n", - 20, "", - keyStyle.MarginRight(maxKeyLen-len(kv.Key)).Render(kv.Key), - valueStyle.Render(kv.Value)) + 20, "", + keyStyle.MarginRight(maxKeyLen-len(kv.Key)).Render(kv.Key), + valueStyle.Render(kv.Value)) } else { fmt.Fprintf(&sb, "%s : %s\n", - keyStyle.MarginRight(maxKeyLen-len(kv.Key)).Render(kv.Key), - valueStyle.Render(kv.Value)) + keyStyle.MarginRight(maxKeyLen-len(kv.Key)).Render(kv.Key), + valueStyle.Render(kv.Value)) } } From 9d0cbabebc9652d3aab099fea01988149b21e3c8 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:30:49 +0530 Subject: [PATCH 03/11] update readme for themes --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index fa29c76..c3738d8 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,22 @@ $env:CHIBI_DATA_PATH = "D:\apps\chibi-data" chibi login ``` +### Themes +Chibi supports built-in themes for CLI colors. + +- Show active theme and available themes: + ```bash + chibi theme + ``` +- Persist a theme: + ```bash + chibi theme nord + ``` +- Temporarily override via environment variable: + ```bash + CHIBI_THEME=sunset chibi profile + ``` + ## Documentation You can check the docs [here](https://chibi-cli.pages.dev/). From aee09c744b1d02857570d64c9240e1e16c3ea9d0 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:31:29 +0530 Subject: [PATCH 04/11] update styles --- internal/ui/styles.go | 79 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/internal/ui/styles.go b/internal/ui/styles.go index 57dfa83..45f40e5 100644 --- a/internal/ui/styles.go +++ b/internal/ui/styles.go @@ -6,87 +6,84 @@ import ( "os" "time" + "github.com/CosmicPredator/chibi/internal/theme" "github.com/charmbracelet/lipgloss" ) -// displays text in green with ✓ on the left +// displays text in green with a check mark on the left func SuccessText(msg string) string { + palette := theme.Current() return lipgloss. NewStyle(). - Foreground(lipgloss.Color("#00FF00")). - Render("✓ " + msg) + Foreground(lipgloss.Color(palette.SuccessText)). + Render("\u2713 " + msg) } -// displays text in red with ✘ on the left +// displays text in red with a cross on the left func ErrorText(err error) string { + palette := theme.Current() return lipgloss. NewStyle(). - Foreground(lipgloss.Color("#CC0000")). - Render("✘ Someting went wrong! Reason: ", err.Error()) + Foreground(lipgloss.Color(palette.ErrorText)). + Render("\u2717 Someting went wrong! Reason: ", err.Error()) } // displays text in cyan foreground func HighlightedText(msg string) string { + palette := theme.Current() return lipgloss. NewStyle(). - Foreground(lipgloss.Color("#00FFFF")). + Foreground(lipgloss.Color(palette.HighlightText)). PaddingLeft(0). PaddingRight(0). Render(msg) } -// displays spinner while the supplied action -// func is getting executed -// func ActionSpinner(title string, action func(context.Context) error) error { -// return spinner. -// New(). -// Title(title). -// ActionWithErr(action). -// Run() -// } - +// displays spinner while the supplied action func is getting executed func ActionSpinner(title string, action func(context.Context) error) error { - done := make(chan bool) - go func() { + palette := theme.Current() + done := make(chan bool) + go func() { spinnerStyle := lipgloss. NewStyle(). - Foreground(lipgloss.ANSIColor(5)) - dots := []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"} - var styledDots []string = make([]string, 0) + Foreground(lipgloss.Color(palette.Spinner)) + dots := []string{"\u280b", "\u2819", "\u2839", "\u2838", "\u283c", "\u2834", "\u2826", "\u2827", "\u2807", "\u280f"} + styledDots := make([]string, 0, len(dots)) for _, character := range dots { styledDots = append(styledDots, spinnerStyle.Render(character)) } - i := 0 - for { - select { - case <-done: - fmt.Fprintf(os.Stderr, "\r\033[K") - return - default: - fmt.Fprintf(os.Stderr, "\r%s %s", styledDots[i], title) - time.Sleep(150 * time.Millisecond) - i = (i + 1) % len(dots) - } - } - }() - err := action(context.TODO()) - done <- true + i := 0 + for { + select { + case <-done: + fmt.Fprintf(os.Stderr, "\r\033[K") + return + default: + fmt.Fprintf(os.Stderr, "\r%s %s", styledDots[i], title) + time.Sleep(150 * time.Millisecond) + i = (i + 1) % len(dots) + } + } + }() + err := action(context.TODO()) + done <- true return err } func PrettyInput(title, defaultVal string, validatorFunc func(s string) error) (string, error) { + palette := theme.Current() if defaultVal == "" { defaultVal = "none" } formattedTitle := lipgloss. NewStyle(). - Foreground(lipgloss.ANSIColor(5)). + Foreground(lipgloss.Color(palette.PromptTitle)). Bold(true). Render(title) - + formattedDefaultVal := lipgloss. NewStyle(). - Foreground(lipgloss.ANSIColor(1)). + Foreground(lipgloss.Color(palette.PromptDefault)). Bold(true). Render(fmt.Sprintf("Default: %s", defaultVal)) prompt := fmt.Sprintf("%s (%s): ", formattedTitle, formattedDefaultVal) @@ -95,4 +92,4 @@ func PrettyInput(title, defaultVal string, validatorFunc func(s string) error) ( fmt.Scanln(&value) err := validatorFunc(value) return value, err -} \ No newline at end of file +} From d04c9237a6e73a6e4196d7ec75af0981cc61c64e Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:31:40 +0530 Subject: [PATCH 05/11] update media search inclusion of themes --- internal/ui/media_search.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/ui/media_search.go b/internal/ui/media_search.go index 8ad9812..6da5d50 100644 --- a/internal/ui/media_search.go +++ b/internal/ui/media_search.go @@ -7,6 +7,7 @@ import ( "github.com/CosmicPredator/chibi/internal" "github.com/CosmicPredator/chibi/internal/api/responses" + "github.com/CosmicPredator/chibi/internal/theme" "github.com/charmbracelet/lipgloss" ) @@ -15,13 +16,14 @@ type MediaSearchUI struct { } type MediaSearchResult struct { - Id string - Title string + Id string + Title string Format string - Score string + Score string } func (l *MediaSearchUI) renderColumn(entries ...*MediaSearchResult) string { + palette := theme.Current() col := func(w int) lipgloss.Style { return lipgloss.NewStyle().Width(w).MarginRight(2).Align(lipgloss.Right) } @@ -33,8 +35,8 @@ func (l *MediaSearchUI) renderColumn(entries ...*MediaSearchResult) string { col(0), } - headerStyle := func (style lipgloss.Style) lipgloss.Style { - return style.MarginBottom(1).Underline(true).Bold(true).Foreground(lipgloss.ANSIColor(5)) + headerStyle := func(style lipgloss.Style) lipgloss.Style { + return style.MarginBottom(1).Underline(true).Bold(true).Foreground(lipgloss.Color(palette.TableHeader)) } var sb strings.Builder @@ -48,9 +50,9 @@ func (l *MediaSearchUI) renderColumn(entries ...*MediaSearchResult) string { sb.WriteString(lipgloss.JoinHorizontal(lipgloss.Top, header...) + "\n") for _, entry := range entries { row := []string{ - styles[0].Foreground(lipgloss.ANSIColor(6)).Render(entry.Id), - styles[1].Foreground(lipgloss.ANSIColor(2)).Render(entry.Format), - styles[2].Foreground(lipgloss.ANSIColor(3)).Render(entry.Score), + styles[0].Foreground(lipgloss.Color(palette.TableID)).Render(entry.Id), + styles[1].Foreground(lipgloss.Color(palette.TableFormat)).Render(entry.Format), + styles[2].Foreground(lipgloss.Color(palette.TableMetric)).Render(entry.Score), styles[3].Render(entry.Title), } sb.WriteString(lipgloss.JoinHorizontal(lipgloss.Top, row...) + "\n") @@ -72,10 +74,10 @@ func (ms *MediaSearchUI) Render() error { } rows = append(rows, &MediaSearchResult{ - Id: strconv.Itoa(media.Id), - Title: media.Title.UserPreferred, + Id: strconv.Itoa(media.Id), + Title: media.Title.UserPreferred, Format: internal.MediaFormatFormatter(media.MediaFormat), - Score: averageScore, + Score: averageScore, }) } From a726f82d85e5a08575663f942c0ec10bea79fb62 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:31:46 +0530 Subject: [PATCH 06/11] create tests for themes --- internal/theme/theme_test.go | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 internal/theme/theme_test.go diff --git a/internal/theme/theme_test.go b/internal/theme/theme_test.go new file mode 100644 index 0000000..590dba7 --- /dev/null +++ b/internal/theme/theme_test.go @@ -0,0 +1,82 @@ +package theme + +import ( + "testing" + + "github.com/CosmicPredator/chibi/internal" +) + +func resetDefaultTheme(t *testing.T) { + t.Helper() + if err := SetCurrent("default"); err != nil { + t.Fatalf("unable to reset theme: %v", err) + } +} + +func TestSetCurrentCaseInsensitive(t *testing.T) { + resetDefaultTheme(t) + defer resetDefaultTheme(t) + + if err := SetCurrent("NoRd"); err != nil { + t.Fatalf("SetCurrent returned error: %v", err) + } + + if got, want := CurrentName(), "nord"; got != want { + t.Fatalf("CurrentName() = %q, want %q", got, want) + } +} + +func TestSetCurrentUnknownTheme(t *testing.T) { + resetDefaultTheme(t) + defer resetDefaultTheme(t) + + if err := SetCurrent("unknown"); err == nil { + t.Fatalf("SetCurrent should fail for unknown theme") + } +} + +func TestSaveAndLoadPersistedTheme(t *testing.T) { + resetDefaultTheme(t) + defer resetDefaultTheme(t) + + t.Setenv(internal.DATA_PATH_ENV, t.TempDir()) + t.Setenv(ThemeEnvName, "") + + if err := Save("sunset"); err != nil { + t.Fatalf("Save returned error: %v", err) + } + if err := SetCurrent("default"); err != nil { + t.Fatalf("SetCurrent returned error: %v", err) + } + + if err := Load(); err != nil { + t.Fatalf("Load returned error: %v", err) + } + + if got, want := CurrentName(), "sunset"; got != want { + t.Fatalf("CurrentName() = %q, want %q", got, want) + } +} + +func TestEnvThemeOverridesPersistedTheme(t *testing.T) { + resetDefaultTheme(t) + defer resetDefaultTheme(t) + + t.Setenv(internal.DATA_PATH_ENV, t.TempDir()) + t.Setenv(ThemeEnvName, "nord") + + if err := Save("sunset"); err != nil { + t.Fatalf("Save returned error: %v", err) + } + if err := SetCurrent("default"); err != nil { + t.Fatalf("SetCurrent returned error: %v", err) + } + + if err := Load(); err != nil { + t.Fatalf("Load returned error: %v", err) + } + + if got, want := CurrentName(), "nord"; got != want { + t.Fatalf("CurrentName() = %q, want %q", got, want) + } +} From 35ec44549bed59b0059739ed34157c708cb80ab1 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:31:51 +0530 Subject: [PATCH 07/11] update constants for themes --- cmd/constants.go | 67 ++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/cmd/constants.go b/cmd/constants.go index acd4de5..b85a945 100644 --- a/cmd/constants.go +++ b/cmd/constants.go @@ -1,27 +1,44 @@ package cmd -import "github.com/charmbracelet/lipgloss" - -var ERROR_MESSAGE_TEMPLATE = lipgloss. - NewStyle(). - BorderStyle(lipgloss.RoundedBorder()). - BorderForeground(lipgloss.Color("#FF0000")). - PaddingLeft(1). - PaddingRight(1). - Foreground(lipgloss.Color("#FF0000")) - -var SUCCESS_MESSAGE_TEMPLATE = lipgloss. - NewStyle(). - BorderStyle(lipgloss.RoundedBorder()). - BorderForeground(lipgloss.Color("#00FF00")). - Foreground(lipgloss.Color("#00FF00")). - PaddingLeft(1). - PaddingRight(1) - -var OTHER_MESSAGE_TEMPLATE = lipgloss. - NewStyle(). - BorderStyle(lipgloss.RoundedBorder()). - BorderForeground(lipgloss.Color("#00FFFF")). - Foreground(lipgloss.Color("#00FFFF")). - PaddingLeft(1). - PaddingRight(1) +import ( + "github.com/CosmicPredator/chibi/internal/theme" + "github.com/charmbracelet/lipgloss" +) + +var ERROR_MESSAGE_TEMPLATE lipgloss.Style + +var SUCCESS_MESSAGE_TEMPLATE lipgloss.Style + +var OTHER_MESSAGE_TEMPLATE lipgloss.Style + +func applyThemeToMessageTemplates() { + palette := theme.Current() + + ERROR_MESSAGE_TEMPLATE = lipgloss. + NewStyle(). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(lipgloss.Color(palette.MessageError)). + PaddingLeft(1). + PaddingRight(1). + Foreground(lipgloss.Color(palette.MessageError)) + + SUCCESS_MESSAGE_TEMPLATE = lipgloss. + NewStyle(). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(lipgloss.Color(palette.MessageSuccess)). + Foreground(lipgloss.Color(palette.MessageSuccess)). + PaddingLeft(1). + PaddingRight(1) + + OTHER_MESSAGE_TEMPLATE = lipgloss. + NewStyle(). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(lipgloss.Color(palette.MessageOther)). + Foreground(lipgloss.Color(palette.MessageOther)). + PaddingLeft(1). + PaddingRight(1) +} + +func init() { + applyThemeToMessageTemplates() +} From 4efcb732adffafaf39f6def69af122d037204331 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:31:56 +0530 Subject: [PATCH 08/11] create theme command --- cmd/cmd_theme.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cmd/cmd_theme.go diff --git a/cmd/cmd_theme.go b/cmd/cmd_theme.go new file mode 100644 index 0000000..a748d05 --- /dev/null +++ b/cmd/cmd_theme.go @@ -0,0 +1,34 @@ +package cmd + +import ( + "fmt" + "strings" + + "github.com/CosmicPredator/chibi/internal/theme" + "github.com/CosmicPredator/chibi/internal/ui" + "github.com/spf13/cobra" +) + +func handleTheme(_ *cobra.Command, args []string) { + if len(args) == 0 { + fmt.Printf("Current theme: %s\n", theme.CurrentName()) + fmt.Printf("Available themes: %s\n", strings.Join(theme.Available(), ", ")) + fmt.Println("Set a theme with: chibi theme ") + return + } + + if err := theme.Save(args[0]); err != nil { + fmt.Println(ui.ErrorText(err)) + return + } + + applyThemeToMessageTemplates() + fmt.Println(ui.SuccessText(fmt.Sprintf("Theme set to %s", theme.CurrentName()))) +} + +var themeCmd = &cobra.Command{ + Use: "theme [name]", + Short: "Show or set the active color theme", + Args: cobra.MaximumNArgs(1), + Run: handleTheme, +} From 73174e2fc6b9cb789ea7bdc6954c911f764e4490 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:32:03 +0530 Subject: [PATCH 09/11] create theme core logic --- internal/theme/theme.go | 193 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 internal/theme/theme.go diff --git a/internal/theme/theme.go b/internal/theme/theme.go new file mode 100644 index 0000000..7e2ff74 --- /dev/null +++ b/internal/theme/theme.go @@ -0,0 +1,193 @@ +package theme + +import ( + "context" + "database/sql" + "errors" + "fmt" + "os" + "sort" + "strings" + "sync" + + "github.com/CosmicPredator/chibi/internal/kvdb" +) + +const ( + ThemeEnvName = "CHIBI_THEME" + themeKey = "theme" +) + +type Palette struct { + SuccessText string + ErrorText string + HighlightText string + + Spinner string + PromptTitle string + PromptDefault string + + KeyText string + ValueText string + + TableHeader string + TableID string + TableFormat string + TableMetric string + TableRepeating string + + MessageError string + MessageSuccess string + MessageOther string +} + +var palettes = map[string]Palette{ + "default": { + SuccessText: "#00FF00", + ErrorText: "#CC0000", + HighlightText: "#00FFFF", + Spinner: "5", + PromptTitle: "5", + PromptDefault: "1", + KeyText: "#FF79C6", + ValueText: "#8BE9FD", + TableHeader: "5", + TableID: "6", + TableFormat: "2", + TableMetric: "3", + TableRepeating: "4", + MessageError: "#FF0000", + MessageSuccess: "#00FF00", + MessageOther: "#00FFFF", + }, + "nord": { + SuccessText: "#A3BE8C", + ErrorText: "#BF616A", + HighlightText: "#88C0D0", + Spinner: "#81A1C1", + PromptTitle: "#81A1C1", + PromptDefault: "#D08770", + KeyText: "#B48EAD", + ValueText: "#8FBCBB", + TableHeader: "#81A1C1", + TableID: "#88C0D0", + TableFormat: "#A3BE8C", + TableMetric: "#EBCB8B", + TableRepeating: "#5E81AC", + MessageError: "#BF616A", + MessageSuccess: "#A3BE8C", + MessageOther: "#88C0D0", + }, + "sunset": { + SuccessText: "#43A047", + ErrorText: "#E53935", + HighlightText: "#00ACC1", + Spinner: "#FB8C00", + PromptTitle: "#FB8C00", + PromptDefault: "#F4511E", + KeyText: "#8E24AA", + ValueText: "#039BE5", + TableHeader: "#FB8C00", + TableID: "#1E88E5", + TableFormat: "#43A047", + TableMetric: "#FDD835", + TableRepeating: "#3949AB", + MessageError: "#E53935", + MessageSuccess: "#43A047", + MessageOther: "#00ACC1", + }, +} + +var ( + mu sync.RWMutex + current = "default" +) + +func normalizeThemeName(name string) string { + return strings.TrimSpace(strings.ToLower(name)) +} + +func Current() Palette { + mu.RLock() + defer mu.RUnlock() + return palettes[current] +} + +func CurrentName() string { + mu.RLock() + defer mu.RUnlock() + return current +} + +func Available() []string { + out := make([]string, 0, len(palettes)) + for name := range palettes { + out = append(out, name) + } + sort.Strings(out) + return out +} + +func SetCurrent(name string) error { + normalized := normalizeThemeName(name) + if normalized == "" { + return errors.New("theme name cannot be empty") + } + if _, ok := palettes[normalized]; !ok { + return fmt.Errorf( + "unknown theme %q (available: %s)", + name, + strings.Join(Available(), ", "), + ) + } + + mu.Lock() + current = normalized + mu.Unlock() + return nil +} + +func Save(name string) error { + if err := SetCurrent(name); err != nil { + return err + } + + db, err := kvdb.Open() + if err != nil { + return err + } + defer db.Close() + + return db.Set(context.TODO(), themeKey, []byte(CurrentName())) +} + +func Load() error { + if envTheme := strings.TrimSpace(os.Getenv(ThemeEnvName)); envTheme != "" { + return SetCurrent(envTheme) + } + + db, err := kvdb.Open() + if err != nil { + return nil + } + defer db.Close() + + rawTheme, err := db.Get(context.TODO(), themeKey) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil + } + return nil + } + + name := strings.TrimSpace(string(rawTheme)) + if name == "" { + return nil + } + + // Ignore stale values from old/invalid config and fallback to default. + if err := SetCurrent(name); err != nil { + return nil + } + return nil +} From 8551270fdac9793f264e5bb1acb49261aa58399f Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:32:12 +0530 Subject: [PATCH 10/11] update media list inclusion of themes --- internal/ui/media_list.go | 43 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/internal/ui/media_list.go b/internal/ui/media_list.go index 103e28b..62095e4 100644 --- a/internal/ui/media_list.go +++ b/internal/ui/media_list.go @@ -7,6 +7,7 @@ import ( "github.com/CosmicPredator/chibi/internal" "github.com/CosmicPredator/chibi/internal/api/responses" + "github.com/CosmicPredator/chibi/internal/theme" "github.com/charmbracelet/lipgloss" ) @@ -16,18 +17,19 @@ type MediaListUI struct { } type MediaListEntry struct { - Id string - Title string - Format string - Progress string + Id string + Title string + Format string + Progress string NextEpEpoch int64 } func (l *MediaListUI) renderColumn(mediaType internal.MediaType, entries ...*MediaListEntry) string { + palette := theme.Current() col := func(w int) lipgloss.Style { return lipgloss.NewStyle().Width(w).MarginRight(2).Align(lipgloss.Right) } - + epFormatCol := func() string { if mediaType == internal.ANIME { return "NEXT EP IN" @@ -35,7 +37,7 @@ func (l *MediaListUI) renderColumn(mediaType internal.MediaType, entries ...*Med return "FORMAT" } }() - + epFormatValue := func(entry *MediaListEntry) string { if mediaType == internal.ANIME { return internal.FormatAiringTs(entry.NextEpEpoch) @@ -51,8 +53,8 @@ func (l *MediaListUI) renderColumn(mediaType internal.MediaType, entries ...*Med col(0), } - headerStyle := func (style lipgloss.Style) lipgloss.Style { - return style.MarginBottom(1).Underline(true).Bold(true).Foreground(lipgloss.ANSIColor(5)) + headerStyle := func(style lipgloss.Style) lipgloss.Style { + return style.MarginBottom(1).Underline(true).Bold(true).Foreground(lipgloss.Color(palette.TableHeader)) } var sb strings.Builder @@ -66,9 +68,9 @@ func (l *MediaListUI) renderColumn(mediaType internal.MediaType, entries ...*Med sb.WriteString(lipgloss.JoinHorizontal(lipgloss.Top, header...) + "\n") for _, entry := range entries { row := []string{ - styles[0].Foreground(lipgloss.ANSIColor(6)).Render(entry.Id), - styles[1].Foreground(lipgloss.ANSIColor(2)).Render(epFormatValue(entry)), - styles[2].Foreground(lipgloss.ANSIColor(3)).Render(entry.Progress), + styles[0].Foreground(lipgloss.Color(palette.TableID)).Render(entry.Id), + styles[1].Foreground(lipgloss.Color(palette.TableFormat)).Render(epFormatValue(entry)), + styles[2].Foreground(lipgloss.Color(palette.TableMetric)).Render(entry.Progress), styles[3].Render(entry.Title), } sb.WriteString(lipgloss.JoinHorizontal(lipgloss.Top, row...) + "\n") @@ -78,6 +80,7 @@ func (l *MediaListUI) renderColumn(mediaType internal.MediaType, entries ...*Med } func (l *MediaListUI) Render() error { + palette := theme.Current() var rows []*MediaListEntry = make([]*MediaListEntry, 0) var selectedList responses.ListCollection @@ -89,9 +92,9 @@ func (l *MediaListUI) Render() error { for _, list := range selectedList.Lists { if list.Status != "CURRENT" && list.Status != "REPEATING" { - continue - } - + continue + } + for _, entry := range list.Entries { var progress string @@ -117,15 +120,15 @@ func (l *MediaListUI) Render() error { if list.Status == "REPEATING" { entry.Media.Title.UserPreferred = lipgloss. NewStyle(). - Foreground(lipgloss.ANSIColor(4)). + Foreground(lipgloss.Color(palette.TableRepeating)). Render("(R) ") + entry.Media.Title.UserPreferred } rows = append(rows, &MediaListEntry{ - Id: strconv.Itoa(entry.Media.Id), - Title: entry.Media.Title.UserPreferred, - Format: internal.MediaFormatFormatter(entry.Media.MediaFormat), - Progress: progress, + Id: strconv.Itoa(entry.Media.Id), + Title: entry.Media.Title.UserPreferred, + Format: internal.MediaFormatFormatter(entry.Media.MediaFormat), + Progress: progress, NextEpEpoch: entry.Media.NextAiringEpisode.AiringAt, }) } @@ -133,4 +136,4 @@ func (l *MediaListUI) Render() error { fmt.Println(l.renderColumn(internal.MediaType(l.MediaType), rows...)) return nil -} \ No newline at end of file +} From 529e1fd8d4c7b97ef9db5766f4829884c4ac1900 Mon Sep 17 00:00:00 2001 From: Aarav Maloo Date: Sun, 22 Feb 2026 16:32:22 +0530 Subject: [PATCH 11/11] update media info inclusion of themes --- internal/ui/media_info.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/ui/media_info.go b/internal/ui/media_info.go index 9f87cf5..15eb760 100644 --- a/internal/ui/media_info.go +++ b/internal/ui/media_info.go @@ -5,6 +5,7 @@ import ( "strconv" "strings" + "github.com/CosmicPredator/chibi/internal/theme" "github.com/charmbracelet/lipgloss" "github.com/muesli/reflow/wordwrap" ) @@ -54,8 +55,9 @@ func (m *MediaInfoUI) Render() error { sep := " : " valueIndent := strings.Repeat(" ", maxKeyLen+len(sep)) - keyStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#FF79C6")) - valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#8BE9FD")) + palette := theme.Current() + keyStyle := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(palette.KeyText)) + valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(palette.ValueText)) var sb strings.Builder for _, kv := range dataSlice {