Skip to content

Commit

Permalink
fix keyframes
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Jun 21, 2024
1 parent f59496d commit 8ac0cf9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/pigment-css-react/src/processors/keyframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,13 @@ export class KeyframesProcessor extends BaseProcessor {
}

private handleCall([, callArg]: CallParam, values: ValueCache) {
let styleObj: CSSInterpolation;
if (callArg.kind === ValueType.LAZY) {
styleObj = values.get(callArg.ex.name) as CSSInterpolation;
} else if (callArg.kind === ValueType.FUNCTION) {
if (callArg.kind === ValueType.LAZY || callArg.kind === ValueType.FUNCTION) {
const value = values.get(callArg.ex.name);
const { themeArgs } = this.options as IOptions;
const value = values.get(callArg.ex.name) as (
args: Record<string, unknown> | undefined,
) => CSSInterpolation;
styleObj = value(themeArgs);
}
if (styleObj) {
this.generateArtifacts(styleObj);
const styleObj: CSSInterpolation = typeof value === 'function' ? value(themeArgs) : value;
if (styleObj) {
this.generateArtifacts(styleObj);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,18 @@ const gradientKeyframe2 = keyframes`
background: ${({ theme }) => theme.palette.secondary.main};
}
`;

// simulate CssBaseline transpiled by Next.js
export const styles = (theme) => ({
'0%': {
background: theme.palette.primary.main,
},
'50%': {
background: green,
},
'100%': {
background: theme.palette.secondary.main,
},
});
const gradientKeyframe3 = keyframes((_c = ({ theme }) => styles(theme)));
var _c;
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@
background: blue;
}
}
@keyframes g9lh2y5 {
0% {
background: red;
}
50% {
background: green;
}
100% {
background: blue;
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
const green = 'green';
const gradientKeyframe = 'gpsum18';
const gradientKeyframe2 = 'g1t1dgxp';

// simulate CssBaseline transpiled by Next.js
export const styles = (theme) => ({
'0%': {
background: theme.palette.primary.main,
},
'50%': {
background: green,
},
'100%': {
background: theme.palette.secondary.main,
},
});
const gradientKeyframe3 = 'g9lh2y5';
var _c;

0 comments on commit 8ac0cf9

Please sign in to comment.