Permalink
Browse files

Add more documentation re: maps and rulesets

  • Loading branch information...
matthew-dean committed Jul 2, 2018
1 parent 2febf36 commit 015926774358cebf03621ca8838b763b807a9139
Showing with 26 additions and 6 deletions.
  1. +1 −1 _less.github.io
  2. +1 −1 content/features/detached-rulesets.md
  3. +22 −2 content/features/maps.md
  4. +2 −2 data/less.json
@@ -7,7 +7,7 @@ A detached ruleset is a group of css properties, nested rulesets, media declarat
Simple example:
````less
// declare detached ruleset
@detached-ruleset: { background: red; };
@detached-ruleset: { background: red; }; // semi-colon is optional in 3.5.0+
// use detached ruleset
.top {
View
@@ -9,7 +9,7 @@ By combining namespacing with the lookup `[]` syntax, you can turn your rulesets
mobile: 320px;
tablet: 768px;
desktop: 1024px;
};
}
.navbar {
display: block;
@@ -66,4 +66,24 @@ You can also make this easier by [aliasing mixins](#mixins-feature-mixin-aliasin
color: @colors[primary];
border-color: @colors[secondary];
}
```
```
Note, if a lookup value produces another ruleset, you can append a second `[]` lookup, as in:
```less
@config: {
@options: {
library-on: true
}
}
& when (@config[@options][library-on] = true) {
.produce-ruleset {
prop: val;
}
}
```
In this way, rulesets and variable calls can emulate a type of "namespacing", similar to mixins.
As far as whether to use mixins or rulesets assigned to variables as maps, it's up to you. You may want to replace entire maps by re-declaring a variable assigned to a rulset. Or you may want to "merge" individual key/value pairs, in which case mixins as maps might be more appropriate.
View
@@ -1,6 +1,6 @@
{
"name": "less",
"version": "3.5.0-beta.4",
"version": "3.5.0-beta.5",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
@@ -69,7 +69,7 @@
"less-plugin-autoprefix": "^1.5.1",
"less-plugin-clean-css": "^1.5.1",
"performance-now": "^0.2.0",
"phantomjs-prebuilt": "^2.1.7",
"phantomjs-prebuilt": "^2.1.16",
"phin": "^2.2.3",
"promise": "^7.1.1",
"time-grunt": "^1.3.0"

0 comments on commit 0159267

Please sign in to comment.