-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwasser.less
51 lines (45 loc) · 1.59 KB
/
wasser.less
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@wasser-viewport-min: 320;
@wasser-viewport-max: 1500;
@wasser-scaling-ratio: 1.5;
@wasser-scaling-ratio-font: 1.25;
@wasser-font-size-to-line-height-ratio: @wasser-scaling-ratio;
/**
* Basic wasser mixin, generates responsive property.
* ---
* @access public
* ---
* @param {string} @property - The property to be scaled
* @param {number} @max — The max value for the property
* @param {number|string} [@min] - The min value ot the property
*/
.wasser(@property, @max, @min: (@max / @wasser-scaling-ratio)) {
._responsive-property(@max, @min, @property);
}
/**
* Basic wasser mixin for responsive typography.
* ---
* @access public
* ---
* @param {number} @max — The max value for the property
* @param {number|string} [@min] - The min value ot the property
* @param {string} [@property] - The property, defaults to padding
*/
.w-font(@max, @min: (@max / @wasser-scaling-ratio-font), @line-height-ratio: @wasser-font-size-to-line-height-ratio) {
._responsive-property(@max, @min, font-size);
._responsive-property(@max * @line-height-ratio, @min * @line-height-ratio, line-height);
}
._responsive-property(@max, @min, @property) {
@viewport-min: @wasser-viewport-min;
@difference: @wasser-viewport-max - @viewport-min;
// This is where the magic happens ;)
@{property}: ~'calc(@{min}px + (@{max} - @{min}) * (100vw - @{wasser-viewport-min}px) / (@{difference}))';
@media (min-width: ~'@{wasser-viewport-max}px') {
@{property}: ~'@{max}px';
}
@media (max-width: ~'@{viewport-min}px') {
@{property}: ~'@{min}px';
}
@media print {
@{property}: ~'@{max}px';
}
}