Skip to content

Commit

Permalink
chore(list): minimal updates for Lip Gloss v2
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Oct 24, 2024
1 parent ac7faa3 commit 301bc03
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
26 changes: 15 additions & 11 deletions list/defaultitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,31 @@ type DefaultItemStyles struct {

// NewDefaultItemStyles returns style definitions for a default item. See
// DefaultItemView for when these come into play.
func NewDefaultItemStyles() (s DefaultItemStyles) {
func NewDefaultItemStyles(isDark bool) (s DefaultItemStyles) {
lightDark := lipgloss.LightDark(isDark)

s.NormalTitle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"}).
Foreground(lightDark("#1a1a1a", "#dddddd")).
Padding(0, 0, 0, 2) //nolint:mnd

s.NormalDesc = s.NormalTitle.
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"})
Foreground(lightDark("#A49FA5", "#777777"))

s.SelectedTitle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, false, true).
BorderForeground(lipgloss.AdaptiveColor{Light: "#F793FF", Dark: "#AD58B4"}).
Foreground(lipgloss.AdaptiveColor{Light: "#EE6FF8", Dark: "#EE6FF8"}).
BorderForeground(lightDark("#F793FF", "#AD58B4")).
Foreground(lightDark("#EE6FF8", "#EE6FF8")).
Padding(0, 0, 0, 1)

s.SelectedDesc = s.SelectedTitle.
Foreground(lipgloss.AdaptiveColor{Light: "#F793FF", Dark: "#AD58B4"})
Foreground(lightDark("#F793FF", "#AD58B4"))

s.DimmedTitle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}).
Foreground(lightDark("#A49FA5", "#777777")).
Padding(0, 0, 0, 2) //nolint:mnd

s.DimmedDesc = s.DimmedTitle.
Foreground(lipgloss.AdaptiveColor{Light: "#C2B8C2", Dark: "#4D4D4D"})
Foreground(lightDark("#C2B8C2", "#4D4D4D"))

s.FilterMatch = lipgloss.NewStyle().Underline(true)

Expand Down Expand Up @@ -97,9 +99,11 @@ func NewDefaultDelegate() DefaultDelegate {
const defaultSpacing = 1
return DefaultDelegate{
ShowDescription: true,
Styles: NewDefaultItemStyles(),
height: defaultHeight,
spacing: defaultSpacing,
// XXX: Let the user choose between light and dark colors. We've
// temporarily hardcoded the dark colors here.
Styles: NewDefaultItemStyles(true),
height: defaultHeight,
spacing: defaultSpacing,
}
}

Expand Down
4 changes: 3 additions & 1 deletion list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ type Model struct {

// New returns a new model with sensible defaults.
func New(items []Item, delegate ItemDelegate, width, height int) Model {
styles := DefaultStyles()
// XXX: Let the user choose between light and dark colors. We've
// temporarily hardcoded the dark colors here.
styles := DefaultStyles(true)

sp := spinner.New()
sp.Spinner = spinner.Line
Expand Down
22 changes: 12 additions & 10 deletions list/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ type Styles struct {

// DefaultStyles returns a set of default style definitions for this list
// component.
func DefaultStyles() (s Styles) {
verySubduedColor := lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"}
subduedColor := lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}
func DefaultStyles(isDark bool) (s Styles) {
lightDark := lipgloss.LightDark(isDark)

verySubduedColor := lightDark("#DDDADA", "#3C3C3C")
subduedColor := lightDark("#9B9B9B", "#5C5C5C")

s.TitleBar = lipgloss.NewStyle().Padding(0, 0, 1, 2) //nolint:mnd

Expand All @@ -53,29 +55,29 @@ func DefaultStyles() (s Styles) {
Padding(0, 1)

s.Spinner = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#8E8E8E", Dark: "#747373"})
Foreground(lightDark("#8E8E8E", "#747373"))

s.FilterPrompt = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#04B575", Dark: "#ECFD65"})
Foreground(lightDark("#04B575", "#ECFD65"))

s.FilterCursor = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#EE6FF8", Dark: "#EE6FF8"})
Foreground(lightDark("#EE6FF8", "#EE6FF8"))

s.DefaultFilterCharacterMatch = lipgloss.NewStyle().Underline(true)

s.StatusBar = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}).
Foreground(lightDark("#A49FA5", "#777777")).
Padding(0, 0, 1, 2) //nolint:mnd

s.StatusEmpty = lipgloss.NewStyle().Foreground(subduedColor)

s.StatusBarActiveFilter = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"})
Foreground(lightDark("#1a1a1a", "#dddddd"))

s.StatusBarFilterCount = lipgloss.NewStyle().Foreground(verySubduedColor)

s.NoItems = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#909090", Dark: "#626262"})
Foreground(lightDark("#909090", "#626262"))

s.ArabicPagination = lipgloss.NewStyle().Foreground(subduedColor)

Expand All @@ -84,7 +86,7 @@ func DefaultStyles() (s Styles) {
s.HelpStyle = lipgloss.NewStyle().Padding(1, 0, 0, 2) //nolint:mnd

s.ActivePaginationDot = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: "#847A85", Dark: "#979797"}).
Foreground(lightDark("#847A85", "#979797")).
SetString(bullet)

s.InactivePaginationDot = lipgloss.NewStyle().
Expand Down

0 comments on commit 301bc03

Please sign in to comment.