mirror of
https://github.com/charmbracelet/gum.git
synced 2024-09-11 06:16:03 +03:00
feat: Default accent color is 212
(Bubble Gum Pink)
This commit is contained in:
parent
0bf74df4fc
commit
fa4f09a413
1
answer.txt
Normal file
1
answer.txt
Normal file
@ -0,0 +1 @@
|
||||
I love Bubble Gum <3
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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"`
|
||||
}
|
||||
|
@ -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{
|
||||
|
@ -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"`
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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"`
|
||||
}
|
||||
|
@ -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++
|
||||
|
@ -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..."`
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user