Skip to content

Commit

Permalink
fix(examples): use latest Color func
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Dec 9, 2024
1 parent 59cbf28 commit 327b3e9
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 75 deletions.
24 changes: 17 additions & 7 deletions examples/color/bubbletea/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,36 @@ func newStyles(backgroundIsDark bool) (s *styles) {
// appropriate light or dark color based on the detected background color.
s.frame = lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lightDark("#C5ADF9", "#864EFF")).
BorderForeground(lightDark(
lipgloss.Color("#C5ADF9"),
lipgloss.Color("#864EFF"))).
Padding(1, 3).
Margin(1, 3)
s.paragraph = lipgloss.NewStyle().
Width(40).
MarginBottom(1).
Align(lipgloss.Center)
s.text = lipgloss.NewStyle().
Foreground(lightDark("#696969", "#bdbdbd"))
Foreground(lightDark(
lipgloss.Color("#696969"),
lipgloss.Color("#bdbdbd")))
s.keyword = lipgloss.NewStyle().
Foreground(lightDark("#37CD96", "#22C78A")).
Foreground(lightDark(
lipgloss.Color("#37CD96"),
lipgloss.Color("#22C78A"))).
Bold(true)

s.activeButton = lipgloss.NewStyle().
Padding(0, 3).
Background(lipgloss.Color(0xFF6AD2)). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color(0xFFFCC2))
Background(lipgloss.Color("0xFF6AD2")). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color("0xFFFCC2"))
s.inactiveButton = s.activeButton.
Background(lightDark(0x988F95, 0x978692)).
Foreground(lightDark(0xFDFCE3, 0xFBFAE7))
Background(lightDark(
lipgloss.Color("0x988F95"),
lipgloss.Color("0x978692"))).
Foreground(lightDark(
lipgloss.Color("0xFDFCE3"),
lipgloss.Color("0xFBFAE7")))
return s
}

Expand Down
21 changes: 8 additions & 13 deletions examples/color/standalone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package main

import (
"fmt"
"os"

"github.com/charmbracelet/lipgloss/v2"
Expand All @@ -18,11 +17,7 @@ func main() {
// when using Lip Gloss standalone.
//
// In Bubble Tea listen for tea.BackgroundColorMsg in your Update.
hasDarkBG, err := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not detect background color: %v\n", err)
os.Exit(1)
}
hasDarkBG := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)

// Create a new helper function for choosing either a light or dark color
// based on the detected background color.
Expand All @@ -32,26 +27,26 @@ func main() {
// appropriate light or dark color based on the detected background color.
frameStyle := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lightDark("#C5ADF9", "#864EFF")).
BorderForeground(lightDark(lipgloss.Color("#C5ADF9"), lipgloss.Color("#864EFF"))).
Padding(1, 3).
Margin(1, 3)
paragraphStyle := lipgloss.NewStyle().
Width(40).
MarginBottom(1).
Align(lipgloss.Center)
textStyle := lipgloss.NewStyle().
Foreground(lightDark("#696969", "#bdbdbd"))
Foreground(lightDark(lipgloss.Color("#696969"), lipgloss.Color("#bdbdbd")))
keywordStyle := lipgloss.NewStyle().
Foreground(lightDark("#37CD96", "#22C78A")).
Foreground(lightDark(lipgloss.Color("#37CD96"), lipgloss.Color("#22C78A"))).
Bold(true)

activeButton := lipgloss.NewStyle().
Padding(0, 3).
Background(lipgloss.Color(0xFF6AD2)). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color(0xFFFCC2))
Background(lipgloss.Color("0xFF6AD2")). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color("0xFFFCC2"))
inactiveButton := activeButton.
Background(lightDark(0x988F95, 0x978692)).
Foreground(lightDark(0xFDFCE3, 0xFBFAE7))
Background(lightDark(lipgloss.Color("0x988F95"), lipgloss.Color("0x978692"))).
Foreground(lightDark(lipgloss.Color("0xFDFCE3"), lipgloss.Color("0xFBFAE7")))

// Build layout.
text := paragraphStyle.Render(
Expand Down
8 changes: 4 additions & 4 deletions examples/compat/bubbletea/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var (
frameColor = compat.AdaptiveColor{Light: lipgloss.Color("#C5ADF9"), Dark: lipgloss.Color("#864EFF")}
textColor = compat.AdaptiveColor{Light: lipgloss.Color("#696969"), Dark: lipgloss.Color("#bdbdbd")}
keywordColor = compat.AdaptiveColor{Light: lipgloss.Color("#37CD96"), Dark: lipgloss.Color("#22C78A")}
inactiveBgColor = compat.AdaptiveColor{Light: lipgloss.Color(0x988F95), Dark: lipgloss.Color(0x978692)}
inactiveFgColor = compat.AdaptiveColor{Light: lipgloss.Color(0xFDFCE3), Dark: lipgloss.Color(0xFBFAE7)}
inactiveBgColor = compat.AdaptiveColor{Light: lipgloss.Color("0x988F95"), Dark: lipgloss.Color("0x978692")}
inactiveFgColor = compat.AdaptiveColor{Light: lipgloss.Color("0xFDFCE3"), Dark: lipgloss.Color("0xFBFAE7")}
)

// Style definitions.
Expand Down Expand Up @@ -48,8 +48,8 @@ func newStyles() (s styles) {

s.activeButton = lipgloss.NewStyle().
Padding(0, 3).
Background(lipgloss.Color(0xFF6AD2)). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color(0xFFFCC2))
Background(lipgloss.Color("0xFF6AD2")). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color("0xFFFCC2"))
s.inactiveButton = s.activeButton.
Background(inactiveBgColor).
Foreground(inactiveFgColor)
Expand Down
8 changes: 4 additions & 4 deletions examples/compat/standalone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ var (
frameColor = compat.AdaptiveColor{Light: lipgloss.Color("#C5ADF9"), Dark: lipgloss.Color("#864EFF")}
textColor = compat.AdaptiveColor{Light: lipgloss.Color("#696969"), Dark: lipgloss.Color("#bdbdbd")}
keywordColor = compat.AdaptiveColor{Light: lipgloss.Color("#37CD96"), Dark: lipgloss.Color("#22C78A")}
inactiveBgColor = compat.AdaptiveColor{Light: lipgloss.Color(0x988F95), Dark: lipgloss.Color(0x978692)}
inactiveFgColor = compat.AdaptiveColor{Light: lipgloss.Color(0xFDFCE3), Dark: lipgloss.Color(0xFBFAE7)}
inactiveBgColor = compat.AdaptiveColor{Light: lipgloss.Color("0x988F95"), Dark: lipgloss.Color("0x978692")}
inactiveFgColor = compat.AdaptiveColor{Light: lipgloss.Color("0xFDFCE3"), Dark: lipgloss.Color("0xFBFAE7")}
)

func main() {
Expand All @@ -39,8 +39,8 @@ func main() {

activeButton := lipgloss.NewStyle().
Padding(0, 3).
Background(lipgloss.Color(0xFF6AD2)). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color(0xFFFCC2))
Background(lipgloss.Color("0xFF6AD2")). // you can also use octal format for colors, i.e 0xff38ec.
Foreground(lipgloss.Color("0xFFFCC2"))
inactiveButton := activeButton.
Background(inactiveBgColor).
Foreground(inactiveFgColor)
Expand Down
10 changes: 4 additions & 6 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ replace github.com/charmbracelet/lipgloss/v2 => ../

require (
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20241031200731-4f70d4c680b8
github.com/charmbracelet/colorprofile v0.1.6
github.com/charmbracelet/colorprofile v0.1.8
github.com/charmbracelet/lipgloss/v2 v2.0.0-20241101153040-904e60506df7
github.com/charmbracelet/ssh v0.0.0-20240401141849-854cddfa2917
github.com/charmbracelet/wish v1.4.0
github.com/charmbracelet/x/term v0.2.0
github.com/charmbracelet/x/term v0.2.1
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/rivo/uniseg v0.4.7
)
Expand All @@ -22,14 +22,12 @@ require (
github.com/charmbracelet/keygen v0.5.0 // indirect
github.com/charmbracelet/lipgloss v0.13.1-0.20240822211938-b89f1a3db2a4 // indirect
github.com/charmbracelet/log v0.4.0 // indirect
github.com/charmbracelet/x/ansi v0.4.2 // indirect
github.com/charmbracelet/x/ansi v0.5.1 // indirect
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 // indirect
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd // indirect
github.com/charmbracelet/x/input v0.2.0 // indirect
github.com/charmbracelet/x/windows v0.2.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
Expand All @@ -42,7 +40,7 @@ require (
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
Expand Down
21 changes: 8 additions & 13 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/charmbracelet/bubbletea v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt
github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20241031200731-4f70d4c680b8 h1:qm5hqKutTe3DcJHlEghLlZxBoKv+hqa8avqEUiSKIZY=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.1.0.20241031200731-4f70d4c680b8/go.mod h1:/w0ccIhyZqnVm+47JBkA/872fruM99gHxXTibc2kEMY=
github.com/charmbracelet/colorprofile v0.1.6 h1:nMMqCns0c0DfCwNGdagBh6SxutFqkltSxxKk5S9kt+Y=
github.com/charmbracelet/colorprofile v0.1.6/go.mod h1:3EMXDxwRDJl0c17eJ1jX99MhtlP9OxE/9Qw0C5lvyUg=
github.com/charmbracelet/colorprofile v0.1.8 h1:PywDeXsiAzlPtkiiKgMEVLvb6nlEuKrMj9+FJBtj4jU=
github.com/charmbracelet/colorprofile v0.1.8/go.mod h1:+jpmObxZl1Dab3H3IMVIPSZTsKcFpjJUv97G0dLqM60=
github.com/charmbracelet/keygen v0.5.0 h1:XY0fsoYiCSM9axkrU+2ziE6u6YjJulo/b9Dghnw6MZc=
github.com/charmbracelet/keygen v0.5.0/go.mod h1:DfvCgLHxZ9rJxdK0DGw3C/LkV4SgdGbnliHcObV3L+8=
github.com/charmbracelet/lipgloss v0.13.1-0.20240822211938-b89f1a3db2a4 h1:BuZojjzjQ89wObGNVxJzFqyeh2S6Crbwhybb8bZNveI=
Expand All @@ -19,26 +19,22 @@ github.com/charmbracelet/ssh v0.0.0-20240401141849-854cddfa2917 h1:NZKjJ7d/pzk/A
github.com/charmbracelet/ssh v0.0.0-20240401141849-854cddfa2917/go.mod h1:8/Ve8iGRRIGFM1kepYfRF2pEOF5Y3TEZYoJaA54228U=
github.com/charmbracelet/wish v1.4.0 h1:pL1uVP/YuYgJheHEj98teZ/n6pMYnmlZq/fcHvomrfc=
github.com/charmbracelet/wish v1.4.0/go.mod h1:ew4/MjJVfW/akEO9KmrQHQv1F7bQRGscRMrA+KtovTk=
github.com/charmbracelet/x/ansi v0.4.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk=
github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/ansi v0.5.1 h1:+mg6abP9skvsu/JQZrIJ9Z/4O1YDnLVkpfutar3dUnc=
github.com/charmbracelet/x/ansi v0.5.1/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651 h1:3RXpZWGWTOeVXCTv0Dnzxdv/MhNUkBfEcbaTY0zrTQI=
github.com/charmbracelet/x/errors v0.0.0-20240117030013-d31dba354651/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
github.com/charmbracelet/x/exp/golden v0.0.0-20240806155701-69247e0abc2a h1:G99klV19u0QnhiizODirwVksQB91TJKV/UaTnACcG30=
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd h1:HqBjkSFXXfW4IgX3TMKipWoPEN08T3Pi4SA/3DLss/U=
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd/go.mod h1:6GZ13FjIP6eOCqWU4lqgveGnYxQo9c3qBzHPeFu4HBE=
github.com/charmbracelet/x/input v0.2.0 h1:1Sv+y/flcqUfUH2PXNIDKDIdT2G8smOnGOgawqhwy8A=
github.com/charmbracelet/x/input v0.2.0/go.mod h1:KUSFIS6uQymtnr5lHVSOK9j8RvwTD4YHnWnzJUYnd/M=
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/charmbracelet/x/windows v0.2.0 h1:ilXA1GJjTNkgOm94CLPeSz7rar54jtFatdmoiONPuEw=
github.com/charmbracelet/x/windows v0.2.0/go.mod h1:ZibNFR49ZFqCXgP76sYanisxRyC+EYrBE7TTknD8s1s=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
Expand Down Expand Up @@ -72,11 +68,10 @@ golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
Expand Down
20 changes: 7 additions & 13 deletions examples/layout/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ var (
)

func init() {
var err error

// Detect the background color.
hasDarkBG, err = lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not detect background color: %v\n", err)
os.Exit(1)
}
hasDarkBG = lipgloss.HasDarkBackground(os.Stdin, os.Stdout)

// Create a new helper function for choosing either a light or dark color
// based on the detected background color.
Expand All @@ -55,9 +49,9 @@ func main() {

// General.

subtle = lightDark("#D9DCCF", "#383838")
highlight = lightDark("#874BFD", "#7D56F4")
special = lightDark("#43BF6D", "#73F59F")
subtle = lightDark(lipgloss.Color("#D9DCCF"), lipgloss.Color("#383838"))
highlight = lightDark(lipgloss.Color("#874BFD"), lipgloss.Color("#7D56F4"))
special = lightDark(lipgloss.Color("#43BF6D"), lipgloss.Color("#73F59F"))

divider = lipgloss.NewStyle().
SetString("•").
Expand Down Expand Up @@ -169,7 +163,7 @@ func main() {
listDone = func(s string) string {
return checkMark + lipgloss.NewStyle().
Strikethrough(true).
Foreground(lightDark("#969B86", "#696969")).
Foreground(lightDark(lipgloss.Color("#969B86"), lipgloss.Color("#696969"))).
Render(s)
}

Expand All @@ -191,8 +185,8 @@ func main() {
Padding(0, 1)

statusBarStyle = lipgloss.NewStyle().
Foreground(lightDark("#343433", "#C1C6B2")).
Background(lightDark("#D9DCCF", "#353533"))
Foreground(lightDark(lipgloss.Color("#343433"), lipgloss.Color("#C1C6B2"))).
Background(lightDark(lipgloss.Color("#D9DCCF"), lipgloss.Color("#353533")))

statusStyle = lipgloss.NewStyle().
Inherit(statusBarStyle).
Expand Down
11 changes: 3 additions & 8 deletions examples/list/sublist/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"

"github.com/charmbracelet/lipgloss/v2"
Expand All @@ -11,11 +10,7 @@ import (
)

func main() {
hasDarkBG, err := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not detect background color: %v\n", err)
os.Exit(1)
}
hasDarkBG := lipgloss.HasDarkBackground(os.Stdin, os.Stdout)

lightDark := lipgloss.LightDark(hasDarkBG)

Expand All @@ -36,7 +31,7 @@ func main() {
dim := lipgloss.Color("250")
highlight := lipgloss.Color("#EE6FF8")

special := lightDark("#43BF6D", "#73F59F")
special := lightDark(lipgloss.Color("#43BF6D"), lipgloss.Color("#73F59F"))

checklistEnumStyle := func(items list.Items, index int) lipgloss.Style {
switch index {
Expand All @@ -63,7 +58,7 @@ func main() {
case 1, 2, 4:
return lipgloss.NewStyle().
Strikethrough(true).
Foreground(lightDark("#969B86", "#696969"))
Foreground(lightDark(lipgloss.Color("#969B86"), lipgloss.Color("#696969")))
default:
return lipgloss.NewStyle()
}
Expand Down
13 changes: 6 additions & 7 deletions examples/ssh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ func handler(next ssh.Handler) ssh.Handler {
styles.gray,
)

hasDarkBG, err := lipgloss.HasDarkBackground(pty.Slave, pty.Slave)
if err != nil {
log.Print("Could not detect background color: %w", err)
return
}

hasDarkBG := lipgloss.HasDarkBackground(pty.Slave, pty.Slave)
lightDark := lipgloss.LightDark(hasDarkBG)

fmt.Fprintf(&str, "%s %s\n\n",
Expand All @@ -123,7 +118,11 @@ func handler(next ssh.Handler) ssh.Handler {
block := lipgloss.Place(width,
lipgloss.Height(str.String()), lipgloss.Center, lipgloss.Center, str.String(),
lipgloss.WithWhitespaceChars("/"),
lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Foreground(lightDark(250, 236))),
lipgloss.WithWhitespaceStyle(
lipgloss.NewStyle().Foreground(lightDark(
lipgloss.ANSIColor(250),
lipgloss.ANSIColor(236),
))),
)

// Render to client.
Expand Down

0 comments on commit 327b3e9

Please sign in to comment.