From 968a31f71b09616ade03fd59d73a114e9c8115a9 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 18 Sep 2024 04:45:32 -0400 Subject: [PATCH 1/2] feat: adapt to pre-processed styles --- packages/pigment-css-react/src/processors/styled.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/pigment-css-react/src/processors/styled.ts b/packages/pigment-css-react/src/processors/styled.ts index 813f09eb..ab7714bc 100644 --- a/packages/pigment-css-react/src/processors/styled.ts +++ b/packages/pigment-css-react/src/processors/styled.ts @@ -607,7 +607,7 @@ export class StyledProcessor extends BaseProcessor { themeImportIdentifier?: string, ) { const { themeArgs = {} } = this.options as IOptions; - const styleObj = typeof styleObjOrFn === 'function' ? styleObjOrFn(themeArgs) : styleObjOrFn; + let styleObj = typeof styleObjOrFn === 'function' ? styleObjOrFn(themeArgs) : styleObjOrFn; if (!styleObj) { return ''; } @@ -619,7 +619,11 @@ export class StyledProcessor extends BaseProcessor { })), ); } - delete styleObj.variants; + if (styleObj.isProcessed) { + styleObj = styleObj.style + } else { + delete styleObj.variants; + } const res = cssFnValueToVariable({ styleObj, expressionValue: styleArg, From 326040f8e222e31e26d55856a325958d9700cd0e Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 18 Sep 2024 05:15:31 -0400 Subject: [PATCH 2/2] lint --- packages/pigment-css-react/src/processors/styled.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pigment-css-react/src/processors/styled.ts b/packages/pigment-css-react/src/processors/styled.ts index ab7714bc..239ec3ed 100644 --- a/packages/pigment-css-react/src/processors/styled.ts +++ b/packages/pigment-css-react/src/processors/styled.ts @@ -620,7 +620,7 @@ export class StyledProcessor extends BaseProcessor { ); } if (styleObj.isProcessed) { - styleObj = styleObj.style + styleObj = styleObj.style; } else { delete styleObj.variants; }