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 {
|
||||
return model{
|
||||
keys: keys,
|
||||
help: help.NewModel(),
|
||||
help: help.New(),
|
||||
inputStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF75B7")),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func main() {
|
|||
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"
|
||||
|
||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||
|
|
|
@ -95,7 +95,7 @@ func newModel() model {
|
|||
|
||||
// Setup list
|
||||
delegate := newItemDelegate(delegateKeys)
|
||||
groceryList := list.NewModel(items, delegate, 0, 0)
|
||||
groceryList := list.New(items, delegate, 0, 0)
|
||||
groceryList.Title = "Groceries"
|
||||
groceryList.Styles.Title = titleStyle
|
||||
groceryList.AdditionalFullHelpKeys = func() []key.Binding {
|
||||
|
|
|
@ -111,7 +111,7 @@ func main() {
|
|||
|
||||
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.SetShowStatusBar(false)
|
||||
l.SetFilteringEnabled(false)
|
||||
|
|
|
@ -21,7 +21,7 @@ func newModel() model {
|
|||
items = append(items, text)
|
||||
}
|
||||
|
||||
p := paginator.NewModel()
|
||||
p := paginator.New()
|
||||
p.Type = paginator.Dots
|
||||
p.PerPage = 10
|
||||
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) {
|
||||
i := textinput.NewModel()
|
||||
i := textinput.New()
|
||||
i.Prompt = ""
|
||||
i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))
|
||||
i.Width = 48
|
||||
|
|
|
@ -27,7 +27,7 @@ var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
|||
|
||||
func main() {
|
||||
m := model{
|
||||
progress: progress.NewModel(progress.WithDefaultGradient()),
|
||||
progress: progress.New(progress.WithDefaultGradient()),
|
||||
}
|
||||
|
||||
if err := tea.NewProgram(m).Start(); err != nil {
|
||||
|
|
|
@ -35,7 +35,7 @@ const (
|
|||
var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render
|
||||
|
||||
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 {
|
||||
fmt.Println("Oh no!", err)
|
||||
|
|
|
@ -82,7 +82,7 @@ func main() {
|
|||
|
||||
p := tea.NewProgram(model{
|
||||
sub: make(chan struct{}),
|
||||
spinner: spinner.NewModel(),
|
||||
spinner: spinner.New(),
|
||||
})
|
||||
|
||||
if p.Start() != nil {
|
||||
|
|
|
@ -45,7 +45,7 @@ type model struct {
|
|||
|
||||
func newModel() model {
|
||||
const numLastResults = 5
|
||||
s := spinner.NewModel()
|
||||
s := spinner.New()
|
||||
s.Style = spinnerStyle
|
||||
return model{
|
||||
spinner: s,
|
||||
|
|
|
@ -21,7 +21,7 @@ type model struct {
|
|||
}
|
||||
|
||||
func initialModel() model {
|
||||
s := spinner.NewModel()
|
||||
s := spinner.New()
|
||||
s.Spinner = spinner.Dot
|
||||
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
|
||||
return model{spinner: s}
|
||||
|
|
|
@ -80,7 +80,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
|
||||
func (m *model) resetSpinner() {
|
||||
m.spinner = spinner.NewModel()
|
||||
m.spinner = spinner.New()
|
||||
m.spinner.Style = spinnerStyle
|
||||
m.spinner.Spinner = spinners[m.index]
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ type model struct {
|
|||
}
|
||||
|
||||
func initialModel() model {
|
||||
ti := textinput.NewModel()
|
||||
ti := textinput.New()
|
||||
ti.Placeholder = "Pikachu"
|
||||
ti.Focus()
|
||||
ti.CharLimit = 156
|
||||
|
|
|
@ -38,7 +38,7 @@ func initialModel() model {
|
|||
|
||||
var t textinput.Model
|
||||
for i := range m.inputs {
|
||||
t = textinput.NewModel()
|
||||
t = textinput.New()
|
||||
t.CursorStyle = cursorStyle
|
||||
t.CharLimit = 32
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ type model struct {
|
|||
func newModel() model {
|
||||
const showLastResults = 5
|
||||
|
||||
sp := spinner.NewModel()
|
||||
sp := spinner.New()
|
||||
sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("206"))
|
||||
|
||||
return model{
|
||||
|
|
Loading…
Reference in New Issue