Skip to content

Commit

Permalink
refactor: remove defaults package and use sync.Once
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 15, 2024
1 parent e4ce38c commit 1969fb5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
3 changes: 3 additions & 0 deletions default.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lipgloss

import (
"os"
"sync"

"github.com/charmbracelet/x/term"
)
Expand All @@ -16,6 +17,8 @@ var (
// HasLightBackground is true if the terminal has a light background.
// This is the default value used to create new styles.
HasLightBackground bool

onceStdDefaults sync.Once
)

// UseDefault will set the default color profile and background color detection
Expand Down
26 changes: 0 additions & 26 deletions defaults/defaults.go

This file was deleted.

1 change: 1 addition & 0 deletions style.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (p props) has(k propKey) bool {
// Style{} primitive, it's recommended to use this function for creating styles
// in case the underlying implementation changes.
func NewStyle() Style {
onceStdDefaults.Do(UseStdDefaults)
return Style{
profile: ColorProfile,
hasLightBackground: HasLightBackground,
Expand Down

0 comments on commit 1969fb5

Please sign in to comment.