Syntax
An ainsley
config is a JavaScript object, which may optionally contain three fields:
variables
, variations
and children
.
Basic Example
Variables
Variables are a map of (CSS class selector friendly) abbreviations to values. These values can be used (interpolated) in both the properties and the values of ainsley rules.
Implied each
Variables use a principle called implied each.
Every time a variable is referenced, it will iterate through its map and generate a class rule for each one. When used together, they will explore each combination of variables and values.
With the above variables, this rule...
...would be expanded to...
Variable modifiers
Variables can have modifiers, which cause them to behave differently when configs with the same variable name are nested.
By default (i.e. without a modifier), the innermost variable will override the outermost variable.
becomes
The extend modifier
The extend modifier is a +
prefix to the name of the variable. It only affects
the scope created by the nested config.
becomes
The default modifier
They can also be given default values, which makes sense for people who want to create shared configs. They are only defined if the variable hasn't already been defined in a higher scope.
produces
Variations
...
Children
...