less_test.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function() {
  4. "use strict";
  5. var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
  6. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
  7. MT("variable",
  8. "[variable-2 @base]: [atom #f04615];",
  9. "[qualifier .class] {",
  10. " [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]",
  11. " [property color]: [variable saturate]([variable-2 @base], [number 5%]);",
  12. "}");
  13. MT("amp",
  14. "[qualifier .child], [qualifier .sibling] {",
  15. " [qualifier .parent] [atom &] {",
  16. " [property color]: [keyword black];",
  17. " }",
  18. " [atom &] + [atom &] {",
  19. " [property color]: [keyword red];",
  20. " }",
  21. "}");
  22. MT("mixin",
  23. "[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
  24. " [property color]: [atom darken]([variable-2 @color], [number 10%]);",
  25. "}",
  26. "[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
  27. " [property color]: [atom lighten]([variable-2 @color], [number 10%]);",
  28. "}",
  29. "[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
  30. " [property display]: [atom block];",
  31. "}",
  32. "[variable-2 @switch]: [variable light];",
  33. "[qualifier .class] {",
  34. " [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
  35. "}");
  36. MT("nest",
  37. "[qualifier .one] {",
  38. " [def @media] ([property width]: [number 400px]) {",
  39. " [property font-size]: [number 1.2em];",
  40. " [def @media] [attribute print] [keyword and] [property color] {",
  41. " [property color]: [keyword blue];",
  42. " }",
  43. " }",
  44. "}");
  45. MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
  46. })();