-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit
Grid
gap props to accept only available spacing values (#402)
## Migration Path For `columnGap` and `rowGap`, reduce all values (responsive or not) in the format `var(--rui-spacing-X)` to corresponding numbers (just `X`), e.g.: ```jsx // Before <Grid columnGap="var(--rui-spacing-3)"> // After <Grid columnGap={3}> ``` (Please mind the correct value type.)
- Loading branch information
1 parent
1b0d005
commit 42529d4
Showing
6 changed files
with
88 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
src/lib/components/Grid/_helpers/generateResponsiveCustomProperties.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
export const generateResponsiveCustomProperties = (prop, infix) => { | ||
const prepareValueByType = (value, type) => { | ||
if (type === 'spacing') { | ||
return `var(--rui-spacing-${value})`; | ||
} | ||
|
||
return value; | ||
}; | ||
|
||
export const generateResponsiveCustomProperties = (prop, infix, type = null) => { | ||
if (typeof prop === 'undefined') { | ||
return null; | ||
} | ||
|
||
if (typeof prop !== 'object') { | ||
return { [`--rui-local-${infix}-xs`]: prop }; | ||
return { [`--rui-local-${infix}-xs`]: prepareValueByType(prop, type) }; | ||
} | ||
|
||
return Object.keys(prop).reduce((acc, breakpoint) => ({ | ||
...acc, | ||
[`--rui-local-${infix}-${breakpoint}`]: prop[breakpoint], | ||
[`--rui-local-${infix}-${breakpoint}`]: prepareValueByType(prop[breakpoint], type), | ||
}), {}); | ||
}; |