From 1209ca13107eba05b3fa52a6e1ac8c802ee11622 Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 19 Mar 2024 18:30:36 -0500 Subject: [PATCH] refactor(styles): Add styles.text --- indicator.go | 4 ++-- styles.go | 5 +++++ times.go | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/indicator.go b/indicator.go index 74d34c6..0d2b9cb 100644 --- a/indicator.go +++ b/indicator.go @@ -25,9 +25,9 @@ type IndicatorInfo struct { func (i IndicatorInfo) String() string { if i.duration == 0 { - return textStyle.Render(strings.Repeat(".", 30)) + return styles.text.Render(strings.Repeat(".", 30)) } - return fmt.Sprintf("%s %s", textStyle.Render(i.duration.String()), i.info) + return fmt.Sprintf("%s %s", styles.text.Render(i.duration.String()), i.info) } func initialIndicator(text string) Indicator { diff --git a/styles.go b/styles.go index 7d1dbfe..2e3238d 100644 --- a/styles.go +++ b/styles.go @@ -10,6 +10,7 @@ type Colors struct { } type Styles struct { + text lipgloss.Style } var colors = Colors{ @@ -26,3 +27,7 @@ var colors = Colors{ lipgloss.Color("#939ab7"), }, } + +var styles = Styles{ + text: lipgloss.NewStyle().Foreground(colors.surface[2]), +} diff --git a/times.go b/times.go index ec3e8eb..a21ccfe 100644 --- a/times.go +++ b/times.go @@ -59,8 +59,6 @@ func getTimeLogs(since time.Time, on_process_repo func(repo gitea.Repository, to return times } -var textStyle = lipgloss.NewStyle().Foreground(colors.surface[2]) - type timesviewer struct { table table.Model length int @@ -93,7 +91,7 @@ func (m timesviewer) View() string { Foreground(colors.overlay[0]). Bold(true) return m.table.View() + - textStyle.Render("\nUse Up and Down arrows to navigate") + + styles.text.Render("\nUse Up and Down arrows to navigate") + totalTextStyle.Render(fmt.Sprintf("\nTotal - %s\n", m.total_time.String())) }