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

[GridList] responsive cols and rows #6261

Closed
sean-stanley opened this issue Mar 2, 2017 · 12 comments
Closed

[GridList] responsive cols and rows #6261

sean-stanley opened this issue Mar 2, 2017 · 12 comments
Labels
component: image list This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@sean-stanley
Copy link

sean-stanley commented Mar 2, 2017

Description

I'm using this project after completing 2-3 projects with Angular Material. There is quite a bit of overlap in how the components and their options work. Sadly though one feature I really miss from Angular Material is the ability to set different cols and rows on different device widths.

Not sure how much work it is but it would be really great if we could have the GridList able to be 2 columns wide on mobile and 4 columns on tablet etc.

The props for GridList could become something like

  • colXs, colSm, colMd, colLg
  • paddingXs, paddingSm, paddingMd, paddingLg
  • cellHeightXs, cellHeightSm, cellHeightMd, cellHeightLg

This would be really useful for responsive applications. Thanks for considering this feature.

Images & references

https://material.angularjs.org/latest/demo/gridList

@stunaz
Copy link
Contributor

stunaz commented Mar 2, 2017

I think it is ok like that. You have the option to pass your own values. This is exactly what I do, I pass the cols, rows or padding base on the width (window.innerWidth) of the screen which achieves the same goal.

@sean-stanley
Copy link
Author

Interesting. I'm quite new to React, but I assumed that gridList under the hood just applies css classes to some divs so wouldn't it be more performant to simply have some media queries on the gridList styles for the breakpoints rather than watching and debouncing window.innerWidth as well as completely re-rendering the component when window.innerWidth changes?

I suppose in production, window.innerWidth doesn't really change that often and there is always the React-dimensions library to get the values easily but it just seems like maybe we're asking javascript to do a whole lot of work that css could do better and with fewer resources. Though I'm not a performance expert so please correct me if I'm wrong.

@Shahrukh-Zindani Shahrukh-Zindani added the component: image list This is the name of the generic UI component, not the React module! label Mar 2, 2017
@mbrookes mbrookes added new feature New feature or request next labels Mar 4, 2017
@oliviertassinari oliviertassinari changed the title Feature Request: [GridList] responsive cols and rows [GridList] responsive cols and rows May 6, 2017
@oliviertassinari oliviertassinari removed their assignment Jun 14, 2017
@chrislim
Copy link

Wish we could use something like the responsive syntax on the Box
https://material-ui.com/system/basics/#responsive

cols={{ xs: 2, sm: 3, md: 3, lg: 6 }}

@dohomi
Copy link
Contributor

dohomi commented Dec 6, 2019

Any chance to re-open this issue? I'd like the simplicity how Grid works and cols inside of GridList would need to be responsive for many use cases. An example how to resolve it would be great inside of the docs.

@oliviertassinari
Copy link
Member

@dohomi GridList should probably be named ImageList (we will likely rename it in v5). Maybe you would prefer #17000?

@dohomi
Copy link
Contributor

dohomi commented Dec 8, 2019

@oliviertassinari thanks for your input. I am overwriting the width through custom css based on props. It works but I think an API @chrislim proposed would be great.

@AyoCodess
Copy link

cols={{ xs: 2, sm: 3, md: 3, lg: 6 }}

this is still not possible? is there a workaround?

@jesusvallez
Copy link

jesusvallez commented Jan 4, 2022

cols={{ xs: 2, sm: 3, md: 3, lg: 6 }}

this is still not possible? is there a workaround?

my workaround...

const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.up('sm'))

<ImageList variant="quilted" cols={isMobile ? 2 : 3} gap={8}>
   ...
</ImageList>

Its ugly but it's the only one solution I found

@montanaflynn
Copy link

This would be very helpful!

@dohomi
Copy link
Contributor

dohomi commented Mar 21, 2022

@oliviertassinari any chance of re-open this issue? responsive cols and gap would be great addition for the use of this component

@Asrorjon17
Copy link

cols={{ xs: 2, sm: 3, md: 3, lg: 6 }}
this method did not work for some reason in me

@raselmahmud-coder
Copy link

const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.up('sm'))

Yeah, it works, But why not work this way? <ImageList cols={{ xs: 2, sm: 3, md: 3}} >

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: image list This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

No branches or pull requests