Skip to content

Commit

Permalink
fix: return color
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 14, 2024
1 parent 4de4322 commit 9a1d854
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions color.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var noColor = NoColor{}
type NoColor struct{}

func (NoColor) color(Profile, bool) ansi.Color {
return color.Black
return color.White
}

// RGBA returns the RGBA value of this color. Because we have to return
Expand All @@ -66,11 +66,12 @@ type Color string

// Color returns a color.Color from a hex or ANSI value (0-16, 16-255).
func (c Color) Color() (col ansi.Color) {
s := string(c)
if len(s) == 0 {
return noColor
col = noColor
if len(c) == 0 {
return
}

s := string(c)
if h, err := colorful.Hex(s); err == nil {
tc := uint32(h.R*255)<<16 + uint32(h.G*255)<<8 + uint32(h.B*255)

Check failure on line 76 in color.go

View workflow job for this annotation

GitHub Actions / lint-soft

Magic number: 255, in <argument> detected (gomnd)
col = ansi.TrueColor(tc)
Expand All @@ -84,7 +85,7 @@ func (c Color) Color() (col ansi.Color) {
}
}

return noColor
return
}

// RGBA returns the RGBA value of this color. This satisfies the Go Color
Expand Down

0 comments on commit 9a1d854

Please sign in to comment.