Skip to content

Commit

Permalink
Update spinner, textinput and pipe examples for Bubbles v0.7.7
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Apr 14, 2021
1 parent ebf80eb commit 9633404
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ module examples
go 1.13

require (
github.com/charmbracelet/bubbles v0.7.6
github.com/charmbracelet/bubbles v0.7.7
github.com/charmbracelet/bubbletea v0.13.1
github.com/charmbracelet/glamour v0.2.0
github.com/charmbracelet/lipgloss v0.1.2
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-runewidth v0.0.10
github.com/mattn/go-runewidth v0.0.12
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68
github.com/muesli/termenv v0.8.1
golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1 // indirect
)

replace github.com/charmbracelet/bubbletea => ../
16 changes: 8 additions & 8 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkx
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/atotto/clipboard v0.1.2 h1:YZCtFu5Ie8qX2VmVTBnrqLSiU9XOWwqNRmdT3gIQzbY=
github.com/atotto/clipboard v0.1.2/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/charmbracelet/bubbles v0.7.6 h1:SCAp4ZEUf2tBNEsufo+Xxxu2dvbFhYSDPrX45toQZrM=
github.com/charmbracelet/bubbles v0.7.6/go.mod h1:0D4XRYK0tjo8JMvflz1obpVcOikNZSG46SFauoZj22s=
github.com/charmbracelet/bubbles v0.7.7 h1:eVsAYiAJskifXaqHpPzbOZS1srMaTnuiTazC6uukBbA=
github.com/charmbracelet/bubbles v0.7.7/go.mod h1:5WX1sSSjNCgCrzvRMN/z23HxvWaa+AI16Ch0KPZPeDs=
github.com/charmbracelet/glamour v0.2.0 h1:mTgaiNiumpqTZp3qVM6DH9UB0NlbY17wejoMf1kM8Pg=
github.com/charmbracelet/glamour v0.2.0/go.mod h1:UA27Kwj3QHialP74iU6C+Gpc8Y7IOAKupeKMLLBURWM=
github.com/charmbracelet/lipgloss v0.1.2 h1:D+LUMg34W7n2pkuMrevKVxT7HXqnoRHm7IoomkX3/ZU=
github.com/charmbracelet/lipgloss v0.1.2/go.mod h1:5D8zradw52m7QmxRF6QgwbwJi9je84g8MkWiGN07uKg=
github.com/containerd/console v1.0.1 h1:u7SFAJyRqWcG6ogaMAx3KjSTy1e3hT9QxqX7Jco7dRc=
github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
Expand All @@ -33,16 +35,15 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/muesli/reflow v0.1.0/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
github.com/muesli/reflow v0.2.0/go.mod h1:qT22vjVmM9MIUeLgsVYe/Ye7eZlbv9dZjL3dVhUqLX8=
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 h1:y1p/ycavWjGT9FnmSjdbWUlLGvcxrY0Rw3ATltrxOhk=
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=
github.com/muesli/termenv v0.6.0/go.mod h1:SohX91w6swWA4AYU+QmPx+aSgXhWO0juiyID9UZmbpA=
github.com/muesli/termenv v0.7.4/go.mod h1:pZ7qY9l3F7e5xsAOS0zCew2tME+p7bWeBkotCEcIIcc=
github.com/muesli/termenv v0.8.1 h1:9q230czSP3DHVpkaPDXGp0TOfAwyjyYwXlUCQxQSaBk=
github.com/muesli/termenv v0.8.1/go.mod h1:kzt/D/4a88RoheZmwfqorY3A+tnsSMA9HJC/fQSFKo0=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
Expand Down Expand Up @@ -77,7 +78,6 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201020230747-6e5568b54d1a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1 h1:/DtoiOYKoQCcIFXQjz07RnWNPRCbqmSXSpgEzhC9ZHM=
golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
3 changes: 2 additions & 1 deletion examples/pipe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)

func main() {
Expand Down Expand Up @@ -59,7 +60,7 @@ type model struct {
func newModel(initialValue string) (m model) {
i := textinput.NewModel()
i.Prompt = ""
i.CursorColor = "63"
i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))
i.Width = 48
i.SetValue(initialValue)
i.CursorEnd()
Expand Down
2 changes: 2 additions & 0 deletions examples/spinner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
)

Expand All @@ -33,6 +34,7 @@ func main() {
func initialModel() model {
s := spinner.NewModel()
s.Spinner = spinner.Dot
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
return model{spinner: s}
}

Expand Down
10 changes: 5 additions & 5 deletions examples/spinners/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/muesli/termenv"
"github.com/charmbracelet/lipgloss"
)

var (
Expand All @@ -23,9 +23,9 @@ var (
spinner.Monkey,
}

color = termenv.ColorProfile().Color
textStyle = termenv.Style{}.Foreground(color("252")).Styled
helpStyle = termenv.Style{}.Foreground(color("241")).Styled
textStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("252")).Render
spinnerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("69"))
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render
)

func main() {
Expand Down Expand Up @@ -81,7 +81,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

func (m *model) resetSpinner() {
m.spinner = spinner.NewModel()
m.spinner.ForegroundColor = "69"
m.spinner.Style = spinnerStyle
m.spinner.Spinner = spinners[m.index]
}

Expand Down
29 changes: 13 additions & 16 deletions examples/textinputs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ import (

"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
te "github.com/muesli/termenv"
"github.com/charmbracelet/lipgloss"
)

const focusedTextColor = "205"

var (
color = te.ColorProfile().Color
focusedPrompt = te.String("> ").Foreground(color("205")).String()
blurredPrompt = "> "
focusedSubmitButton = "[ " + te.String("Submit").Foreground(color("205")).String() + " ]"
blurredSubmitButton = "[ " + te.String("Submit").Foreground(color("240")).String() + " ]"
focusedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
blurredButtonStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
noStyle = lipgloss.NewStyle()

focusedSubmitButton = "[ " + focusedStyle.Render("Submit") + " ]"
blurredSubmitButton = "[ " + blurredButtonStyle.Render("Submit") + " ]"
)

func main() {
Expand All @@ -41,18 +40,16 @@ func initialModel() model {
name := textinput.NewModel()
name.Placeholder = "Nickname"
name.Focus()
name.Prompt = focusedPrompt
name.TextColor = focusedTextColor
name.PromptStyle = focusedStyle
name.TextStyle = focusedStyle
name.CharLimit = 32

email := textinput.NewModel()
email.Placeholder = "Email"
email.Prompt = blurredPrompt
email.CharLimit = 64

password := textinput.NewModel()
password.Placeholder = "Password"
password.Prompt = blurredPrompt
password.EchoMode = textinput.EchoPassword
password.EchoCharacter = '•'
password.CharLimit = 32
Expand Down Expand Up @@ -108,14 +105,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if i == m.index {
// Set focused state
inputs[i].Focus()
inputs[i].Prompt = focusedPrompt
inputs[i].TextColor = focusedTextColor
inputs[i].PromptStyle = focusedStyle
inputs[i].TextStyle = focusedStyle
continue
}
// Remove focused state
inputs[i].Blur()
inputs[i].Prompt = blurredPrompt
inputs[i].TextColor = ""
inputs[i].PromptStyle = noStyle
inputs[i].TextStyle = noStyle
}

m.nameInput = inputs[0]
Expand Down

0 comments on commit 9633404

Please sign in to comment.