1 |
|
2 |
|
3 | import type {PluginConfig, PluginResult} from './index';
|
4 | import type {Keyframes} from '../keyframes';
|
5 |
|
6 | export default function keyframesPlugin(
|
7 | {addCSS, config, style}: PluginConfig, // eslint-disable-line no-shadow
|
8 | ): PluginResult {
|
9 | const newStyle = Object.keys(style).reduce(
|
10 | (newStyleInProgress, key) => {
|
11 | let value = style[key];
|
12 | if (key === 'animationName' && value && value.__radiumKeyframes) {
|
13 | const keyframesValue = (value: Keyframes);
|
14 | const {animationName, css} = keyframesValue.__process(config.userAgent);
|
15 | addCSS(css);
|
16 | value = animationName;
|
17 | }
|
18 |
|
19 | newStyleInProgress[key] = value;
|
20 | return newStyleInProgress;
|
21 | },
|
22 | {},
|
23 | );
|
24 | return {style: newStyle};
|
25 | }
|