Skip to content

Commit b764e16

Browse files
fix: Add a function to return value for styles
1 parent 1699a84 commit b764e16

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/utils/commonUtils.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ export const logger = {
119119
},
120120
};
121121

122+
export const getCustomStyleValues = (customValue?: number, defaultValue?: number) => {
123+
return customValue === undefined ||
124+
customValue === null
125+
? defaultValue
126+
: customValue
127+
}
128+
122129
export const applyTheme = (
123130
theme: ThemeProps = {},
124131
mode: ThemeMode = ThemeMode.DARK,
@@ -337,19 +344,14 @@ export const applyTheme = (
337344
height: customStyle.tabs?.containerHeight || DefaultStyle.tabs.containerHeight,
338345
backgroundColor: theme.tabs?.containerBackgroundColor || DefaultTheme[mode].tabs.containerBackgroundColor,
339346
borderBottom: `${
340-
(customStyle.tabs?.tabContainerBorderWidth === undefined || customStyle.tabs?.tabContainerBorderWidth === null)?
341-
DefaultStyle.tabs.tabContainerBorderWidth :
342-
customStyle.tabs?.tabContainerBorderWidth
347+
getCustomStyleValues(customStyle.tabs?.tabContainerBorderWidth, DefaultStyle.tabs.tabContainerBorderWidth)
343348
}px solid`,
344349
borderColor:
345350
theme.customCard?.borderColor ||
346351
theme.colors?.borderColor ||
347352
DefaultTheme[mode].customCard.borderColor,
348353
padding: `0 ${
349-
customStyle.tabs?.tabPadding === undefined ||
350-
customStyle.tabs?.tabPadding === null
351-
? DefaultStyle.tabs.tabPadding
352-
: customStyle.tabs?.tabPadding
354+
getCustomStyleValues(customStyle.tabs?.tabPadding, DefaultStyle.tabs.tabPadding)
353355
}px`,
354356
gap: customStyle.tabs?.headingGap || DefaultStyle.tabs.headingGap,
355357
},
@@ -391,11 +393,7 @@ export const applyTheme = (
391393
},
392394
activeTabIndicator:{
393395
backgroundColor: theme.tabs?.indicatorColor || DefaultTheme[mode].tabs.indicatorColor,
394-
height:
395-
customStyle.tabs?.indicatorHeight === undefined ||
396-
customStyle.tabs?.indicatorHeight === null
397-
? DefaultStyle.tabs.indicatorHeight
398-
: customStyle.tabs?.indicatorHeight,
396+
height: getCustomStyleValues(customStyle.tabs?.indicatorHeight, DefaultStyle.tabs.indicatorHeight)
399397
},
400398
};
401399
};

0 commit comments

Comments
 (0)