forked from Mirrors/bubbletea
Migrate from NewModel() to New() in examples for Bubbles-related stuff
This commit is contained in:
parent
843b6a5249
commit
66cea095eb
|
@ -75,7 +75,7 @@ type model struct {
|
||||||
func newModel() model {
|
func newModel() model {
|
||||||
return model{
|
return model{
|
||||||
keys: keys,
|
keys: keys,
|
||||||
help: help.NewModel(),
|
help: help.New(),
|
||||||
inputStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF75B7")),
|
inputStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF75B7")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ func main() {
|
||||||
item{title: "Terrycloth", desc: "In other words, towel fabric"},
|
item{title: "Terrycloth", desc: "In other words, towel fabric"},
|
||||||
}
|
}
|
||||||
|
|
||||||
m := model{list: list.NewModel(items, list.NewDefaultDelegate(), 0, 0)}
|
m := model{list: list.New(items, list.NewDefaultDelegate(), 0, 0)}
|
||||||
m.list.Title = "My Fave Things"
|
m.list.Title = "My Fave Things"
|
||||||
|
|
||||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||||
|
|
|
@ -95,7 +95,7 @@ func newModel() model {
|
||||||
|
|
||||||
// Setup list
|
// Setup list
|
||||||
delegate := newItemDelegate(delegateKeys)
|
delegate := newItemDelegate(delegateKeys)
|
||||||
groceryList := list.NewModel(items, delegate, 0, 0)
|
groceryList := list.New(items, delegate, 0, 0)
|
||||||
groceryList.Title = "Groceries"
|
groceryList.Title = "Groceries"
|
||||||
groceryList.Styles.Title = titleStyle
|
groceryList.Styles.Title = titleStyle
|
||||||
groceryList.AdditionalFullHelpKeys = func() []key.Binding {
|
groceryList.AdditionalFullHelpKeys = func() []key.Binding {
|
||||||
|
|
|
@ -111,7 +111,7 @@ func main() {
|
||||||
|
|
||||||
const defaultWidth = 20
|
const defaultWidth = 20
|
||||||
|
|
||||||
l := list.NewModel(items, itemDelegate{}, defaultWidth, listHeight)
|
l := list.New(items, itemDelegate{}, defaultWidth, listHeight)
|
||||||
l.Title = "What do you want for dinner?"
|
l.Title = "What do you want for dinner?"
|
||||||
l.SetShowStatusBar(false)
|
l.SetShowStatusBar(false)
|
||||||
l.SetFilteringEnabled(false)
|
l.SetFilteringEnabled(false)
|
||||||
|
|
|
@ -21,7 +21,7 @@ func newModel() model {
|
||||||
items = append(items, text)
|
items = append(items, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
p := paginator.NewModel()
|
p := paginator.New()
|
||||||
p.Type = paginator.Dots
|
p.Type = paginator.Dots
|
||||||
p.PerPage = 10
|
p.PerPage = 10
|
||||||
p.ActiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "235", Dark: "252"}).Render("•")
|
p.ActiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "235", Dark: "252"}).Render("•")
|
||||||
|
|
|
@ -56,7 +56,7 @@ type model struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newModel(initialValue string) (m model) {
|
func newModel(initialValue string) (m model) {
|
||||||
i := textinput.NewModel()
|
i := textinput.New()
|
||||||
i.Prompt = ""
|
i.Prompt = ""
|
||||||
i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))
|
i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))
|
||||||
i.Width = 48
|
i.Width = 48
|
||||||
|
|
|
@ -27,7 +27,7 @@ var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
m := model{
|
m := model{
|
||||||
progress: progress.NewModel(progress.WithDefaultGradient()),
|
progress: progress.New(progress.WithDefaultGradient()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tea.NewProgram(m).Start(); err != nil {
|
if err := tea.NewProgram(m).Start(); err != nil {
|
||||||
|
|
|
@ -35,7 +35,7 @@ const (
|
||||||
var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
prog := progress.NewModel(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))
|
prog := progress.New(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))
|
||||||
|
|
||||||
if err := tea.NewProgram(model{progress: prog}).Start(); err != nil {
|
if err := tea.NewProgram(model{progress: prog}).Start(); err != nil {
|
||||||
fmt.Println("Oh no!", err)
|
fmt.Println("Oh no!", err)
|
||||||
|
|
|
@ -82,7 +82,7 @@ func main() {
|
||||||
|
|
||||||
p := tea.NewProgram(model{
|
p := tea.NewProgram(model{
|
||||||
sub: make(chan struct{}),
|
sub: make(chan struct{}),
|
||||||
spinner: spinner.NewModel(),
|
spinner: spinner.New(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if p.Start() != nil {
|
if p.Start() != nil {
|
||||||
|
|
|
@ -45,7 +45,7 @@ type model struct {
|
||||||
|
|
||||||
func newModel() model {
|
func newModel() model {
|
||||||
const numLastResults = 5
|
const numLastResults = 5
|
||||||
s := spinner.NewModel()
|
s := spinner.New()
|
||||||
s.Style = spinnerStyle
|
s.Style = spinnerStyle
|
||||||
return model{
|
return model{
|
||||||
spinner: s,
|
spinner: s,
|
||||||
|
|
|
@ -21,7 +21,7 @@ type model struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialModel() model {
|
func initialModel() model {
|
||||||
s := spinner.NewModel()
|
s := spinner.New()
|
||||||
s.Spinner = spinner.Dot
|
s.Spinner = spinner.Dot
|
||||||
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
|
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
|
||||||
return model{spinner: s}
|
return model{spinner: s}
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *model) resetSpinner() {
|
func (m *model) resetSpinner() {
|
||||||
m.spinner = spinner.NewModel()
|
m.spinner = spinner.New()
|
||||||
m.spinner.Style = spinnerStyle
|
m.spinner.Style = spinnerStyle
|
||||||
m.spinner.Spinner = spinners[m.index]
|
m.spinner.Spinner = spinners[m.index]
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ type model struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialModel() model {
|
func initialModel() model {
|
||||||
ti := textinput.NewModel()
|
ti := textinput.New()
|
||||||
ti.Placeholder = "Pikachu"
|
ti.Placeholder = "Pikachu"
|
||||||
ti.Focus()
|
ti.Focus()
|
||||||
ti.CharLimit = 156
|
ti.CharLimit = 156
|
||||||
|
|
|
@ -38,7 +38,7 @@ func initialModel() model {
|
||||||
|
|
||||||
var t textinput.Model
|
var t textinput.Model
|
||||||
for i := range m.inputs {
|
for i := range m.inputs {
|
||||||
t = textinput.NewModel()
|
t = textinput.New()
|
||||||
t.CursorStyle = cursorStyle
|
t.CursorStyle = cursorStyle
|
||||||
t.CharLimit = 32
|
t.CharLimit = 32
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ type model struct {
|
||||||
func newModel() model {
|
func newModel() model {
|
||||||
const showLastResults = 5
|
const showLastResults = 5
|
||||||
|
|
||||||
sp := spinner.NewModel()
|
sp := spinner.New()
|
||||||
sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("206"))
|
sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("206"))
|
||||||
|
|
||||||
return model{
|
return model{
|
||||||
|
|
Loading…
Reference in New Issue