mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 12:46:14 +00:00
118 lines
3.1 KiB
Go
118 lines
3.1 KiB
Go
package list
|
|
|
|
import (
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
const (
|
|
bullet = "•"
|
|
ellipsis = "…"
|
|
)
|
|
|
|
// Styles contains style definitions for this list component. By default, these
|
|
// values are generated by DefaultStyles.
|
|
type Styles struct {
|
|
TitleBar lipgloss.Style
|
|
Title lipgloss.Style
|
|
Spinner lipgloss.Style
|
|
FilterPrompt lipgloss.Style
|
|
FilterCursor lipgloss.Style
|
|
|
|
// Default styling for matched characters in a filter. This can be
|
|
// overridden by delegates.
|
|
DefaultFilterCharacterMatch lipgloss.Style
|
|
|
|
StatusBar lipgloss.Style
|
|
StatusEmpty lipgloss.Style
|
|
StatusBarActiveFilter lipgloss.Style
|
|
StatusBarFilterCount lipgloss.Style
|
|
|
|
NoItems lipgloss.Style
|
|
|
|
PaginationStyle lipgloss.Style
|
|
HelpStyle lipgloss.Style
|
|
|
|
// Styled characters.
|
|
ActivePaginationDot lipgloss.Style
|
|
InactivePaginationDot lipgloss.Style
|
|
ArabicPagination lipgloss.Style
|
|
DividerDot lipgloss.Style
|
|
}
|
|
|
|
// DefaultStyles returns a set of default style definitions for this list
|
|
// component.
|
|
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)
|
|
|
|
s.Title = lipgloss.NewStyle().
|
|
Background(lipgloss.Color("62")).
|
|
Foreground(lipgloss.Color("230")).
|
|
Padding(0, 1)
|
|
|
|
s.Spinner = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(spinnerColor))
|
|
|
|
s.FilterPrompt = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(filterPromptColor))
|
|
|
|
s.FilterCursor = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(filterCursorColor))
|
|
|
|
s.DefaultFilterCharacterMatch = lipgloss.NewStyle().Underline(true)
|
|
|
|
s.StatusBar = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(statusBarColor)).
|
|
Padding(0, 0, 1, 2)
|
|
|
|
s.StatusEmpty = lipgloss.NewStyle().Foreground(lipgloss.Color(subduedColor))
|
|
|
|
s.StatusBarActiveFilter = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(statusBarActiveFilterColor))
|
|
|
|
s.StatusBarFilterCount = lipgloss.NewStyle().Foreground(lipgloss.Color(verySubduedColor))
|
|
|
|
s.NoItems = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(noItemsColor))
|
|
|
|
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.Color(activePaginationColor)).
|
|
SetString(bullet)
|
|
|
|
s.InactivePaginationDot = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(verySubduedColor)).
|
|
SetString(bullet)
|
|
|
|
s.DividerDot = lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color(verySubduedColor)).
|
|
SetString(" " + bullet + " ")
|
|
|
|
return s
|
|
}
|