From 890b5acdd12bac368eda9732aab23f7a7589e1eb Mon Sep 17 00:00:00 2001 From: mistakenelf Date: Tue, 26 Mar 2024 19:48:53 -0400 Subject: [PATCH] feat: created shared color library polish --- code/code.go | 3 ++- filetree/update.go | 3 ++- image/image.go | 4 +++- internal/tui/commands.go | 3 ++- markdown/markdown.go | 3 ++- pdf/pdf.go | 3 ++- polish/polish.go | 11 +++++++++++ 7 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 polish/polish.go diff --git a/code/code.go b/code/code.go index dffddb7..9c4dc45 100644 --- a/code/code.go +++ b/code/code.go @@ -14,6 +14,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/mistakenelf/fm/filesystem" + "github.com/mistakenelf/fm/polish" ) type syntaxMsg string @@ -148,7 +149,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { m.Filename = "" cmds = append(cmds, m.NewStatusMessageCmd( lipgloss.NewStyle(). - Foreground(lipgloss.Color("#cc241d")). + Foreground(polish.Colors.Red600). Bold(true). Render(string(msg)), )) diff --git a/filetree/update.go b/filetree/update.go index ce62b3e..57ffd57 100644 --- a/filetree/update.go +++ b/filetree/update.go @@ -8,6 +8,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/mistakenelf/fm/filesystem" + "github.com/mistakenelf/fm/polish" ) func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { @@ -26,7 +27,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { case errorMsg: cmds = append(cmds, m.NewStatusMessageCmd( lipgloss.NewStyle(). - Foreground(lipgloss.Color("#cc241d")). + Foreground(polish.Colors.Red600). Bold(true). Render(string(msg)))) case statusMessageTimeoutMsg: diff --git a/image/image.go b/image/image.go index 5d9b9d8..3128cb1 100644 --- a/image/image.go +++ b/image/image.go @@ -14,6 +14,8 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/disintegration/imaging" "github.com/lucasb-eyer/go-colorful" + + "github.com/mistakenelf/fm/polish" ) type convertImageToStringMsg string @@ -164,7 +166,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { case errorMsg: cmds = append(cmds, m.NewStatusMessageCmd( lipgloss.NewStyle(). - Foreground(lipgloss.Color("#cc241d")). + Foreground(polish.Colors.Red600). Bold(true). Render(string(msg)), )) diff --git a/internal/tui/commands.go b/internal/tui/commands.go index 94614f4..0db96e6 100644 --- a/internal/tui/commands.go +++ b/internal/tui/commands.go @@ -5,6 +5,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/mistakenelf/fm/polish" ) var forbiddenExtensions = []string{ @@ -47,7 +48,7 @@ func (m *model) openFileCmd() tea.Cmd { return m.pdf.SetFileNameCmd(selectedFile.Path) case contains(forbiddenExtensions, selectedFile.Extension): return m.newStatusMessageCmd(lipgloss.NewStyle(). - Foreground(lipgloss.Color("#cc241d")). + Foreground(polish.Colors.Red600). Bold(true). Render("Selected file type is not supported")) default: diff --git a/markdown/markdown.go b/markdown/markdown.go index 11e5afe..8561c3e 100644 --- a/markdown/markdown.go +++ b/markdown/markdown.go @@ -12,6 +12,7 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/mistakenelf/fm/filesystem" + "github.com/mistakenelf/fm/polish" ) type renderMarkdownMsg string @@ -154,7 +155,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { m.FileName = "" cmds = append(cmds, m.NewStatusMessageCmd( lipgloss.NewStyle(). - Foreground(lipgloss.Color("#cc241d")). + Foreground(polish.Colors.Red600). Bold(true). Render(string(msg)), )) diff --git a/pdf/pdf.go b/pdf/pdf.go index df89a6d..327cc05 100644 --- a/pdf/pdf.go +++ b/pdf/pdf.go @@ -11,6 +11,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/ledongthuc/pdf" + "github.com/mistakenelf/fm/polish" ) type renderPDFMsg string @@ -149,7 +150,7 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { m.FileName = "" cmds = append(cmds, m.NewStatusMessageCmd( lipgloss.NewStyle(). - Foreground(lipgloss.Color("#cc241d")). + Foreground(polish.Colors.Red600). Bold(true). Render(string(msg)), )) diff --git a/polish/polish.go b/polish/polish.go new file mode 100644 index 0000000..6bcce93 --- /dev/null +++ b/polish/polish.go @@ -0,0 +1,11 @@ +package polish + +import "github.com/charmbracelet/lipgloss" + +type ColorMap struct { + Red600 lipgloss.Color +} + +var Colors = ColorMap{ + Red600: lipgloss.Color("#dc2626"), +}