From 174dcb9706aac695802c12314a7a58394bea176d Mon Sep 17 00:00:00 2001 From: Noah Date: Sun, 17 Mar 2024 22:27:11 -0500 Subject: [PATCH] refactor(colors): Add colors structure with all the needed colors (fix #7) --- colors.go | 25 +++++++++++++++++++++++++ indicator.go | 2 +- times.go | 12 ++++++------ 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 colors.go diff --git a/colors.go b/colors.go new file mode 100644 index 0000000..37bfc90 --- /dev/null +++ b/colors.go @@ -0,0 +1,25 @@ +package main + +import "github.com/charmbracelet/lipgloss" + +type Colors struct { + green lipgloss.Color + text lipgloss.Color + surface []lipgloss.Color + overlay []lipgloss.Color +} + +var colors = Colors{ + green: lipgloss.Color("#a6da95"), + text: lipgloss.Color("#cad3f5"), + surface: []lipgloss.Color{ + lipgloss.Color("#363a4f"), + lipgloss.Color("#494d64"), + lipgloss.Color("#5b6078"), + }, + overlay: []lipgloss.Color{ + lipgloss.Color("#6e738d"), + lipgloss.Color("#8087a2"), + lipgloss.Color("#939ab7"), + }, +} diff --git a/indicator.go b/indicator.go index 1cef0b5..e719d44 100644 --- a/indicator.go +++ b/indicator.go @@ -32,7 +32,7 @@ func (i IndicatorInfo) String() string { func initialIndicator() Indicator { s := spinner.New() s.Spinner = spinner.Dot - s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("#a6da95")) + s.Style = lipgloss.NewStyle().Foreground(colors.green) return Indicator{spinner: s} } func (m Indicator) Init() tea.Cmd { diff --git a/times.go b/times.go index aa8efd8..01f8f39 100644 --- a/times.go +++ b/times.go @@ -59,7 +59,7 @@ func getTimeLogs(since time.Time, on_process_repo func(repo gitea.Repository, to return times } -var textStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#5b6078")) +var textStyle = lipgloss.NewStyle().Foreground(colors.surface[2]) type timesviewer struct { table table.Model @@ -90,7 +90,7 @@ func (m timesviewer) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m timesviewer) View() string { var totalTextStyle = lipgloss.NewStyle(). - Foreground(lipgloss.Color("#6e738d")). + Foreground(colors.overlay[0]). Bold(true) return m.table.View() + textStyle.Render("\nUse Up and Down arrows to navigate") + @@ -152,14 +152,14 @@ func times() { ) s := table.DefaultStyles() s.Header = s.Header. - Foreground(lipgloss.Color("#6e738d")). + Foreground(colors.overlay[0]). BorderStyle(lipgloss.DoubleBorder()). - BorderForeground(lipgloss.Color("#a6da95")). + BorderForeground(colors.green). BorderBottom(true). Bold(false) s.Selected = s.Selected. - Foreground(lipgloss.Color("#494d64")). - Background(lipgloss.Color("#a6da95")). + Foreground(colors.surface[1]). + Background(colors.green). Bold(false) tab.SetStyles(s) tv.table = tab