From 7cdc0434a20f2286813f5e6300cf56c612f7b01c Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 5 Nov 2024 09:52:33 -0500 Subject: [PATCH] refactor(compat): accept any and use lipgloss.Color --- compat/color.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/compat/color.go b/compat/color.go index 1cc67a5b..c8c99d13 100644 --- a/compat/color.go +++ b/compat/color.go @@ -1,7 +1,6 @@ package compat import ( - "image/color" "os" "github.com/charmbracelet/colorprofile" @@ -27,25 +26,25 @@ var ( // // color := lipgloss.AdaptiveColor{Light: "#0000ff", Dark: "#000099"} type AdaptiveColor struct { - Light color.Color - Dark color.Color + Light any + Dark any } // RGBA returns the RGBA value of this color. This satisfies the Go Color // interface. func (c AdaptiveColor) RGBA() (uint32, uint32, uint32, uint32) { if HasDarkBackground { - return c.Dark.RGBA() + return lipgloss.Color(c.Dark).RGBA() } - return c.Light.RGBA() + return lipgloss.Color(c.Light).RGBA() } // CompleteColor specifies exact values for truecolor, ANSI256, and ANSI color // profiles. Automatic color degradation will not be performed. type CompleteColor struct { - TrueColor color.Color - ANSI256 color.Color - ANSI color.Color + TrueColor any + ANSI256 any + ANSI any } // RGBA returns the RGBA value of this color. This satisfies the Go Color @@ -53,11 +52,11 @@ type CompleteColor struct { func (c CompleteColor) RGBA() (uint32, uint32, uint32, uint32) { switch Profile { case colorprofile.TrueColor: - return c.TrueColor.RGBA() + return lipgloss.Color(c.TrueColor).RGBA() case colorprofile.ANSI256: - return c.ANSI256.RGBA() + return lipgloss.Color(c.ANSI256).RGBA() case colorprofile.ANSI: - return c.ANSI.RGBA() + return lipgloss.Color(c.ANSI).RGBA() } return lipgloss.NoColor{}.RGBA() }