mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
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.
16 lines
380 B
Go
16 lines
380 B
Go
package bubbles
|
|
|
|
// Styler represents an interface for styling bubbles.
|
|
type Styler[T any] interface {
|
|
Styles(isDark bool) T
|
|
}
|
|
|
|
// StylerFunc is a function type that implements the Styler interface.
|
|
type StylerFunc[T any] func(isDark bool) T
|
|
|
|
// Styles calls the function.
|
|
// It implements the Styler interface.
|
|
func (f StylerFunc[T]) Styles(isDark bool) T {
|
|
return f(isDark)
|
|
}
|