[CSS-in-JS] Convert EuiBreakpoint Mixin to Emotion#6057
[CSS-in-JS] Convert EuiBreakpoint Mixin to Emotion#6057breehall merged 15 commits intoelastic:mainfrom
Conversation
… validation functions
…n conditions to allow consumers the flexibility of obtaining a min-width, max-width, or min and max width media query from a variety of different scenarios
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
|
👋🏾 Hey Greg and Constance, I can go through and clean up some of my comments after the reviews are good. I just wanted to make sure that my thought process matched our goal here. Also, I know the validation might look like a lot, but the more I added conditions to account for |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
| | '0' | ||
| | 'infinity' |
There was a problem hiding this comment.
We should likely be using the numeric version of these for easier type checking:
| | '0' | |
| | 'infinity' | |
| | 0 | |
| | Infinity |
I don't think we need to consider this a breaking change. The previous mixin was written in Sass and this is more of a port than a refactor. Any one choosing to "upgrade" to the JS version will be working with new APIs outside of Sass. Probably worth noting the difference(s) in a code comment in |
- Prefer types from theme instead of the breakpoints service (which likely needs to be refactored to use the theme) - simplify output to use array logic to output/concatenate a string - Remove undefined type - improve unit tests: - catch console warn conditions - don't snapshot invalid/uncommon size combos
|
@breehall I realize I was a little unspecific with what I wanted in the euiBreakpoint I've created a local spike that simplifies the checks/warnings as well as adds more specific unit tests. Let me know what you think! If you think it's an improvement, feel free to cherry-pick it in. FYI, we'll almost certainly want to document this new function in https://elastic.github.io/eui/#/theming/breakpoints/values. There might need to be more updates down the road as |
[PR feedback] Simplify branching logic and typing
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
|
@thompsongl Any feedback on the revised function/logic? @breehall I think this is good to move forward with removing the breaking change changelog line and adding documentation to the Breakpoints CSS-in-JS utils! |
|
Nope, let's start adding documentation 👍 |
…into emotion/breakpoint Merging in latest code from eui/breakpoint
@constancecchen Gotcha! I've added documentation to the Breakpoints page in the docs. I only added an entry for the hook because there's no variation between the hook and the function. Part of me would like to see two examples here, but I believe that would break a pattern as no other examples have two code snippets. |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
Let's add a new entry for the function version. Not just another snippet, but another |
…or the euiBreakpoing function
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
@thompsongl I don't think we do this anywhere else, actually. It looks like if a non-hook and a hook util both exist, we document the hook version only (the most likely version for consumers to use, the non-hook version is most likely to only be used internally by EUI). For example, our color utilities: https://eui.elastic.co/pr_6057/#/theming/colors/utilities |
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
|
@constancecchen I'm not sure why I can't respond to the comment about the imports, but as you commented, I just pushed a commit cleaning them up. |
|
Haha sike! Nobody saw that last comment @thompsongl I think this is good to merge on my end - any objections/change requests to the docs? |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
Co-authored-by: Greg Thompson <thompson.glowe@gmail.com>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6057/ |
Summary
Converted the
euiBreakpointmixin to Emotion and created a hook for use within components. Unlike the Sass mixin, the JS mixin allows creating media queries with just(min-width)and(max-width)via the0andInfinityargs.Example:
euiBreakpoint(['m', Infinity])becomes@media only screen and (min-width: 768px)euiBreakpoint([0, 'm'])becomes@media only screen and (max-width: 767px)Checklist
[ ] Checked in both light and dark modes[ ] Checked in Chrome, Safari, Edge, and Firefox[ ] Props have proper autodocs and **[playground toggles](https://github.com/elastic/eui/blob/main/wiki/documentation-guidelines.md#adding-playground-toggles)**[ ] Checked Code Sandbox works for any docs examples[ ] Checked for accessibility including keyboard-only and screenreader modes[ ] Updated the Figma library counterpart