Migrate from NewModel() to New() in examples for Bubbles-related stuff
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Christian Rocha · committed by Christian Rocha · parent 843b6a5 · Browse files · 15 files·+15 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+15 added−15 removed
- other:+15 added−15 removed
Provenance
- Commit
66cea09- Tree
a22ec78- Author
Christian Rocha <christian@rocha.is>- Committer
Christian Rocha <christian@rocha.is>- Parent
843b6a5
15 files changed+15 added−15 removed
modified:examples/help/main.go+1 added-1 removed
73 unmodified lines74 75 func newModel() model {76 return model{77 keys: keys,78- help: help.NewModel(),78+ help: help.New(),79 inputStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("#FF75B7")),80 }81 }82 65 unmodified linesmodified:examples/list-default/main.go+1 added-1 removed
72 unmodified lines73 item{title: "Gaffer’s tape", desc: "Basically sticky fabric"},74 item{title: "Terrycloth", desc: "In other words, towel fabric"},75 }76 77- m := model{list: list.NewModel(items, list.NewDefaultDelegate(), 0, 0)}77+ m := model{list: list.New(items, list.NewDefaultDelegate(), 0, 0)}78 m.list.Title = "My Fave Things"79 80 p := tea.NewProgram(m, tea.WithAltScreen())81 5 unmodified linesmodified:examples/list-fancy/main.go+1 added-1 removed
93 unmodified lines94 }95 96 // Setup list97 delegate := newItemDelegate(delegateKeys)98- groceryList := list.NewModel(items, delegate, 0, 0)98+ groceryList := list.New(items, delegate, 0, 0)99 groceryList.Title = "Groceries"100 groceryList.Styles.Title = titleStyle101 groceryList.AdditionalFullHelpKeys = func() []key.Binding {102 return []key.Binding{88 unmodified linesmodified:examples/list-simple/main.go+1 added-1 removed
109 unmodified lines110 }111 112 const defaultWidth = 20113 114- l := list.NewModel(items, itemDelegate{}, defaultWidth, listHeight)114+ l := list.New(items, itemDelegate{}, defaultWidth, listHeight)115 l.Title = "What do you want for dinner?"116 l.SetShowStatusBar(false)117 l.SetFilteringEnabled(false)118 l.Styles.Title = titleStyle10 unmodified linesmodified:examples/paginator/main.go+1 added-1 removed
19 unmodified lines20 text := fmt.Sprintf("Item %d", i)21 items = append(items, text)22 }23 24- p := paginator.NewModel()24+ p := paginator.New()25 p.Type = paginator.Dots26 p.PerPage = 1027 p.ActiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "235", Dark: "252"}).Render("•")28 p.InactiveDot = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "250", Dark: "238"}).Render("•")48 unmodified linesmodified:examples/pipe/main.go+1 added-1 removed
54 unmodified lines55 userInput textinput.Model56 }57 58 func newModel(initialValue string) (m model) {59- i := textinput.NewModel()59+ i := textinput.New()60 i.Prompt = ""61 i.CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))62 i.Width = 4863 i.SetValue(initialValue)30 unmodified linesmodified:examples/progress-animated/main.go+1 added-1 removed
25 unmodified lines26 var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render27 28 func main() {29 m := model{30- progress: progress.NewModel(progress.WithDefaultGradient()),30+ progress: progress.New(progress.WithDefaultGradient()),31 }32 33 if err := tea.NewProgram(m).Start(); err != nil {34 fmt.Println("Oh no!", err)59 unmodified linesmodified:examples/progress-static/main.go+1 added-1 removed
33 unmodified lines34 35 var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#626262")).Render36 37 func main() {38- prog := progress.NewModel(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))38+ prog := progress.New(progress.WithScaledGradient("#FF7CCB", "#FDFF8C"))39 40 if err := tea.NewProgram(model{progress: prog}).Start(); err != nil {41 fmt.Println("Oh no!", err)42 os.Exit(1)52 unmodified linesmodified:examples/realtime/main.go+1 added-1 removed
80 unmodified lines81 rand.Seed(time.Now().UTC().UnixNano())82 83 p := tea.NewProgram(model{84 sub: make(chan struct{}),85- spinner: spinner.NewModel(),85+ spinner: spinner.New(),86 })87 88 if p.Start() != nil {89 fmt.Println("could not start program")3 unmodified linesmodified:examples/send-msg/main.go+1 added-1 removed
43 unmodified lines44 }45 46 func newModel() model {47 const numLastResults = 548- s := spinner.NewModel()48+ s := spinner.New()49 s.Style = spinnerStyle50 return model{51 spinner: s,52 results: make([]resultMsg, numLastResults),84 unmodified linesmodified:examples/spinner/main.go+1 added-1 removed
19 unmodified lines20 err error21 }22 23 func initialModel() model {24- s := spinner.NewModel()24+ s := spinner.New()25 s.Spinner = spinner.Dot26 s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))27 return model{spinner: s}28 }47 unmodified linesmodified:examples/spinners/main.go+1 added-1 removed
78 unmodified lines79 }80 }81 82 func (m *model) resetSpinner() {83- m.spinner = spinner.NewModel()83+ m.spinner = spinner.New()84 m.spinner.Style = spinnerStyle85 m.spinner.Spinner = spinners[m.index]86 }87 13 unmodified linesmodified:examples/textinput/main.go+1 added-1 removed
26 unmodified lines27 err error28 }29 30 func initialModel() model {31- ti := textinput.NewModel()31+ ti := textinput.New()32 ti.Placeholder = "Pikachu"33 ti.Focus()34 ti.CharLimit = 15635 ti.Width = 2038 unmodified linesmodified:examples/textinputs/main.go+1 added-1 removed
36 unmodified lines37 }38 39 var t textinput.Model40 for i := range m.inputs {41- t = textinput.NewModel()41+ t = textinput.New()42 t.CursorStyle = cursorStyle43 t.CharLimit = 3244 45 switch i {131 unmodified linesmodified:examples/tui-daemon-combo/main.go+1 added-1 removed
63 unmodified lines64 65 func newModel() model {66 const showLastResults = 567 68- sp := spinner.NewModel()68+ sp := spinner.New()69 sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("206"))70 71 return model{72 spinner: sp,67 unmodified lines