feat: Default accent color is 212 (Bubble Gum Pink)

This commit is contained in:
Maas Lalani 2022-07-07 17:46:22 -04:00
parent 0bf74df4fc
commit fa4f09a413
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
12 changed files with 52 additions and 31 deletions

1
answer.txt Normal file
View file

@ -0,0 +1 @@
I love Bubble Gum <3

View file

@ -14,7 +14,7 @@ echo "Wait a moment, while I think of my favorite color..."
gum spin --title "Thinking..." --color 212 -- sleep 3 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 sleep 1
@ -24,7 +24,7 @@ sleep 1
echo "What's your favorite Gum flavor?" echo "What's your favorite Gum flavor?"
GUM=$(gum search --accent-color 212 << FLAVORS GUM=$(gum search << FLAVORS
Cherry Cherry
Grape Grape
Lime Lime

View file

@ -6,6 +6,7 @@ import (
"github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea" tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
) )
// Run provides a shell script interface for the text input bubble. // Run provides a shell script interface for the text input bubble.
@ -17,6 +18,8 @@ func (o Options) Run() {
i.Prompt = o.Prompt i.Prompt = o.Prompt
i.Placeholder = o.Placeholder i.Placeholder = o.Placeholder
i.Width = o.Width 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)) p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr))
m, _ := p.StartReturningModel() m, _ := p.StartReturningModel()

View file

@ -2,7 +2,9 @@ package input
// Options are the customization options for the input. // Options are the customization options for the input.
type Options struct { type Options struct {
CursorColor string `help:"Color of prompt" default:"212"`
Placeholder string `help:"Placeholder value" default:"Type something..."` Placeholder string `help:"Placeholder value" default:"Type something..."`
Prompt string `help:"Prompt to display" default:"> "` Prompt string `help:"Prompt to display" default:"> "`
PromptColor string `help:"Color of prompt" default:"7"`
Width int `help:"Input width" default:"20"` Width int `help:"Input width" default:"20"`
} }

View file

@ -10,7 +10,7 @@ import (
// Run runs the progress command. // Run runs the progress command.
func (o Options) Run() { func (o Options) Run() {
p := progress.New( p := progress.New(
progress.WithDefaultGradient(), progress.WithGradient(o.ColorStart, o.ColorEnd),
progress.WithSpringOptions(o.Frequency, o.Damping), progress.WithSpringOptions(o.Frequency, o.Damping),
) )
m := model{ m := model{

View file

@ -4,8 +4,10 @@ import "time"
// Options is the available options for the progress command. // Options is the available options for the progress command.
type Options struct { type Options struct {
Damping float64 `help:"Damping of the spring animation." default:"0.9"` ColorEnd string `help:"The end color of the progress bar gradient." default:"#EE6FF8"`
Frequency float64 `help:"Frequency of the spring animation." default:"10.0"` ColorStart string `help:"The start color of the progress bar gradient." default:"#5A56E0"`
Increment float64 `help:"The percentage to increment the progress bar per tick." default:"0.1"` Damping float64 `help:"Damping of the spring animation." default:"0.9"`
Interval time.Duration `help:"The interval of time to wait before incrementing." default:"100ms"` 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"`
} }

View file

@ -19,7 +19,7 @@ func (o Options) Run() {
i.Focus() i.Focus()
i.Prompt = o.Prompt 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.Placeholder = o.Placeholder
i.Width = o.Width i.Width = o.Width
@ -31,10 +31,12 @@ func (o Options) Run() {
choices := strings.Split(string(input), "\n") choices := strings.Split(string(input), "\n")
p := tea.NewProgram(model{ p := tea.NewProgram(model{
textinput: i, textinput: i,
choices: choices, choices: choices,
matches: matchAll(choices), matches: matchAll(choices),
indicator: o.Indicator, indicator: o.Indicator,
highlightStyle: lipgloss.NewStyle().Foreground(lipgloss.Color(o.HighlightColor)),
indicatorStyle: lipgloss.NewStyle().Foreground(lipgloss.Color(o.IndicatorColor)),
}, tea.WithOutput(os.Stderr)) }, tea.WithOutput(os.Stderr))
tm, _ := p.StartReturningModel() tm, _ := p.StartReturningModel()

View file

@ -2,9 +2,11 @@ package search
// Options is the customization options for the search. // Options is the customization options for the search.
type Options struct { type Options struct {
AccentColor string `help:"Accent color for prompt, indicator, and matches" default:"#FF06B7"` HighlightColor string `help:"Color for highlighted matches" default:"212"`
Indicator string `help:"Character for selection" default:"•"` Indicator string `help:"Character for selection" default:"•"`
Placeholder string `help:"Placeholder value" default:"Search..."` IndicatorColor string `help:"Color for indicator" default:"212"`
Prompt string `help:"Prompt to display" default:"> "` Placeholder string `help:"Placeholder value" default:"Search..."`
Width int `help:"Input width" default:"20"` Prompt string `help:"Prompt to display" default:"> "`
PromptColor string `help:"Color for prompt" default:"240"`
Width int `help:"Input width" default:"20"`
} }

View file

@ -11,13 +11,15 @@ import (
) )
type model struct { type model struct {
textinput textinput.Model textinput textinput.Model
choices []string choices []string
matches []fuzzy.Match matches []fuzzy.Match
selected int selected int
indicator string indicator string
height int height int
quitting bool quitting bool
highlightStyle lipgloss.Style
indicatorStyle lipgloss.Style
} }
func (m model) Init() tea.Cmd { return nil } 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 // If this is the current selected index, we add a small indicator to
// represent it. Otherwise, simply pad the string. // represent it. Otherwise, simply pad the string.
if i == m.selected { if i == m.selected {
s.WriteString(m.textinput.PromptStyle.Render(m.indicator) + " ") s.WriteString(m.indicatorStyle.Render(m.indicator) + " ")
} else { } else {
s.WriteString(strings.Repeat(" ", runewidth.StringWidth(m.indicator)) + " ") 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 // Check if the current character index matches the current matched
// index. If so, color the character to indicate a match. // index. If so, color the character to indicate a match.
if mi < len(match.MatchedIndexes) && ci == match.MatchedIndexes[mi] { 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 // We have matched this character, so we never have to check it
// again. Move on to the next match. // again. Move on to the next match.
mi++ mi++

View file

@ -4,7 +4,7 @@ package spin
type Options struct { type Options struct {
Command []string `arg:"" help:"Command to run"` Command []string `arg:"" help:"Command to run"`
Color string `help:"Spinner color" default:"#FF06B7"` Color string `help:"Spinner color" default:"212"`
Title string `help:"Text to display to user while spinning" default:"Loading..."`
Spinner string `help:"Spinner type" type:"spinner" enum:"line,dot,minidot,jump,pulse,points,globe,moon,monkey,meter,hamburger" default:"dot"` 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..."`
} }

View file

@ -23,6 +23,11 @@ func (o Options) Run() {
a.BlurredStyle.CursorLine = lipgloss.NewStyle() 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) a.SetWidth(o.Width)
p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr)) p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr))

View file

@ -2,10 +2,12 @@ package write
// Options are the customization options for the textarea. // Options are the customization options for the textarea.
type Options struct { type Options struct {
ShowCursorLine bool `help:"Show cursor line" default:"true"` CursorColor string `help:"Color for cursor" default:"212"`
ShowLineNumbers bool `help:"Show line numbers" default:"true"` Height int `help:"Text area height" default:"5"`
Placeholder string `help:"Placeholder value" default:"Write something..."` Placeholder string `help:"Placeholder value" default:"Write something..."`
Prompt string `help:"Prompt to display" default:"┃ "` 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"` Width int `help:"Text area width" default:"50"`
Height int `help:"Text area height" default:"5"`
} }