From 8e89b4b8c2bcf66be731c25dc67f32eaac0d0e58 Mon Sep 17 00:00:00 2001 From: Fernando Rojo Date: Wed, 9 Oct 2024 10:22:39 -0400 Subject: [PATCH] prefer object.assign --- packages/dripsy/src/core/css/index.tsx | 20 +++++++++++--------- packages/dripsy/src/core/css/scales.ts | 2 -- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/dripsy/src/core/css/index.tsx b/packages/dripsy/src/core/css/index.tsx index d42492b..3d626d6 100644 --- a/packages/dripsy/src/core/css/index.tsx +++ b/packages/dripsy/src/core/css/index.tsx @@ -183,10 +183,12 @@ export const css = ( fontFamily: fontFamilyFromProps, ...props }: CssPropsArgument = {}): CSSObject => { - const theme: DripsyFinalTheme = { - ...defaultTheme, - ...('theme' in props ? props.theme : props), - } as DripsyFinalTheme + let theme = defaultTheme as DripsyFinalTheme + if ('theme' in props) { + theme = Object.assign({}, theme, props.theme) + } else { + theme = Object.assign({}, theme, props) + } let result: CSSObject = {} const obj = typeof args === 'function' ? args(theme) : args const filteredOutWebKeys = filterWebStyleKeys(obj) @@ -202,7 +204,7 @@ export const css = ( get(theme, themeKey + '.' + val, get(theme, val)), breakpoint )({ theme }) - result = { ...result, ...variant } + Object.assign(result, variant) continue } @@ -217,13 +219,13 @@ export const css = ( theme.textShadows[val] as any, breakpoint )(theme) - result = { ...result, ...styledTextShadow } + Object.assign(result, styledTextShadow) continue } if (key == 'boxShadow' && val && theme.shadows?.[val]) { const styledBoxShadow = css(theme.shadows[val] as any, breakpoint)(theme) - result = { ...result, ...styledBoxShadow } + Object.assign(result, styledBoxShadow) continue } @@ -246,9 +248,9 @@ export const css = ( continue } - let themedAliases = aliases; + let themedAliases = aliases if (theme.aliases) { - themedAliases = Object.assign({}, themedAliases, theme.aliases); + themedAliases = Object.assign({}, themedAliases, theme.aliases) } const prop = diff --git a/packages/dripsy/src/core/css/scales.ts b/packages/dripsy/src/core/css/scales.ts index f263cc8..08fef55 100644 --- a/packages/dripsy/src/core/css/scales.ts +++ b/packages/dripsy/src/core/css/scales.ts @@ -1,5 +1,3 @@ -import { DripsyFinalTheme } from '../types-v2/declarations' - export const aliases = { zi: 'zIndex', dsp: 'display',