-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_scale.scss
61 lines (47 loc) · 1.43 KB
/
_scale.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
@use 'sass:list';
@use 'sass:math';
@use 'sass:map';
$ratio: 1.15 !default;
$major-ratio: $ratio !default;
$minor-ratio: $ratio !default;
$base: 1rem !default;
$precision: .05 !default;
$lower-clamp-point: math.div(960px, 16px) * $base !default;
$higher-clamp-point: null !default;
$viewport-unit: 1vw;
@function round($value, $precision: $precision) {
$multiplier: math.div(1, $precision);
@return math.div(math.round($value * $multiplier), $multiplier);
}
@function select-ratio($power) {
@if $power < 0 {
@return $minor-ratio;
}
@return $major-ratio;
}
@function factor($power, $ratio: select-ratio($power)) {
@return round(math.pow($ratio, $power));
}
@function value($power, $base: $base, $ratio: select-ratio($power)) {
@return round($base * math.pow($ratio, $power));
}
@function range(
$min-value,
$max-value,
$lower-clamp-point: $lower-clamp-point,
$higher-clamp-point: $higher-clamp-point,
$viewport-unit: $viewport-unit,
) {
@if not $higher-clamp-point {
$factor: math.div($min-value, $lower-clamp-point);
$value: round($factor * 100 * $viewport-unit);
@return clamp(#{$min-value}, #{$value}, #{$max-value});
}
// f(x) = ax + b = y, where y is size and x is viewport range
$a: math.div(
$max-value - $min-value, // y1 - y0
$higher-clamp-point - $lower-clamp-point // x1 - x0
);
$b: $a * $min-value - $lower-clamp-point;
@return clamp(#{$min-value}, #{$b} + #{$a * 100 * $viewport-unit}, #{$max-value});
}