Skip to content

Commit

Permalink
type: specify the type of responsive value
Browse files Browse the repository at this point in the history
  • Loading branch information
shervinchen committed Nov 10, 2024
1 parent b53ad96 commit b31405d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/Grid/Grid.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,17 @@ export const getColResponsiveStyle = (

if (isPlainObject(value)) {
const breakPoints = Object.keys(BreakPoints);
Object.keys(value).map((breakPoint: BreakPoint) => {
if (type === 'span' && value[breakPoint] === 0) {
const responsiveValue = value as { [key in BreakPoint]?: number };
Object.keys(responsiveValue).map((breakPoint: BreakPoint) => {
if (type === 'span' && responsiveValue[breakPoint] === 0) {
responsiveStyle[breakPoint] = hideSpanStyle;
} else if (
breakPoints.includes(breakPoint) &&
isLegalColPropertyValue(value[breakPoint])
isLegalColPropertyValue(responsiveValue[breakPoint])
) {
responsiveStyle[breakPoint] = calculateColStyle(
type,
value[breakPoint]
responsiveValue[breakPoint]
);
}
});
Expand Down Expand Up @@ -190,12 +191,15 @@ export const getGridResponsiveStyle = (

if (isPlainObject(value)) {
const breakPoints = Object.keys(BreakPoints);
Object.keys(value).map((breakPoint: BreakPoint) => {
const responsiveValue = value as {
[key in BreakPoint]?: number | Align | Justify;
};
Object.keys(responsiveValue).map((breakPoint: BreakPoint) => {
if (
breakPoints.includes(breakPoint) &&
isLegalGridPropertyValue(type, value[breakPoint])
isLegalGridPropertyValue(type, responsiveValue[breakPoint])
) {
gridResponsiveStyle[breakPoint] = value[breakPoint] as
gridResponsiveStyle[breakPoint] = responsiveValue[breakPoint] as
| number
| Align
| Justify;
Expand Down

0 comments on commit b31405d

Please sign in to comment.