Build and prepend a keyframes property node onto varsArg.
( varsArg: AstNode, fromProps: Record<string, number | string>, toProps: Record<string, number | string>, easeEach?: string, )
| 2524 | |
| 2525 | /** Build and prepend a keyframes property node onto varsArg. */ |
| 2526 | function insertKeyframesProp( |
| 2527 | varsArg: AstNode, |
| 2528 | fromProps: Record<string, number | string>, |
| 2529 | toProps: Record<string, number | string>, |
| 2530 | easeEach?: string, |
| 2531 | ): void { |
| 2532 | const fromEntries = Object.entries(fromProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`); |
| 2533 | const toEntries = Object.entries(toProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`); |
| 2534 | const easeEntry = easeEach ? `, easeEach: ${JSON.stringify(easeEach)}` : ""; |
| 2535 | const kfCode = `{ "0%": { ${fromEntries.join(", ")} }, "100%": { ${toEntries.join(", ")} }${easeEntry} }`; |
| 2536 | const kfProp = parseExpr(`{ keyframes: {} }`).properties[0]; |
| 2537 | kfProp.value = parseExpr(kfCode); |
| 2538 | if (varsArg?.type === "ObjectExpression") varsArg.properties.unshift(kfProp); |
| 2539 | } |
| 2540 | |
| 2541 | /** |
| 2542 | * Convert a flat tween (to/from/fromTo) to percentage-keyframes format. |
no test coverage detected