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

feat(grid): add CSS Grid Experiment #7851

Merged

Conversation

joshblack
Copy link
Contributor

This is currently a draft / WIP Pull Request to see what we could pull off with CSS Grid in terms of grid primitives, subgrid support, and layouts.

@netlify
Copy link

netlify bot commented Feb 19, 2021

Deploy preview for carbon-elements ready!

Built with commit 0d28a80

https://deploy-preview-7851--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Feb 19, 2021

Deploy preview for carbon-elements ready!

Built with commit 89fc252

https://deploy-preview-7851--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Feb 19, 2021

Deploy preview for carbon-components-react ready!

Built with commit 0d28a80

https://deploy-preview-7851--carbon-components-react.netlify.app

@joshblack
Copy link
Contributor Author

@alisonjoseph @tay1orjones thought you all might be interested in this, in particular:

I think the notable exception is that, since we use column-gap we can't support the narrow grid mode. We can however drop all the gutter and offer classes that add back in the missing gutter from the custom property.

@netlify
Copy link

netlify bot commented Feb 19, 2021

Deploy preview for carbon-components-react ready!

Built without sensitive environment variables with commit 89fc252

https://deploy-preview-7851--carbon-components-react.netlify.app

@tay1orjones
Copy link
Member

This is awesome! 🎉 After taking a look, could we alternatively keep the wide mode/normal gutter but incorporate a narrow grid mode modifier that applies a negative margin to each child? In addition we could allow this at the per-column level to allow mixing of modes.

.bx--css-grid--narrow > *,
.bx--col-narrow {
    margin-left: calc(var(--cds-grid-gutter)/2*-1);
}

In both cases the gutter to the right of the column would remain unaffected per the spec. It would be an intentional violation of the css grid and would be visible in the grid mode explorer overlay in dev tools (see span 2 below), but it would conform to the design spec.

image

@alisonjoseph alisonjoseph mentioned this pull request Mar 8, 2021
87 tasks
@tay1orjones tay1orjones mentioned this pull request Mar 8, 2021
60 tasks
Base automatically changed from master to main March 8, 2021 16:35
@tay1orjones tay1orjones marked this pull request as ready for review March 8, 2021 21:31
@tay1orjones tay1orjones requested a review from a team as a code owner March 8, 2021 21:31
Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the following here:

  • Direct support for narrow mode with the "hang by default" negative left margin.
  • 12 column grid modifier/helper class
  • Proper support for mixing modes via subgrid
    • Condensed subgrid has proper gutters when placed in a wide or narrow parent grid
    • Narrow subgrid has proper gutters when placed in a wide or condensed parent grid
    • Wide subgrid has proper gutters when placed in a narrow or condensed parent grid
  • Additional simple layout exploration/examples on /layouts page

@tay1orjones
Copy link
Member

I also just added row-gap to the condensed grid so that consistent vertical guttering is applied when columns wrap as referenced in #4555

@joshblack
Copy link
Contributor Author

@andreancardona @jnm2377 let me know if you have any questions!

@andreancardona
Copy link
Contributor

@tay1orjones Do we care at all about mobile? Span 1's are getting cut off a bit
Screen Shot 2021-03-17 at 4 57 41 PM

@tay1orjones
Copy link
Member

@andreancardona great catch, thanks! I just pushed up a fix.

@tay1orjones tay1orjones merged commit a8edfd1 into carbon-design-system:main Mar 18, 2021
@joshblack joshblack mentioned this pull request Mar 22, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants