-
Notifications
You must be signed in to change notification settings - Fork 172
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
feat(editor): add responsive utils #6716
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#15410 Bundle Size — 58.21MiB (~+0.01%).cdbebeb(current) vs d1d46c1 master#15407(baseline) Warning Bundle contains 70 duplicate packages – View duplicate packages Bundle metrics
|
Current #15410 |
Baseline #15407 |
|
---|---|---|
Initial JS | 41.18MiB (~+0.01% ) |
41.18MiB |
Initial CSS | 0B |
0B |
Cache Invalidation | 18.24% |
18.12% |
Chunks | 20 |
20 |
Assets | 22 |
22 |
Modules | 4189 |
4189 |
Duplicate Modules | 213 |
213 |
Duplicate Code | 27.24% |
27.24% |
Packages | 477 |
477 |
Duplicate Packages | 70 |
70 |
Bundle size by type 2 changes
1 regression
1 improvement
Current #15410 |
Baseline #15407 |
|
---|---|---|
JS | 58.2MiB (~+0.01% ) |
58.2MiB |
HTML | 9.4KiB (-0.21% ) |
9.42KiB |
Bundle analysis report Branch feat/responsive-utils Project dashboard
Generated by RelativeCI Documentation Report issue
liady
requested review from
gbalint,
seanparsons,
Rheeseyb,
ruggi,
balazsbajorics,
enidemi and
bkrmendy
December 10, 2024 09:56
bkrmendy
approved these changes
Dec 11, 2024
ruggi
approved these changes
Dec 11, 2024
2 tasks
liady
added a commit
that referenced
this pull request
Dec 13, 2024
This prep PR adds the responsive utilities we'll use in our responsive PR, along with types and tests. The important utilities (that are exposed outside) are: 1. `extractScreenSizeFromCss(css: string)` - which recieves a CSS string of the media query (i.e `@media (min-width: 100px)`) and turns it into a `ScreenSize` object (in our example - `{ min: {value: 100, unit: 'px'} }`). We also support media ranges (`@media (20px < width < 50em)`). This function is covered in tests. It uses `mediaQueryToScreenSize(mediaQuery: MediaQuery)` internally, which takes a `MediaQuery` object (after it was parsed from the CSS string), and does the "heavy lifting" of converting it to a `ScreenSize` representation. This inner function is also covered in tests. 2. `selectValueByBreakpoint` - this function recieves a list of possible variants (values with corresponding `ScreenSize`s which they apply in), and the current Scene size. It infers the most matching variant according to the Scene size (can also be the default variant if none are matching). This function is also fully covered in tests. No functionality is added to the app itself, this is just a prep PR for the functionality in the subsequent PR. **Manual Tests:** I hereby swear that: - [X] I opened a hydrogen project and it loaded - [X] I could navigate to various routes in Play mode
liady
added a commit
that referenced
this pull request
Dec 13, 2024
…6723) This PR adds the ability to display the correct value in the controller according to the Scene size. For example - if the element has `className='pt-[20px] lg:pt-[150px] md:pt-[110px]`, and the Scene has a width of `1000px` (which is larger than `md` but smaller than `lg`) - the `paddingTop` control will correctly show `110px`. **Details:** - This PR augments `ParsedCSSStyleProperty`, so instead of containing just the `value` it now holds: - a list of `variants` (the possible values and for each one the `modifier`s that when applied, the value is chosen. a screen size is a modifier) - the `currentVariant` - which is the value that is currently selected according to the Scene size. - After parsing the Tailwind classes using the 3rd-party parser (as before), we call `getModifiers`, that converts the Tailwind specific variants from the parser representation that looks like: ```ts {type: 'media', value: 'sm'} ``` to our generic representation: ```ts { type: 'media-size', size: { min: { value: 0, unit: 'px' }, max: { value: 100, unit: 'em' } } } ``` - The `getModifiers` function uses an interal `screensConfigToScreenSizes` function - that parses the Tailwind config to have a map of `<screenAlias>` to `ScreenSize` - Both are covered in tests in `tailwind-responsive-utils.spec.ts` - This PR uses the utils that were merged in #6716 (specifically `selectValueByBreakpoint` to select the best matching variant) **Example (note that this PR *does not* contain the Scene resize buttons):** <video src="https://github.com/user-attachments/assets/90bb37ee-9aae-4563-9ddc-57a869a69ad5"></video> **Manual Tests:** I hereby swear that: - [X] I opened a hydrogen project and it loaded - [X] I could navigate to various routes in Play mode
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This prep PR adds the responsive utilities we'll use in our responsive PR, along with types and tests.
The important utilities (that are exposed outside) are:
extractScreenSizeFromCss(css: string)
- which recieves a CSS string of the media query (i.e@media (min-width: 100px)
) and turns it into aScreenSize
object (in our example -{ min: {value: 100, unit: 'px'} }
). We also support media ranges (@media (20px < width < 50em)
). This function is covered in tests.It uses
mediaQueryToScreenSize(mediaQuery: MediaQuery)
internally, which takes aMediaQuery
object (after it was parsed from the CSS string), and does the "heavy lifting" of converting it to aScreenSize
representation. This inner function is also covered in tests.selectValueByBreakpoint
- this function recieves a list of possible variants (values with correspondingScreenSize
s which they apply in), and the current Scene size. It infers the most matching variant according to the Scene size (can also be the default variant if none are matching). This function is also fully covered in tests.No functionality is added to the app itself, this is just a prep PR for the functionality in the subsequent PR.
Manual Tests:
I hereby swear that: