Skip to content

Commit

Permalink
chore: add missing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
op committed May 11, 2024
1 parent 0388514 commit 31924aa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ import (
Then initiate the theme the way that suits your needs.

```go
// use an adaptive theme that switches between light and dark depending on the
// terminal's color scheme
variant := catppuccin.Adaptive(catppuccin.Latte, catppuccin.Mocha)
log.SetStyles(catppuccin.New(variant))
```
4 changes: 4 additions & 0 deletions internal/themes/themes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import (
"github.com/op/redlog/pkg/catppuccin"
)

// Themes contains all available themes.
var Themes = []logtheme.Theme{
catppuccin.Theme,
}

// Default theme is catppuccin.
var Default = catppuccin.Theme

// ByName returns a theme by name.
func ByName(name string) (logtheme.Theme, bool) {
for _, t := range Themes {
if strings.EqualFold(t.Name, name) {
Expand All @@ -22,6 +25,7 @@ func ByName(name string) (logtheme.Theme, bool) {
return logtheme.Theme{}, false
}

// VariantByName returns a variant of a theme by name.
func VariantByName(t logtheme.Theme, name string) (logtheme.Variant, bool) {
for _, v := range t.Variants {
if strings.EqualFold(v.Name, name) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/catppuccin/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// Theme consists of 4 beautiful pastel color palettes. The theme comes in one
// light and three dark variants
// light and three dark variants.
var Theme = logtheme.New(
"Catppuccin",
newVariant(Adaptive(Latte, Mocha)),
Expand Down
4 changes: 3 additions & 1 deletion redlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
)

var (
ErrUnknownTheme = errors.New("unknown theme")
// ErrUnknownTheme is returned when a theme could not found.
ErrUnknownTheme = errors.New("unknown theme")
// ErrUnknownVariant is returned when a theme variant could not found.
ErrUnknownVariant = errors.New("unknown variant")
)

Expand Down

0 comments on commit 31924aa

Please sign in to comment.