Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adapt to pre-processed styles #243

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/pigment-css-react/src/processors/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}
Expand All @@ -619,7 +619,11 @@ export class StyledProcessor extends BaseProcessor {
})),
);
}
delete styleObj.variants;
if (styleObj.isProcessed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check instead be for the presence of the key isProcessed instead of checking for true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels good to me, any reason for checking that way instead of this one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for key's presence makes sure that this object is coming from the new processor regardless of the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value can only be true, it makes more sense to check for true than for the key presence.

styleObj = styleObj.style
} else {
delete styleObj.variants;
}
const res = cssFnValueToVariable({
styleObj,
expressionValue: styleArg,
Expand Down
Loading