How to use the jss.createRule function in jss

To help you get started, we’ve selected a few jss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cssinjs / jss / packages / jss-plugin-rule-value-observable / src / index.js View on Github external
onCreateRule(name?: string, decl: JssStyle, options: RuleOptions): Rule | null {
      if (!isObservable(decl)) return null

      // Cast `decl` to `Observable`, since it passed the type guard.
      const style$ = (decl: Observable<{[string]: string | number}>)

      const rule = ((createRule(name, {}, options): any): StyleRule)

      // TODO
      // Call `stream.subscribe()` returns a subscription, which should be explicitly
      // unsubscribed from when we know this sheet is no longer needed.
      style$.subscribe((style: JssStyle) => {
        for (const prop in style) {
          rule.prop(prop, style[prop], updateOptions)
        }
      })

      return rule
    },
github cssinjs / jss / packages / jss-plugin-rule-value-function / src / index.js View on Github external
onCreateRule(name?: string, decl: JssStyle, options: RuleOptions): Rule | null {
      if (typeof decl !== 'function') return null
      const rule: StyleRuleWithRuleFunction = (createRule(name, {}, options): any)
      rule[fnRuleNs] = decl
      return rule
    },