Skip to content
Myr

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

3 files+11 added−9 removed

modified:examples/tui-daemon-combo/main.go+5 added-3 removed
11 unmodified lines
12 "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)1718var (19var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render19 helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render20 mainStyle = lipgloss.NewStyle().MarginLeft(1)21)2223func main() {24 var (25 daemonMode bool
93 unmodified lines
119 if m.quitting {120 s += "\n"121 }122121 return indent.String(s, 1)123 return mainStyle.Render(s)124}125126// processFinishedMsg is sent when a pretend process completes.127type processFinishedMsg time.Duration
12 unmodified lines
modified:examples/views/main.go+5 added-5 removed
15 unmodified lines
16 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)2122const (23 progressBarWidth = 71
8 unmodified lines
32 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)3839 // Gradient colors we'll use for the progress bar40 ramp = makeRampStyles("#B14FFF", "#00FFA3", progressBarWidth)41)
66 unmodified lines
108 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}114115// Sub-update functions116
67 unmodified lines
184185 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")191192 choices := fmt.Sprintf(193 "%s\n%s\n%s\n%s",
82 unmodified lines
modified:examples/go.mod+1 added-1 removed
10 unmodified lines
11 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)1617require (18 github.com/alecthomas/chroma v0.10.0 // indirect
10 unmodified lines
29 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 // indirect
10 unmodified lines