UNPKG

748 BJavaScriptView Raw
1/* @flow */
2
3import type {PluginConfig, PluginResult} from './index';
4import type {Keyframes} from '../keyframes';
5
6export 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}