-
Notifications
You must be signed in to change notification settings - Fork 51
Layout::Flex
& Layout::Grid
- Prevent inheritance of gap values when nested (HDS-5067)
#2987
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
Changes from all commits
2ac0627
05c7d71
811cdf3
60b1434
7dddce3
62aa41b
ea689a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@hashicorp/design-system-components": minor | ||
--- | ||
|
||
`Layout::Flex` - Fixed issue in which `gap` value was improperly inherited by nested `Flex` components, added "0" as a supported `gap` value. | ||
|
||
`Layout::Grid` - Fixed issue in which `gap` & `columnMinWidth` values were improperly inherited by nested `Grid` components, added "0" as a supported `gap` value. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,23 @@ | |
// | ||
|
||
.hds-layout-grid { | ||
// Note: "Unitless 0" <length>s aren’t supported in math functions so we use 0px as a default value within calc() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion] maybe add a comment here, explaining why we need to initialize it here (instead of relying on the fallback in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the comment with more info |
||
// https://drafts.csswg.org/css-values/#calc-type-checking | ||
// We initialize the variable here to prevent inheritance issues in nested grids | ||
--hds-layout-grid-column-min-width: 0px; | ||
|
||
display: grid; | ||
// The column gap value is subtracted from the column-min-width to prevent overflow & simplify API for consumers | ||
|
||
// Note: "Unitless 0" <length>s aren’t supported in math functions so we use 0px as a fallback value within calc() | ||
// https://drafts.csswg.org/css-values/#calc-type-checking | ||
// The column gap value is subtracted from the column-min-width to prevent overflow & simplify API for consumers | ||
grid-template-columns: repeat( | ||
var(--hds-layout-grid-column-fill-type, auto-fit), | ||
minmax(calc(var(--hds-layout-grid-column-min-width, 0px) - var(--hds-layout-grid-column-gap, 0px)), 1fr) | ||
minmax(calc(var(--hds-layout-grid-column-min-width) - var(--hds-layout-grid-column-gap)), 1fr) | ||
); | ||
|
||
// Note: The gap style is defined here to avoid setting it repeatedly for the gap size variants defined below. | ||
// For the gap size variants, we override the value of the gap custom properties to set the desired sizes. | ||
// These variables can be used by the consumers as an escape hatch if they need to set non-standard gap values (but adds a bit of friction to it) | ||
gap: var(--hds-layout-grid-row-gap, 0) var(--hds-layout-grid-column-gap, 0); | ||
gap: var(--hds-layout-grid-row-gap) var(--hds-layout-grid-column-gap); | ||
} | ||
|
||
// align | ||
|
@@ -46,6 +49,11 @@ | |
|
||
// We set the values of the gap custom properties overriding the default value of 0 | ||
|
||
// row | ||
.hds-layout-grid--row-gap-0 { | ||
--hds-layout-grid-row-gap: 0px; | ||
} | ||
|
||
.hds-layout-grid--row-gap-4 { | ||
--hds-layout-grid-row-gap: 4px; | ||
} | ||
|
@@ -74,6 +82,11 @@ | |
--hds-layout-grid-row-gap: 48px; | ||
} | ||
|
||
// column | ||
.hds-layout-grid--column-gap-0 { | ||
--hds-layout-grid-column-gap: 0px; | ||
} | ||
|
||
.hds-layout-grid--column-gap-4 { | ||
--hds-layout-grid-column-gap: 4px; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.