mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
feat: add a Styler interface for styling bubbles
This change introduces a Styler interface that allows users to define custom styles for bubbles. The interface is implemented by the StylerFunc type, which is a function type that takes a boolean argument and returns a value of any type. This allows a user to define a custom StylerFunc that returns a custom style for a bubble based on the background color of the terminal.
This commit is contained in:
+4
-6
@@ -94,16 +94,14 @@ type DefaultDelegate struct {
|
||||
}
|
||||
|
||||
// NewDefaultDelegate creates a new delegate with default styles.
|
||||
func NewDefaultDelegate() DefaultDelegate {
|
||||
func NewDefaultDelegate(isDark bool) DefaultDelegate {
|
||||
const defaultHeight = 2
|
||||
const defaultSpacing = 1
|
||||
return DefaultDelegate{
|
||||
ShowDescription: true,
|
||||
// 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,
|
||||
Styles: NewDefaultItemStyles(isDark),
|
||||
height: defaultHeight,
|
||||
spacing: defaultSpacing,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user