-
Hello, I love Vanilla Extract, and I'm trying to create a plugin to make it a little easier to use. One of the features I want to create is anonymous keyframing of griffel. Here's the sample code import { keyframes, type StyleRule } from "@vanilla-extract/css";
type KeyframeArgs = Parameters<typeof keyframes>[0];
type MyStyleRule = Omit<StyleRule, "animationName"> & {
animationName: KeyframeArgs;
};
export function myStyle(rules: MyStyleRule): StyleRule {
const { animationName, ...otherRules } = rules;
const anonymousName = keyframes(animationName, "test");
return {
...otherRules,
animationName: anonymousName
} satisfies StyleRule;
}
if (import.meta.vitest) {
const { it, expect } = import.meta.vitest;
it("Anonymous AtRules", () => {
const rules: MyStyleRule = {
animationName: {
from: {
opacity: 0
},
"50%": {
opacity: 0.3
},
to: {
opacity: 1
}
}
};
expect(myStyle(rules)).toStrictEqual({
animationName: "animationName_test"
});
});
} When I run the test, I get an error.
Can I use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The issue here is likely that your file doesn't end in
|
Beta Was this translation helpful? Give feedback.
Calling
setFileScope
beforemyStyle
seems to fix it, though it doesn't seem to actually do anything with the filescope you provide. The plugin usually handles this in regular code, but I think due to that way tests are executed this doesn't occur, so you have to do it manually.