-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(v2) feat: add adaptive color package #359
Conversation
This introduces a helper type `LightDark` that takes a boolean to determine which `Color(light, dark)` to choose from. The `adaptive` package is a helper package that uses the `lipgloss.LightDark` along with querying the terminal when the module is imported to choose the appropriate light-dark color. Example: ```go var ( light = "#0000ff" dark = "#ff0000" ) colorToUse := adaptive.Color(light, dark) // the terminal is queried before choosing the color fmt.Println(colorToUse) ```
// dark := "#ff0000" | ||
// colorToUse := useDark.Color(light, dark) | ||
// fmt.Println(colorToUse) | ||
type LightDark bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about naming this Adapt
instead? Might feel more familiar.
Then it could be
adaptive := lipgloss.Adapt(true)
colors := adaptive.Color("#0000ff", "#ff0000")
I think that would make the purpose more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally: this is really nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also update the comment to show use with Bubble Tea, as well as standalone Lip Gloss (when we get there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of dropping this type which is basically an ifelse; the adaptive sub-package should be enough imo
// dark := "#ff0000" | ||
// colorToUse := useDark.Color(light, dark) | ||
// fmt.Println(colorToUse) | ||
type LightDark bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also update the comment to show use with Bubble Tea, as well as standalone Lip Gloss (when we get there).
This introduces a helper type
LightDark
that takes a boolean to determine whichColor(light, dark)
to choose from. Theadaptive
package is a helper package that uses thelipgloss.LightDark
along with querying the terminal when the module is imported to choose the appropriate light-dark color.This will also make
lipgloss.Color
takeany
type and try to infer the color from either strings or integers.Example: