mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
feat!: use pure lipgloss and drop adaptive colors
This commit is contained in:
+25
-9
@@ -32,29 +32,45 @@ 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) {
|
||||
normalTitleColor := "#1a1a1a"
|
||||
normalDescColor := "#A49FA5"
|
||||
selectedTitleBorderFgColor := "#F793FF"
|
||||
selectedTitleFgColor := "#EE6FF8"
|
||||
selectedDescColor := "#F793FF"
|
||||
dimmedTitleColor := "#A49FA5"
|
||||
dimmedDescColor := "#C2B8C2"
|
||||
if isDark {
|
||||
normalTitleColor = "#dddddd"
|
||||
normalDescColor = "#777777"
|
||||
selectedTitleBorderFgColor = "#AD58B4"
|
||||
selectedTitleFgColor = "#EE6FF8"
|
||||
selectedDescColor = "#AD58B4"
|
||||
dimmedTitleColor = "#777777"
|
||||
dimmedDescColor = "#4D4D4D"
|
||||
}
|
||||
s.NormalTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"}).
|
||||
Foreground(lipgloss.Color(normalTitleColor)).
|
||||
Padding(0, 0, 0, 2)
|
||||
|
||||
s.NormalDesc = s.NormalTitle.
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"})
|
||||
Foreground(lipgloss.Color(normalDescColor))
|
||||
|
||||
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(lipgloss.Color(selectedTitleBorderFgColor)).
|
||||
Foreground(lipgloss.Color(selectedTitleFgColor)).
|
||||
Padding(0, 0, 0, 1)
|
||||
|
||||
s.SelectedDesc = s.SelectedTitle.
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#F793FF", Dark: "#AD58B4"})
|
||||
Foreground(lipgloss.Color(selectedDescColor))
|
||||
|
||||
s.DimmedTitle = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}).
|
||||
Foreground(lipgloss.Color(dimmedTitleColor)).
|
||||
Padding(0, 0, 0, 2)
|
||||
|
||||
s.DimmedDesc = s.DimmedTitle.
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#C2B8C2", Dark: "#4D4D4D"})
|
||||
Foreground(lipgloss.Color(dimmedDescColor))
|
||||
|
||||
s.FilterMatch = lipgloss.NewStyle().Underline(true)
|
||||
|
||||
@@ -95,7 +111,7 @@ type DefaultDelegate struct {
|
||||
func NewDefaultDelegate() DefaultDelegate {
|
||||
return DefaultDelegate{
|
||||
ShowDescription: true,
|
||||
Styles: NewDefaultItemStyles(),
|
||||
Styles: NewDefaultItemStyles(true),
|
||||
height: 2,
|
||||
spacing: 1,
|
||||
}
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ type Model struct {
|
||||
|
||||
// New returns a new model with sensible defaults.
|
||||
func New(items []Item, delegate ItemDelegate, width, height int) Model {
|
||||
styles := DefaultStyles()
|
||||
styles := DefaultStyles(true)
|
||||
|
||||
sp := spinner.New()
|
||||
sp.Spinner = spinner.Line
|
||||
|
||||
+33
-15
@@ -41,9 +41,27 @@ 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) {
|
||||
verySubduedColor := "#DDDADA"
|
||||
subduedColor := "#9B9B9B"
|
||||
spinnerColor := "#8E8E8E"
|
||||
filterPromptColor := "#04B575"
|
||||
filterCursorColor := "#EE6FF8"
|
||||
statusBarColor := "#A49FA5"
|
||||
statusBarActiveFilterColor := "#1a1a1a"
|
||||
noItemsColor := "#909090"
|
||||
activePaginationColor := "#847A85"
|
||||
if isDark {
|
||||
verySubduedColor = "#3C3C3C"
|
||||
subduedColor = "#5C5C5C"
|
||||
spinnerColor = "#747373"
|
||||
filterPromptColor = "#ECFD65"
|
||||
filterCursorColor = "#EE6FF8"
|
||||
statusBarColor = "#777777"
|
||||
statusBarActiveFilterColor = "#dddddd"
|
||||
noItemsColor = "#626262"
|
||||
activePaginationColor = "#979797"
|
||||
}
|
||||
|
||||
s.TitleBar = lipgloss.NewStyle().Padding(0, 0, 1, 2)
|
||||
|
||||
@@ -53,46 +71,46 @@ func DefaultStyles() (s Styles) {
|
||||
Padding(0, 1)
|
||||
|
||||
s.Spinner = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#8E8E8E", Dark: "#747373"})
|
||||
Foreground(lipgloss.Color(spinnerColor))
|
||||
|
||||
s.FilterPrompt = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#04B575", Dark: "#ECFD65"})
|
||||
Foreground(lipgloss.Color(filterPromptColor))
|
||||
|
||||
s.FilterCursor = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#EE6FF8", Dark: "#EE6FF8"})
|
||||
Foreground(lipgloss.Color(filterCursorColor))
|
||||
|
||||
s.DefaultFilterCharacterMatch = lipgloss.NewStyle().Underline(true)
|
||||
|
||||
s.StatusBar = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}).
|
||||
Foreground(lipgloss.Color(statusBarColor)).
|
||||
Padding(0, 0, 1, 2)
|
||||
|
||||
s.StatusEmpty = lipgloss.NewStyle().Foreground(subduedColor)
|
||||
s.StatusEmpty = lipgloss.NewStyle().Foreground(lipgloss.Color(subduedColor))
|
||||
|
||||
s.StatusBarActiveFilter = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"})
|
||||
Foreground(lipgloss.Color(statusBarActiveFilterColor))
|
||||
|
||||
s.StatusBarFilterCount = lipgloss.NewStyle().Foreground(verySubduedColor)
|
||||
s.StatusBarFilterCount = lipgloss.NewStyle().Foreground(lipgloss.Color(verySubduedColor))
|
||||
|
||||
s.NoItems = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#909090", Dark: "#626262"})
|
||||
Foreground(lipgloss.Color(noItemsColor))
|
||||
|
||||
s.ArabicPagination = lipgloss.NewStyle().Foreground(subduedColor)
|
||||
s.ArabicPagination = lipgloss.NewStyle().Foreground(lipgloss.Color(subduedColor))
|
||||
|
||||
s.PaginationStyle = lipgloss.NewStyle().PaddingLeft(2) //nolint:gomnd
|
||||
|
||||
s.HelpStyle = lipgloss.NewStyle().Padding(1, 0, 0, 2)
|
||||
|
||||
s.ActivePaginationDot = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.AdaptiveColor{Light: "#847A85", Dark: "#979797"}).
|
||||
Foreground(lipgloss.Color(activePaginationColor)).
|
||||
SetString(bullet)
|
||||
|
||||
s.InactivePaginationDot = lipgloss.NewStyle().
|
||||
Foreground(verySubduedColor).
|
||||
Foreground(lipgloss.Color(verySubduedColor)).
|
||||
SetString(bullet)
|
||||
|
||||
s.DividerDot = lipgloss.NewStyle().
|
||||
Foreground(verySubduedColor).
|
||||
Foreground(lipgloss.Color(verySubduedColor)).
|
||||
SetString(" " + bullet + " ")
|
||||
|
||||
return s
|
||||
|
||||
Reference in New Issue
Block a user