chore(examples): use lipgloss for indentation
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Ayman Bagabas · committed by Ayman Bagabas · parent a6f77ff · Browse files · 3 files·+11 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Fixes: a6f77ff8cdfc
Diff stats
3 files+11 added−9 removed
- other:+11 added−9 removed
Provenance
- Commit
7199a7f- Tree
81eea5b- Author
Ayman Bagabas <ayman.bagabas@gmail.com>- Committer
Ayman Bagabas <ayman.bagabas@gmail.com>- Parent
a6f77ff
3 files changed+11 added−9 removed
modified:examples/tui-daemon-combo/main.go+5 added-3 removed
11 unmodified lines12 "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 )17 18+var (19-var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render19+ helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render20+ mainStyle = lipgloss.NewStyle().MarginLeft(1)21+)22 23 func main() {24 var (25 daemonMode bool93 unmodified lines119 if m.quitting {120 s += "\n"121 }122 121- return indent.String(s, 1)123+ return mainStyle.Render(s)124 }125 126 // processFinishedMsg is sent when a pretend process completes.127 type processFinishedMsg time.Duration12 unmodified linesmodified:examples/views/main.go+5 added-5 removed
15 unmodified lines16 tea "github.com/charmbracelet/bubbletea"17 "github.com/charmbracelet/lipgloss"18 "github.com/fogleman/ease"19 "github.com/lucasb-eyer/go-colorful"20- "github.com/muesli/reflow/indent"20 )21 22 const (23 progressBarWidth = 718 unmodified lines32 subtleStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241"))33 ticksStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("79"))34 checkboxStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))35 progressEmpty = subtleStyle.Render(progressEmptyChar)37- dot = lipgloss.NewStyle().Foreground(lipgloss.Color("236")).Render(dotChar)36+ dotStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("236")).Render(dotChar)37+ mainStyle = lipgloss.NewStyle().MarginLeft(2)38 39 // Gradient colors we'll use for the progress bar40 ramp = makeRampStyles("#B14FFF", "#00FFA3", progressBarWidth)41 )66 unmodified lines108 s = choicesView(m)109 } else {110 s = chosenView(m)111 }112- return indent.String("\n"+s+"\n\n", 2)112+ return mainStyle.Render("\n" + s + "\n\n")113 }114 115 // Sub-update functions116 67 unmodified lines184 185 tpl := "What to do today?\n\n"186 tpl += "%s\n\n"187 tpl += "Program quits in %s seconds\n\n"188- tpl += subtleStyle.Render("j/k, up/down: select") + dot +189- subtleStyle.Render("enter: choose") + dot +188+ tpl += subtleStyle.Render("j/k, up/down: select") + dotStyle +189+ subtleStyle.Render("enter: choose") + dotStyle +190 subtleStyle.Render("q, esc: quit")191 192 choices := fmt.Sprintf(193 "%s\n%s\n%s\n%s",82 unmodified linesmodified:examples/go.mod+1 added-1 removed
10 unmodified lines11 github.com/charmbracelet/x/exp/teatest v0.0.0-20240229115032-4b79243a351612 github.com/fogleman/ease v0.0.0-20170301025033-8da417bf177613 github.com/lucasb-eyer/go-colorful v1.2.014 github.com/mattn/go-isatty v0.0.2015- github.com/muesli/reflow v0.3.015 )16 17 require (18 github.com/alecthomas/chroma v0.10.0 // indirect10 unmodified lines29 github.com/mattn/go-runewidth v0.0.15 // indirect30 github.com/microcosm-cc/bluemonday v1.0.21 // indirect31 github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect32 github.com/muesli/cancelreader v0.2.2 // indirect33+ github.com/muesli/reflow v0.3.0 // indirect34 github.com/muesli/termenv v0.15.2 // indirect35 github.com/olekukonko/tablewriter v0.0.5 // indirect36 github.com/rivo/uniseg v0.4.6 // indirect37 github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect10 unmodified lines