-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Refactor some screen compatibility code #14438
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
Conversation
|
@philipp-spiess |
@thecrypticace Pushed a commit that fixes that :) The value parser is actually not the issue here, it's that we were only looking into |
b4e83e8 to
ea69d99
Compare
57aa89b to
153a22b
Compare
This will ensure that a breakpoint defined with an object like `lg: { min: "1280px" }` will also support `max-lg:*`
153a22b to
28f0c84
Compare
screen() in CSSscreen() function in CSS
philipp-spiess
left a comment
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.
It's still not great that we now have the screen function checks in core but this way the legacy implementation is at least contained.
Just brainstorming here, but one way to clean this up even further is by adding another walk for function replacement in the compat layer and we'd need a way for the compat layer to hook into the build calls (since we do a function substitution there first).
Other idea is that we do the function replacement after the core layer and have a dictionary of functions that we can register (just like our Utilities and Variants maps). Then, the compat layer could push custom functions into it.
| // Replace `resolveBreakpointQuery` with a version that can handle more | ||
| // complex breakpoint queries like objects, tuples, and custom media queries | ||
| // that are present in JS theme configurations. | ||
| designSystem.resolveBreakpointQuery = function resolveBreakpointQuery(name: string) { | ||
| return buildMediaQuery(pluginApi.theme(`screens.${name}`)) | ||
| } |
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!
c510a81 to
ac95ff1
Compare
screen() function in CSS|
We've decided to do this as a code mod instead — I'll be landing some of the refactoring tweaks in a separate PR. |
This adds support for the
screen(…)CSS function which can be used to build the media queries for a given breakpoint:Input:
output:
We also support more advanced
screensconfigurations from configuration files (mainly for backwards) compat:Output: