mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-02 22:22:19 +00:00
26 lines
590 B
JavaScript
26 lines
590 B
JavaScript
// @flow
|
|
import warning from 'tiny-warning'
|
|
import type {Rule, RuleOptions, JssStyle} from '../types'
|
|
import cloneStyle from './cloneStyle'
|
|
|
|
/**
|
|
* Create a rule instance.
|
|
*/
|
|
export default function createRule(
|
|
name: string = 'unnamed',
|
|
decl: JssStyle,
|
|
options: RuleOptions
|
|
): Rule | null {
|
|
const {jss} = options
|
|
const declCopy = cloneStyle(decl)
|
|
|
|
const rule = jss.plugins.onCreateRule(name, declCopy, options)
|
|
if (rule) return rule
|
|
|
|
// It is an at-rule and it has no instance.
|
|
if (name[0] === '@') {
|
|
warning(false, `[JSS] Unknown rule ${name}`)
|
|
}
|
|
|
|
return null
|
|
}
|