Skip to content
Myr

Cleanup styling spinner and tui-daemon-combo examples

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 65df162 · Browse files · 2 files+9 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−13 removed

  • other:+9 added−13 removed

2 files+9 added−13 removed

modified:examples/spinner/main.go+1 added-5 removed
8 unmodified lines
910 "github.com/charmbracelet/bubbles/spinner"11 tea "github.com/charmbracelet/bubbletea"12 "github.com/charmbracelet/lipgloss"13 "github.com/muesli/termenv"13)1416var color = termenv.ColorProfile().Color1715type errMsg error1617type model struct {18 spinner spinner.Model
39 unmodified lines
58func (m model) View() string {59 if m.err != nil {60 return m.err.Error()61 }65 s := termenv.String(m.spinner.View()).Foreground(color("205")).String()66 str := fmt.Sprintf("\n\n %s Loading forever...press q to quit\n\n", s)62 str := fmt.Sprintf("\n\n %s Loading forever...press q to quit\n\n", m.spinner.View())63 if m.quitting {64 return str + "\n"65 }66 return str
9 unmodified lines
modified:examples/tui-daemon-combo/main.go+8 added-8 removed
9 unmodified lines
10 "time"1112 "github.com/charmbracelet/bubbles/spinner"13 tea "github.com/charmbracelet/bubbletea"14 "github.com/charmbracelet/lipgloss"15 "github.com/mattn/go-isatty"16 "github.com/muesli/reflow/indent"16 "github.com/muesli/termenv"17)1819var (20 color = termenv.ColorProfile().Color21)19var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render2021func main() {22 rand.Seed(time.Now().UTC().UnixNano())23
40 unmodified lines
6465func newModel() model {66 const showLastResults = 56768 sp := spinner.NewModel()69 sp.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("206"))7071 return model{71 spinner: spinner.NewModel(),72 spinner: sp,73 results: make([]result, showLastResults),74 }75}76
26 unmodified lines
103}104105func (m model) View() string {106 s := "\n" +106 termenv.String(m.spinner.View()).Foreground(color("206")).String() +107 " Doing some work...\n\n"107 m.spinner.View() + " Doing some work...\n\n"108109 for _, res := range m.results {110 if res.duration == 0 {111 s += "........................\n"
1 unmodified line
113 s += fmt.Sprintf("%s Job finished in %s\n", res.emoji, res.duration)114 }115 }116117 s += termenv.String("\nPress any key to exit\n").Foreground(color("240")).String()117 s += helpStyle("\nPress any key to exit\n")118119 if m.quitting {120 s += "\n"121 }
18 unmodified lines