Skip to content
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

Media queries handling for responsive design #9

Open
hugoattal opened this issue Feb 3, 2022 · 7 comments
Open

Media queries handling for responsive design #9

hugoattal opened this issue Feb 3, 2022 · 7 comments

Comments

@hugoattal
Copy link
Collaborator

hugoattal commented Feb 3, 2022

I know this is a long shot, and we certainly won't focus on this in the short term.
But we discussed displaying different resolutions of stories to test responsive design, and there will probably be some problem with the media queries (as we won't use iframe).

I just wanted to mention a couple of links that might help to tackle this problem in the future:

It's just a proposal for now, but the fact that a polyfill exists may be a good starting point to make media queries based on a specific div (just to see how Google did this specifically). Also, we may have to create a plugin that change the way CSS is compiled for Histoire?

@elevatebart
Copy link
Collaborator

Great idea to put to debate. Thanks.

What is the rationale for not using iframes?

This is how storybook and cypress handle media queries testing so you can bet that browser support is going to stay. Container queries on the other hand are still not used enough to be stable in API.

Using them instead to test Media queries would meant doing some CSS rewriting. I don't mind doing this magic (with sourcemaps of course) if we have a stable API on the other hand.

@hugoattal
Copy link
Collaborator Author

hugoattal commented Feb 3, 2022

After discussing it with @Akryum, it cames that iframes would be kinda heavy, especially with several versions of an element in a story, and might slow down the hot reload and the whole page.

But you're right, usage of iframes should also be put to debate! The advantage being that we won't need anything special to handle media queries.

Small example to illustrate, imagine an iframe for each element of this page:
https://vuejs.github.io/ui/#/demo/button

@Akryum
Copy link
Member

Akryum commented Feb 3, 2022

it cames that iframes would be kinda heavy

Specifically for the grid view where 10 or 100s of the component can be displayed at once.

@Akryum
Copy link
Member

Akryum commented Feb 3, 2022

Maybe we can have an hybrid approach and use iframe only when we want responsive queries to apply?

@Akryum Akryum closed this as completed in dd65fa7 Feb 3, 2022
@Akryum
Copy link
Member

Akryum commented Feb 3, 2022

image

@BBoehm
Copy link

BBoehm commented Jul 31, 2023

Would be great if we can get some kind of solution for the container queries

@hugoattal
Copy link
Collaborator Author

hugoattal commented Jul 31, 2023

This seems to now be commonly supported: https://caniuse.com/css-container-queries

So, the solution would be to just add a css rule on the variant like this:

.variant {
    container: variant / size
}

But then you'll have to use the @container query instead of the @media query.

ex:

@container (min-width: 720px) {
    .child {...}
}

(The usual media query would still work of course) Wdyt?

@hugoattal hugoattal reopened this Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants