UNPKG

457 BJavaScriptView Raw
1import { insert, classPrefix } from './sheet.js'
2
3let count = 0
4const keyframeCache = {}
5
6export default function(props) {
7 const content = Object.keys(props).reduce((acc, key) =>
8 acc + key + '{' + props[key].__style || props[key] + '}'
9 , '')
10
11 if (content in keyframeCache)
12 return keyframeCache[content]
13
14 const name = classPrefix + ++count
15 keyframeCache[content] = name
16 insert('@keyframes ' + name + '{' + content + '}')
17
18 return name
19}