mirror of
https://github.com/marcusDenslow/terminalShop.git
synced 2026-10-25 18:08:45 +01:00
* refactor(tui): port to charm v2 bumped bubbletea, lipgloss, bubbles, wish, and huh to v2. Mostly mechanical chur, new import paths, vewport getter/setter api, view() returns tea.view now, huh.theme became an interface so the theme package needed a small reshape. Render plumbing is gone (no more lipgloss.Render field on the Model or MakeRenderer in main.go). All pages still work over ssh. setting up for the refund composer next * style(tui): gofmt main.go and menu.go
51 lines
1.9 KiB
Go
51 lines
1.9 KiB
Go
package theme
|
|
|
|
import (
|
|
"charm.land/bubbles/v2/help"
|
|
"charm.land/huh/v2"
|
|
"charm.land/lipgloss/v2"
|
|
)
|
|
|
|
// HuhTheme creates a huh form theme using this project's color palette.
|
|
func HuhTheme(t Theme) huh.Theme {
|
|
var s huh.Styles
|
|
|
|
s.FieldSeparator = lipgloss.NewStyle().SetString("\n\n")
|
|
|
|
f := &s.Focused
|
|
f.Base = lipgloss.NewStyle().
|
|
PaddingLeft(1).
|
|
BorderStyle(lipgloss.ThickBorder()).
|
|
BorderLeft(true).
|
|
BorderForeground(t.accent)
|
|
f.Title = lipgloss.NewStyle().Foreground(t.body)
|
|
f.Description = lipgloss.NewStyle().Foreground(t.body)
|
|
f.TextInput.Cursor = lipgloss.NewStyle().Foreground(t.highlight)
|
|
f.TextInput.Placeholder = lipgloss.NewStyle().Foreground(t.dim)
|
|
f.TextInput.Prompt = lipgloss.NewStyle().Foreground(t.accent)
|
|
f.TextInput.Text = lipgloss.NewStyle().Foreground(t.accent)
|
|
f.ErrorIndicator = lipgloss.NewStyle().Foreground(t.error)
|
|
f.ErrorMessage = lipgloss.NewStyle().Foreground(t.error)
|
|
|
|
f.SelectSelector = lipgloss.NewStyle().Foreground(t.accent).SetString("> ")
|
|
f.Option = lipgloss.NewStyle().Foreground(t.body)
|
|
f.SelectedOption = lipgloss.NewStyle().Foreground(t.highlight).Bold(true)
|
|
f.MultiSelectSelector = lipgloss.NewStyle().Foreground(t.accent).SetString("> ")
|
|
f.SelectedPrefix = lipgloss.NewStyle().Foreground(t.highlight).SetString("[x] ")
|
|
f.UnselectedPrefix = lipgloss.NewStyle().Foreground(t.dim).SetString("[ ] ")
|
|
f.UnselectedOption = lipgloss.NewStyle().Foreground(t.body)
|
|
|
|
s.Help = help.New().Styles
|
|
|
|
s.Blurred = copyFieldStyles(*f)
|
|
s.Blurred.Base = s.Blurred.Base.BorderStyle(lipgloss.HiddenBorder())
|
|
s.Blurred.Title = s.Blurred.Title.Foreground(t.body)
|
|
s.Blurred.SelectSelector = lipgloss.NewStyle().SetString(" ")
|
|
s.Blurred.SelectedOption = lipgloss.NewStyle().Foreground(t.success).Bold(true)
|
|
s.Blurred.Option = lipgloss.NewStyle().Foreground(t.dim)
|
|
|
|
return huh.ThemeFunc(func(bool) *huh.Styles { return &s })
|
|
}
|
|
|
|
func copyFieldStyles(f huh.FieldStyles) huh.FieldStyles { return f }
|