Skip to content

Commit

Permalink
chore(examples): use lipgloss for indentation
Browse files Browse the repository at this point in the history
Fixes: a6f77ff
  • Loading branch information
aymanbagabas committed Mar 22, 2024
1 parent a6f77ff commit 7199a7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/go.mod
Expand Up @@ -12,7 +12,6 @@ require (
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-isatty v0.0.20
github.com/muesli/reflow v0.3.0
)

require (
Expand All @@ -31,6 +30,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/rivo/uniseg v0.4.6 // indirect
Expand Down
8 changes: 5 additions & 3 deletions examples/tui-daemon-combo/main.go
Expand Up @@ -13,10 +13,12 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/mattn/go-isatty"
"github.com/muesli/reflow/indent"
)

var helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render
var (
helpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render
mainStyle = lipgloss.NewStyle().MarginLeft(1)
)

func main() {
var (
Expand Down Expand Up @@ -118,7 +120,7 @@ func (m model) View() string {
s += "\n"
}

return indent.String(s, 1)
return mainStyle.Render(s)
}

// processFinishedMsg is sent when a pretend process completes.
Expand Down
10 changes: 5 additions & 5 deletions examples/views/main.go
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/fogleman/ease"
"github.com/lucasb-eyer/go-colorful"
"github.com/muesli/reflow/indent"
)

const (
Expand All @@ -34,7 +33,8 @@ var (
ticksStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("79"))
checkboxStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("212"))
progressEmpty = subtleStyle.Render(progressEmptyChar)
dot = lipgloss.NewStyle().Foreground(lipgloss.Color("236")).Render(dotChar)
dotStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("236")).Render(dotChar)
mainStyle = lipgloss.NewStyle().MarginLeft(2)

// Gradient colors we'll use for the progress bar
ramp = makeRampStyles("#B14FFF", "#00FFA3", progressBarWidth)
Expand Down Expand Up @@ -109,7 +109,7 @@ func (m model) View() string {
} else {
s = chosenView(m)
}
return indent.String("\n"+s+"\n\n", 2)
return mainStyle.Render("\n" + s + "\n\n")
}

// Sub-update functions
Expand Down Expand Up @@ -185,8 +185,8 @@ func choicesView(m model) string {
tpl := "What to do today?\n\n"
tpl += "%s\n\n"
tpl += "Program quits in %s seconds\n\n"
tpl += subtleStyle.Render("j/k, up/down: select") + dot +
subtleStyle.Render("enter: choose") + dot +
tpl += subtleStyle.Render("j/k, up/down: select") + dotStyle +
subtleStyle.Render("enter: choose") + dotStyle +
subtleStyle.Render("q, esc: quit")

choices := fmt.Sprintf(
Expand Down

0 comments on commit 7199a7f

Please sign in to comment.