-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable
sx
prop on any components (#37)
- Loading branch information
1 parent
a75333c
commit df751ab
Showing
30 changed files
with
580 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/processors/ | ||
/utils/ | ||
LICENSE | ||
/private-runtime/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
packages/pigment-css-react/src/private-runtime/ForwardSx.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
export default function sx(styleObj) { | ||
return styleObj; | ||
export default function sx(transformedSx, { className, style }) { | ||
const sxClass = typeof transformedSx === 'string' ? transformedSx : transformedSx?.className; | ||
const sxVars = | ||
transformedSx && typeof transformedSx !== 'string' ? transformedSx.vars : undefined; | ||
const varStyles = {}; | ||
|
||
if (sxVars) { | ||
Object.entries(sxVars).forEach(([cssVariable, [value, isUnitLess]]) => { | ||
if (typeof value === 'string' || isUnitLess) { | ||
varStyles[`--${cssVariable}`] = value; | ||
} else { | ||
varStyles[`--${cssVariable}`] = `${value}px`; | ||
} | ||
}); | ||
} | ||
|
||
return { | ||
className: `${sxClass}${className ? ` ${className}` : ''}`, | ||
style: { | ||
...varStyles, | ||
...style, | ||
}, | ||
}; | ||
} |
Oops, something went wrong.