Skip to content

Commit

Permalink
Replace sx callback object param with theme (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored May 6, 2024
1 parent df751ab commit 7a75d3c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/pigment-css-react/src/processors/sx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ export class SxProcessor extends BaseProcessor {

private processCss(styleObjOrFn: unknown, expressionValue: ExpressionValue) {
const { themeArgs } = this.options as IOptions;
const styleObj = typeof styleObjOrFn === 'function' ? styleObjOrFn(themeArgs) : styleObjOrFn;
const styleObj =
typeof styleObjOrFn === 'function' ? styleObjOrFn(themeArgs?.theme) : styleObjOrFn;

const res = cssFnValueToVariable({
styleObj,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function App2(props) {
className: props.className,
style: props.style,
children: /*#__PURE__*/ _jsx('p', {
sx: ({ theme }) => ({
sx: (theme) => ({
color: (theme.vars || theme).palette.primary.main,
...theme.applyStyles('dark', {
color: 'white',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const A = {
function App(props) {
return (
<SliderRail
sx={({ theme }) => ({
sx={(theme) => ({
mb: 1,
...theme.applyStyles('dark', {
color: 'white',
Expand Down Expand Up @@ -52,7 +52,7 @@ function App2() {
function App3(props) {
return (
<A.SliderRail
sx={({ theme }) => ({
sx={(theme) => ({
color: (theme.vars || theme).palette.primary.main,
fontSize: props.isRed ? 'h1-fontSize' : 'h2-fontSize',
':hover': {
Expand Down

0 comments on commit 7a75d3c

Please sign in to comment.