Example #1
0
 (strings: Array<string>, ...interpolations: Array<Interpolation>): string => {
   const rules = css(strings, ...interpolations)
   const hash = hashStr(replaceWhitespace(JSON.stringify(rules)))
   const name = nameGenerator(hash)
   const keyframes = new GlobalStyle(rules, `@keyframes ${name}`)
   keyframes.generateAndInject()
   return name
 }
Example #2
0
 generateStyleObject(executionContext: Object) {
   const flatCSS = flatten(this.rules, executionContext).join('')
   const hash = hashStr(flatCSS)
   if (!generated[hash]) {
     const root = parse(flatCSS)
     const styleObject = {}
     root.each(node => {
       if (node.type === 'decl') {
         const { value } = node
         const isNumber = value !== '' && !isNaN(value)
         const typedVal = isNumber && !propNeedsStrings[node.prop] ? parseFloat(value) : value
         styleObject[camelizeStyleName(node.prop)] = typedVal
       } else {
         /* eslint-disable no-console */
         console.warn(`Node of type ${node.type} not supported as an inline style`)
       }
     })
     const styles = StyleSheet.create({
       generated: styleObject,
     })
     generated[hash] = styles.generated
   }
   return generated[hash]
 }