-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Update color CSS variables in Liquid to only use RGB #97
Conversation
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.
👍 overall, nice cleanup!
assets/collage.css
Outdated
@@ -397,7 +397,7 @@ | |||
left: 0; | |||
overflow: auto; | |||
width: 100%; | |||
background: rgba(var(--color-base-text-rgb), 0.2); | |||
background: var(--color-foreground-20); |
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.
Not a fan of these "percentage" variables. I think rgba(var(--color-base-text-rgb), 0.2)
is more readable. What do we gain by using variables that mimic rgba
?
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.
Mostly to make the CSS a bit less verbose
div {
color: rgba(var(--color-foreground-rgb), 0.2);
}
div {
color: var(--color-foreground-20);
}
But yes I think we can use the former instead of the latter if it's less ambiguous
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.
@Thibaut Updated. See details
assets/base.css
Outdated
--color-foreground: rgb(var(--color-base-text)); | ||
--color-foreground-rgb: var(--color-base-text); |
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 find this a bit confusing—I'd expect -rgb
to be the one with the rgb
function attached. Thoughts on instead having a single color, e.g. --color-foreground: var(--color-base-text)
for both so we can rely on a single custom property for all references?
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.
Then the one thing about this approach as I was thinking about it is that we need to add rbg(...)
around the var(--color-base-text)
variables in a few files which then adds more lines/characters overall.
But I do find it clearer to have one single custom property rather than 2.
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 like that suggestion. We just need to ensure we don't introduce another kind of ambiguity:
Currently we have 2 tyoes of color variables:
- with suffix
rgb
- meant to be wrapped withrgb(...)
orrgba(...)
- without suffix
rgb
- meant to be used as-is
By getting rid of rgb
suffix type variables, when using a variable, it's not immediately clear if we need to wrap a variable in rgb(...)
or not.
Example:
:root,
.color-background-1 {
--color-link: var(--color-base-outline-button-labels);
--color-link-hover: rgba(var(--color-base-outline-button-labels), 0.85);
}
.color-background-2,
.color-inverse,
.color-accent-1,
.color-accent-2 {
--color-link: var(--color-foreground);
--color-link-hover: rgba(var(--color-foreground), 0.7);
}
--color-link
would need to be wrapped in rgb(...)
, but --color-link-hover
would be used as-is.
Trying to figure out an approach that would avoid this ambiguity.
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.
@chrisberthe Updated. See details
assets/base.css
Outdated
--color-foreground: rgb(var(--color-base-text)); | ||
--color-foreground-rgb: var(--color-base-text); |
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.
Then the one thing about this approach as I was thinking about it is that we need to add rbg(...)
around the var(--color-base-text)
variables in a few files which then adds more lines/characters overall.
But I do find it clearer to have one single custom property rather than 2.
Co-authored-by: Chris Berthe <[email protected]>
Co-authored-by: Chris Berthe <[email protected]>
Co-authored-by: Chris Berthe <[email protected]>
…fy/dawn into fix-color-system-variables
UpdateFollowing feedback, these updates were made: 1. All color variables are now in
|
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.
This is great, thanks for updating 👍🏻 Will approve once this comment is addressed.
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.
Looks good to me 👌
Left a comment to remove a variable where it's not needed.
I do feel like we're losing in ease of customization by hard coding the alpha value in quite a few places vs having css variables set for the different alpha values we need across the theme (like we had with var(--color-foreground-20)
).
I did find the variable names straight forward and if you'd need to make a change then you can update it across the theme in one place rather than having to search for each 0.2
values for example.
Not sure how often we will come across the situation where the opacity will need to be changed (designers choose to make a change to the theme or theme support customization for individual merchants) but something to keep in mind 🤔
cc: @Thibaut
--color-foreground-8: rgba(var(--color-foreground-rgb), 0.08); | ||
--color-foreground-4: rgba(var(--color-foreground-rgb), 0.04); | ||
--color-foreground-3: rgba(var(--color-foreground-rgb), 0.03); | ||
} |
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.
Removing those I guess makes it a little longer to update if ever needed when we go back and forth with designers.
…-system-variables # Conflicts: # assets/template-collection.css
…-system-variables # Conflicts: # assets/section-main-product.css
Hi ! I really like the approach of using one variable, that is used either in rgb() or rgba() filter based on the use case. Here are a few additions that would make it simpler to work with colors:
It would assign settings.background if the "section" color is set to rgba(0,0,0,0). We are using a lot of sections where we want to fallback on default color if none has been set. |
To illustrate a bit more, here is what we have all over our new theme: I would love to be able to rewrite those with something like that:
The "rgb" would be a new value for color_extract that would automatically output the three components (but without the "rgb()" part as the color_to_rgb does. Would that be doable? It would remove ton of boilerplate code here. |
Why are these changes introduced?
Address #83 (comment)
What approach did you take?
Before
After
giftcard
template andpassword
layoutOther considerations
Also explored (but did not include in this PR) a solution for addressing:
Potential solution adds some unwanted complexity to color system, so a separate issue will be created to allow for further exploration and discussion.
Demo links
Checklist