-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
db64e3c
commit 8fdc81c
Showing
8 changed files
with
34 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters