Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit df6d7aa

Browse files
committed
fix(system): remove userStyleConfig and add optional chaining
1 parent ffb10cc commit df6d7aa

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

packages/system/src/composables/use-style-config.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,41 @@ import { useChakra } from './use-chakra'
77
export function useStyleConfig(
88
themeKey: string,
99
themingProps: ThemingProps,
10-
options: { isMultiPart: true },
11-
userStyleConfig?: any
10+
options: { isMultiPart: true }
1211
): ComputedRef<Record<string, SystemStyleObject>>
1312

1413
export function useStyleConfig(
1514
themeKey: string,
1615
themingProps?: ThemingProps,
17-
options?: { isMultiPart?: boolean },
18-
userStyleConfig?: any
16+
options?: { isMultiPart?: boolean }
1917
): ComputedRef<SystemStyleObject>
2018

2119
export function useStyleConfig(
2220
themeKey: any,
2321
themingProps: any,
24-
options: any = {},
25-
userStyleConfig?: any
22+
options: any = {}
2623
) {
2724
return computed(() => {
25+
const { styleConfig: styleConfigProp, ...rest } = themingProps
2826
const { theme, colorMode } = useChakra()
2927
const themeStyleConfig = get(theme, `components.${themeKey}`)
3028

31-
const styleConfig = userStyleConfig || themeStyleConfig
29+
const styleConfig = styleConfigProp || themeStyleConfig
3230

3331
const mergedProps = mergeWith(
3432
{ theme: theme, colorMode: colorMode.value },
3533
styleConfig?.defaultProps ?? {},
36-
filterUndefined(themingProps)
34+
filterUndefined(rest)
3735
)
3836

39-
const baseStyles = runIfFn(styleConfig.baseStyle ?? {}, mergedProps)
37+
const baseStyles = runIfFn(styleConfig?.baseStyle ?? {}, mergedProps)
4038
const variants = runIfFn(
41-
styleConfig.variants?.[mergedProps.variant] ?? {},
39+
styleConfig?.variants?.[mergedProps.variant] ?? {},
4240
mergedProps
4341
)
4442

4543
const sizes = runIfFn(
46-
styleConfig.sizes?.[mergedProps.size] ?? {},
44+
styleConfig?.sizes?.[mergedProps.size] ?? {},
4745
mergedProps
4846
)
4947

0 commit comments

Comments
 (0)