Skip to content

Commit

Permalink
feat: add Default to catppuccin
Browse files Browse the repository at this point in the history
  • Loading branch information
op committed May 11, 2024
1 parent c2ec968 commit f81efbd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/catppuccin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,39 @@ flavors. The theme comes in one light and three dark variants.

* 🍀 *Mocha* is the original and the darkest variant, offering a cozy feeling
with color-rich accents.

## Usage

Use `go get` to download the dependency.

```bash
go get github.com/op/redlog/pkg/catppuccin@latest
```

Then, `import` it in Go files:

```go
import (
"github.com/charmbracelet/log"
"github.com/op/redlog/pkg/catppuccin"
)
```

The package comes with a `Default` you can use.

```go
log.SetStyles(catppuccin.Default.Styles)
slog.SetDefault(slog.New(log.Default()))
```

To use a specific variant, request it by name.

```go
// logger always uses Macchiato
logger := log.New(os.Stderr)
logger.SetStyles(catppuccin.Macchiato.Styles)

// update default styles to use an adaptive theme
variant := catppuccin.Adaptive(catppuccin.Latte, catppuccin.Mocha)
log.SetStyles(catppuccin.New(variant))
```
4 changes: 4 additions & 0 deletions pkg/catppuccin/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ var Theme = logtheme.New(
},
)

// Default is the default Catppuccin variant which is an adaptive flavour using
// Latte for light backgrounds and Mocha for dark backgrounds.
var Default = Theme.Default

func hexColor(c lipgloss.TerminalColor) string {
if c, ok := c.(lipgloss.Color); ok {
hex := string(c)
Expand Down

0 comments on commit f81efbd

Please sign in to comment.