Skip to content

Commit d1b52a0

Browse files
committed
Added a new function for use in fluid/responsive layouts. Takes two Dimensions in pixels and returns their ratio as a percentage. Updated unit tests to include the function.
1 parent 2af0f62 commit d1b52a0

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

lib/less/functions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ tree.functions = {
158158
argb: function (color) {
159159
return new(tree.Anonymous)(color.toARGB());
160160

161+
},
162+
fluid: function(target, container){
163+
return new tree.Dimension((target.value / container.value) * 100.0, '%');
161164
}
162165
};
163166

test/css/functions.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
height: undefined("self");
55
border-width: 5;
66
variable: 11;
7+
padding: 5%;
78
}
89
#built-in {
910
escaped: -Some::weird(#thing, y);

test/less/functions.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
height: undefined("self");
66
border-width: add(2, 3);
77
variable: increment(@var);
8+
padding: fluid(10px, 200px);
89
}
910

1011
#built-in {

0 commit comments

Comments
 (0)