-
Notifications
You must be signed in to change notification settings - Fork 841
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
[EuiFlexGrid] Allow number of columns based on viewport size #2609
Comments
It sounds useful. Give us a day to discuss at one of our internal meetings and we'll provide some guidance on how we think it would work from a props perspective. Likely it's something we'd want generic that could be reusable in other parts of EUI. I'll follow up tomorrow. |
@snide spot on, I mentioned FlexGrid because it's the first example I came across but I agree that the feature could have a wider use, that's also why I suggested something like the second solution. I'll wait for you then :) thanks! |
We've discussed your proposal and think the second example is the better way to get this started,
Thinking through some of the implementation, and that this needs to dynamically trigger a callback to handle window resize, we'd like to expose the functionality primarily through a React hook:
Remaining aware that not all users could use this hook (e.g. wanting to use this breakpoint in a class component), we'll also want to expose the same functionality through a vanilla JavaScript callback/listener function (which the hook itself should use). The window Lastly, as our SCSS variables are not [currently] accessible from our JavaScript code, please duplicate the breakpoint values into the JS side, we'll address this separately in the future. Feel free to ask for clarification, more feedback, anything! Wanted to give a decent acceptance criteria without prescribing every detail, so if any of this feels too open-ended I'm happy to go into more detail! |
Great! This is more than enough for now to get started. I'll get to work on it ASAP and in case I need any clarification I'll ping you :) thank you! |
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment. |
Now that we have the hook const isMobile = useIsWithinBreakpoints(['xs', 's']);
return (
<EuiFlexGrid columns={isMobile ? 2 : 3} />
) |
Is there any easy way I can set a certain value for the number of columns of a grid for the desktop viewport size and another one, for example, for tablets viewport size? If not, would a pull request be welcome to implement such a feature? I find it something very important for certain layouts.
A practical example of what I mean (just to give the idea):
An idea could even be to have a helper to facilitate these operations, hence a function that extracts the values from
$euiBreakpoints
from SASS and compares the current viewport size against the breakpoints, returning the current one. This way the code would look something like this:The text was updated successfully, but these errors were encountered: