From b00aee79d6c752e29d2730bbaeae02591bef377b Mon Sep 17 00:00:00 2001 From: hokaccha Date: Thu, 15 Dec 2011 11:10:53 +0900 Subject: [PATCH] Add function `percentage` --- lib/less/functions.js | 3 +++ test/css/functions.css | 1 + test/less/functions.less | 1 + 3 files changed, 5 insertions(+) diff --git a/lib/less/functions.js b/lib/less/functions.js index d5fe8678..1aaa0d4c 100644 --- a/lib/less/functions.js +++ b/lib/less/functions.js @@ -167,6 +167,9 @@ tree.functions = { argb: function (color) { return new(tree.Anonymous)(color.toARGB()); + }, + percentage: function(n) { + return new(tree.Dimension)(n.value * 100, '%'); } }; diff --git a/test/css/functions.css b/test/css/functions.css index f33b9869..810af0df 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -24,6 +24,7 @@ lightness: 95%; rounded: 11; roundedpx: 3px; + percentage: 20%; } #alpha { alpha: rgba(153, 94, 51, 0.6); diff --git a/test/less/functions.less b/test/less/functions.less index 1af78bc8..27b4d0bc 100644 --- a/test/less/functions.less +++ b/test/less/functions.less @@ -28,6 +28,7 @@ lightness: lightness(hsl(98, 12%, 95%)); rounded: round(@r/3); roundedpx: round(10px / 3); + percentage: percentage(10px / 50); } #alpha {