From fa4f09a413c80a122a92a4827f3779070c8edac2 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 7 Jul 2022 17:46:22 -0400 Subject: [PATCH] feat: Default accent color is `212` (Bubble Gum Pink) --- answer.txt | 1 + examples/demo.sh | 4 ++-- input/command.go | 3 +++ input/options.go | 2 ++ progress/command.go | 2 +- progress/options.go | 10 ++++++---- search/command.go | 12 +++++++----- search/options.go | 12 +++++++----- search/search.go | 20 +++++++++++--------- spin/options.go | 4 ++-- write/command.go | 5 +++++ write/options.go | 8 +++++--- 12 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 answer.txt diff --git a/answer.txt b/answer.txt new file mode 100644 index 0000000..5cac9ff --- /dev/null +++ b/answer.txt @@ -0,0 +1 @@ +I love Bubble Gum <3 diff --git a/examples/demo.sh b/examples/demo.sh index 2b5e1c7..fc3f79d 100755 --- a/examples/demo.sh +++ b/examples/demo.sh @@ -14,7 +14,7 @@ echo "Wait a moment, while I think of my favorite color..." gum spin --title "Thinking..." --color 212 -- sleep 3 -echo "I like $(gum style --background $COLOR $COLOR), too. In fact, it's my $(gum style --background $COLOR 'favorite color!')" +echo "I like $(gum style --padding "0 1" --background $COLOR $COLOR), too. In fact, it's my $(gum style --padding "0 1" --background $COLOR 'favorite color!')" sleep 1 @@ -24,7 +24,7 @@ sleep 1 echo "What's your favorite Gum flavor?" -GUM=$(gum search --accent-color 212 << FLAVORS +GUM=$(gum search << FLAVORS Cherry Grape Lime diff --git a/input/command.go b/input/command.go index 5c7c661..4bfabf7 100644 --- a/input/command.go +++ b/input/command.go @@ -6,6 +6,7 @@ import ( "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" ) // Run provides a shell script interface for the text input bubble. @@ -17,6 +18,8 @@ func (o Options) Run() { i.Prompt = o.Prompt i.Placeholder = o.Placeholder i.Width = o.Width + i.PromptStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(o.PromptColor)) + i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(o.CursorColor)) p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr)) m, _ := p.StartReturningModel() diff --git a/input/options.go b/input/options.go index 66175e6..4abfdd8 100644 --- a/input/options.go +++ b/input/options.go @@ -2,7 +2,9 @@ package input // Options are the customization options for the input. type Options struct { + CursorColor string `help:"Color of prompt" default:"212"` Placeholder string `help:"Placeholder value" default:"Type something..."` Prompt string `help:"Prompt to display" default:"> "` + PromptColor string `help:"Color of prompt" default:"7"` Width int `help:"Input width" default:"20"` } diff --git a/progress/command.go b/progress/command.go index 6db6198..468b8ad 100644 --- a/progress/command.go +++ b/progress/command.go @@ -10,7 +10,7 @@ import ( // Run runs the progress command. func (o Options) Run() { p := progress.New( - progress.WithDefaultGradient(), + progress.WithGradient(o.ColorStart, o.ColorEnd), progress.WithSpringOptions(o.Frequency, o.Damping), ) m := model{ diff --git a/progress/options.go b/progress/options.go index 55c5e2a..2c12b6b 100644 --- a/progress/options.go +++ b/progress/options.go @@ -4,8 +4,10 @@ import "time" // Options is the available options for the progress command. type Options struct { - Damping float64 `help:"Damping of the spring animation." default:"0.9"` - Frequency float64 `help:"Frequency of the spring animation." default:"10.0"` - Increment float64 `help:"The percentage to increment the progress bar per tick." default:"0.1"` - Interval time.Duration `help:"The interval of time to wait before incrementing." default:"100ms"` + ColorEnd string `help:"The end color of the progress bar gradient." default:"#EE6FF8"` + ColorStart string `help:"The start color of the progress bar gradient." default:"#5A56E0"` + Damping float64 `help:"Damping of the spring animation." default:"0.9"` + Frequency float64 `help:"Frequency of the spring animation." default:"10.0"` + Increment float64 `help:"The percentage to increment the progress bar per tick." default:"0.1"` + Interval time.Duration `help:"The interval of time to wait before incrementing." default:"100ms"` } diff --git a/search/command.go b/search/command.go index 9f72668..b64cacf 100644 --- a/search/command.go +++ b/search/command.go @@ -19,7 +19,7 @@ func (o Options) Run() { i.Focus() i.Prompt = o.Prompt - i.PromptStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(o.AccentColor)) + i.PromptStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(o.PromptColor)) i.Placeholder = o.Placeholder i.Width = o.Width @@ -31,10 +31,12 @@ func (o Options) Run() { choices := strings.Split(string(input), "\n") p := tea.NewProgram(model{ - textinput: i, - choices: choices, - matches: matchAll(choices), - indicator: o.Indicator, + textinput: i, + choices: choices, + matches: matchAll(choices), + indicator: o.Indicator, + highlightStyle: lipgloss.NewStyle().Foreground(lipgloss.Color(o.HighlightColor)), + indicatorStyle: lipgloss.NewStyle().Foreground(lipgloss.Color(o.IndicatorColor)), }, tea.WithOutput(os.Stderr)) tm, _ := p.StartReturningModel() diff --git a/search/options.go b/search/options.go index 7cea70a..60cbc69 100644 --- a/search/options.go +++ b/search/options.go @@ -2,9 +2,11 @@ package search // Options is the customization options for the search. type Options struct { - AccentColor string `help:"Accent color for prompt, indicator, and matches" default:"#FF06B7"` - Indicator string `help:"Character for selection" default:"•"` - Placeholder string `help:"Placeholder value" default:"Search..."` - Prompt string `help:"Prompt to display" default:"> "` - Width int `help:"Input width" default:"20"` + HighlightColor string `help:"Color for highlighted matches" default:"212"` + Indicator string `help:"Character for selection" default:"•"` + IndicatorColor string `help:"Color for indicator" default:"212"` + Placeholder string `help:"Placeholder value" default:"Search..."` + Prompt string `help:"Prompt to display" default:"> "` + PromptColor string `help:"Color for prompt" default:"240"` + Width int `help:"Input width" default:"20"` } diff --git a/search/search.go b/search/search.go index b4949f4..4504170 100644 --- a/search/search.go +++ b/search/search.go @@ -11,13 +11,15 @@ import ( ) type model struct { - textinput textinput.Model - choices []string - matches []fuzzy.Match - selected int - indicator string - height int - quitting bool + textinput textinput.Model + choices []string + matches []fuzzy.Match + selected int + indicator string + height int + quitting bool + highlightStyle lipgloss.Style + indicatorStyle lipgloss.Style } func (m model) Init() tea.Cmd { return nil } @@ -35,7 +37,7 @@ func (m model) View() string { // If this is the current selected index, we add a small indicator to // represent it. Otherwise, simply pad the string. if i == m.selected { - s.WriteString(m.textinput.PromptStyle.Render(m.indicator) + " ") + s.WriteString(m.indicatorStyle.Render(m.indicator) + " ") } else { s.WriteString(strings.Repeat(" ", runewidth.StringWidth(m.indicator)) + " ") } @@ -48,7 +50,7 @@ func (m model) View() string { // Check if the current character index matches the current matched // index. If so, color the character to indicate a match. if mi < len(match.MatchedIndexes) && ci == match.MatchedIndexes[mi] { - s.WriteString(m.textinput.PromptStyle.Render(string(c))) + s.WriteString(m.highlightStyle.Render(string(c))) // We have matched this character, so we never have to check it // again. Move on to the next match. mi++ diff --git a/spin/options.go b/spin/options.go index fc4dc95..8200337 100644 --- a/spin/options.go +++ b/spin/options.go @@ -4,7 +4,7 @@ package spin type Options struct { Command []string `arg:"" help:"Command to run"` - Color string `help:"Spinner color" default:"#FF06B7"` - Title string `help:"Text to display to user while spinning" default:"Loading..."` + Color string `help:"Spinner color" default:"212"` Spinner string `help:"Spinner type" type:"spinner" enum:"line,dot,minidot,jump,pulse,points,globe,moon,monkey,meter,hamburger" default:"dot"` + Title string `help:"Text to display to user while spinning" default:"Loading..."` } diff --git a/write/command.go b/write/command.go index 1658f18..54dff3c 100644 --- a/write/command.go +++ b/write/command.go @@ -23,6 +23,11 @@ func (o Options) Run() { a.BlurredStyle.CursorLine = lipgloss.NewStyle() } + a.Cursor.Style = lipgloss.NewStyle().Foreground(lipgloss.Color(o.CursorColor)) + + a.FocusedStyle.Prompt = lipgloss.NewStyle().Foreground(lipgloss.Color(o.PromptColor)) + a.BlurredStyle.Prompt = lipgloss.NewStyle().Foreground(lipgloss.Color(o.PromptColor)) + a.SetWidth(o.Width) p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr)) diff --git a/write/options.go b/write/options.go index 9cf71fb..9ab4699 100644 --- a/write/options.go +++ b/write/options.go @@ -2,10 +2,12 @@ package write // Options are the customization options for the textarea. type Options struct { - ShowCursorLine bool `help:"Show cursor line" default:"true"` - ShowLineNumbers bool `help:"Show line numbers" default:"true"` + CursorColor string `help:"Color for cursor" default:"212"` + Height int `help:"Text area height" default:"5"` Placeholder string `help:"Placeholder value" default:"Write something..."` Prompt string `help:"Prompt to display" default:"┃ "` + PromptColor string `help:"Color for prompt" default:"238"` + ShowCursorLine bool `help:"Show cursor line" default:"false"` + ShowLineNumbers bool `help:"Show line numbers" default:"false"` Width int `help:"Text area width" default:"50"` - Height int `help:"Text area height" default:"5"` }