-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_wasser.scss
81 lines (69 loc) · 2.14 KB
/
_wasser.scss
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@use 'sass:math';
$wasser-viewport-min: 320 !default;
$wasser-viewport-max: 1500 !default;
$wasser-scaling-ratio: 1.5 !default;
$wasser-scaling-ratio-font: 1.25 !default;
$wasser-font-size-to-line-height-ratio: $wasser-scaling-ratio !default;
/**
* 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
*/
@mixin wasser($property, $max, $min: math.div($max, $wasser-scaling-ratio)) {
@if type-of($max) != number {
@error 'wasser: A number is expected as the second parameter.';
}
@include _getResponsiveProperty($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
*/
@mixin w-font(
$max,
$min: math.div($max, $wasser-scaling-ratio-font),
$line-height-ratio: $wasser-font-size-to-line-height-ratio
) {
@if type-of($max) != number {
@error 'wasser: A number is expected as the first parameter.';
}
@include _getResponsiveProperty($max, $min, font-size);
@include _getResponsiveProperty(
$max * $line-height-ratio,
$min * $line-height-ratio,
line-height
);
}
@mixin _getResponsiveProperty($max, $min, $property) {
$max: _wasser-strip-unit($max);
$min: _wasser-strip-unit($min);
// This is where the magic happens ;)
#{$property}: calc(
#{$min}px + (#{$max} - #{$min}) * (100vw - #{$wasser-viewport-min}px) /
(#{$wasser-viewport-max} - #{$wasser-viewport-min - 1})
);
@media (min-width: #{$wasser-viewport-max}px) {
#{$property}: #{$max}px;
}
@media (max-width: #{$wasser-viewport-min}px) {
#{$property}: #{$min}px;
}
@media print {
#{$property}: #{$max}px;
}
}
@function _wasser-strip-unit($number) {
@if type-of($number) == 'number' and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}