-
Notifications
You must be signed in to change notification settings - Fork 26
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: add Grid component #442
Conversation
This component can obviously be extended and made more configurable as we go, for now I would consider this the bare minimum to make it usable. |
src/components/grid/grid.js
Outdated
grid-gap: ${customProperties['--spacing-16']}; | ||
grid-auto-columns: 1fr; | ||
grid-template-columns: ${props => { | ||
switch (props.mode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if a Grid.Fixed
and Grid.AutoFit
would be nicer than a prop
. It feels a bit like a type
on a button. I know it would likely complicate the implementation a bit cause we'd have the GridContainer
and compose it with more specific grid-template-columns
depending if it's Grid.Fixed
and Grid.Autofit
. Not sure if the suggestion makes sense or if others would agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can do that. It would avoid "throwing" errors because of unsupported modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also make one mode the default instead of throwing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/grid/grid.js
Outdated
1: '600px', | ||
2: '450px', | ||
3: '350px', | ||
4: '275px', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be the same as our horizontal constraints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm good point. I can check in the places where we use this already if the sizes make sense.
src/components/grid/grid.js
Outdated
1: '600px', | ||
2: '450px', | ||
3: '350px', | ||
4: '275px', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our possible values are all over the place right now. We sometimes use numbers, words or shirt sizes.
I'd use shirt-sizes for now, so s
, m
, l
, xl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's one of the things we need to check with the design team.
</GridContainer> | ||
); | ||
Grid.displayName = 'Grid'; | ||
Grid.propTypes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder about the API. The current one is pretty restrictive and it would suck if we had to upgrade the whole MC while we learn more about how to provide a flexible API. Exploring more possible use-cases now can probably avoid migration pain afterwards.
Maybe we can explore using Grid for more advanced use-cases before publishing it?
For example, we could try to build the CollapsiblePanel
header (if that's even something we intend it to be used for).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we don't need to merge this in right away. We can keep it open for now.
The current one is pretty restrictive
Definitely. There is a lot of room for improvements, this one is the bare minimum.
Alright, after talking to @dferber90 we decided to have a low-level |
Nice! Looking forward to use this! Thanks a lot @emmenko 🎉 |
feat(grid): add support for data-attributes refactor(grid): to export Grid.Fixed and Grid.AutoFit components refactor(grid): to export low-level component Grid and ready-to-use components GridFixed and GridAutoFit feat(grid): implement css-grid component
Alright, I've rewrote the There are a couple of examples in the storybook to show the setup using fixed columns or auto-sizing columns. |
I approved the new snaps as they're not really design-related ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔢
Closes #73
Summary
Implements a
<Grid>
component that accepts all the supported CSS Grid properties.<Grid>
componentExample for fixed columns

Example for auto-sizing columns

Design
NA
Component Checklist
Technical
Documentation
README.md
fileProps
true
for default-propsclassNames
propDesign
Testing
data
attributesAccessibility (optional)
aria
attributes