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(css-grid): add percent span prop option #10552

Merged

Conversation

tay1orjones
Copy link
Member

Closes #10475

Enables CSSGrid columns to span a percentage width of the parent grid

Changelog

New

  • grid: spanPropTypes support new string percent options
  • grid: responsive per-breakpoint percent span width styles

Testing / Reviewing

  • View the Grid/Responsive story in the carbon-react-next storybook, there's a new column showing percent span widths.

@tay1orjones tay1orjones requested a review from a team as a code owner January 28, 2022 22:05
@netlify
Copy link

netlify bot commented Jan 28, 2022

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: 0758d14

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/6206c7345a8e0c0008792151

😎 Browse the preview: https://deploy-preview-10552--carbon-react-next.netlify.app

@netlify
Copy link

netlify bot commented Jan 28, 2022

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: 0758d14

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/6206c734ebb70c0007690415

😎 Browse the preview: https://deploy-preview-10552--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Jan 28, 2022

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: 0758d14

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/6206c734c7b2c50008f1754c

😎 Browse the preview: https://deploy-preview-10552--carbon-components-react.netlify.app

@@ -51,6 +51,7 @@ const spanPropType = FeatureFlags.enabled('enable-css-grid')
start: PropTypes.number,
end: PropTypes.number,
}),
PropTypes.arrayOf(PropTypes.oneOf(['25%', '50%', '75%', '100%'])),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would something like this work:

const percentSpanType = PropTypes.oneOf(['25%', '50%', '75%', '100%']);

//
? PropTypes.oneOfType([
    PropTypes.bool,
    PropTypes.number,
    PropTypes.shape({
      span: PropTypes.oneOfType([PropTypes.number, percentSpanType]),
      offset: PropTypes.number,
      start: PropTypes.number,
      end: PropTypes.number,
    }),
    percentSpanType
  ]);

Only reason why I'm curious is if we could support offsets or not with percent span 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

@joshblack Great idea - I got it working! I added a new column to the offset story that uses percent-based span with offsets. Check it out and let me know what you think.

Copy link
Contributor

@abbeyhrt abbeyhrt left a comment

Choose a reason for hiding this comment

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

Looks good to me! Grid is such a cool component, playing around with the story and the percentages work as expected!

@tay1orjones tay1orjones requested a review from joshblack February 8, 2022 21:26
@jnm2377 jnm2377 enabled auto-merge (squash) February 11, 2022 19:53
@jnm2377 jnm2377 merged commit 9cadb15 into carbon-design-system:main Feb 11, 2022
@jnm2377 jnm2377 mentioned this pull request Feb 14, 2022
22 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.

Add %-span support (100%, 50%, 25%) to Grid
5 participants