-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfluidprop.scss
74 lines (51 loc) · 2.22 KB
/
fluidprop.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
/**
* FluidProp for Sass
*
* @version 1.0
* @author Niels Lyngsø
* @license MIT License
* @website: https://github.com/nielslyngsoe/sass-fluid-prop
*/
$FluidProp__currentPropName: font-size !global;
$FluidProp__currentMapValue: 1 !global;
$FluidProp__currentPropValue: 1 !global;
$FluidProp__currentPropUnit: px !global;
@mixin FluidProp-start($propertyName:font-size, $startMappingAt:0, $propertyStartValue:0, $propertyUnit:px) {
$FluidProp__currentPropName: $propertyName !global;
$FluidProp__currentMapValue: $startMappingAt !global;
$FluidProp__currentPropValue: $propertyStartValue !global;
$FluidProp__currentPropUnit: $propertyUnit !global;
#{$propertyName}: #{$propertyStartValue}#{$FluidProp__currentPropUnit};
}
@mixin FluidProp-step($mapAt, $propertyValue) {
$viewportGrowth: $mapAt - $FluidProp__currentMapValue;
$sizeGrowth: $propertyValue - $FluidProp__currentPropValue;
$relationRatio: $sizeGrowth / $viewportGrowth;
$correction: $FluidProp__currentPropValue - $FluidProp__currentMapValue * $relationRatio;
$propertyName: $FluidProp__currentPropName;
@media (min-width: #{$FluidProp__currentMapValue}px ) and (max-width: #{$mapAt}px ) {
#{$propertyName}: calc(#{($relationRatio*100)}vw + #{$correction}#{$FluidProp__currentPropUnit});
}
$FluidProp__currentPropValue: $propertyValue !global;
$FluidProp__currentMapValue: $mapAt !global;
}
@mixin FluidProp-stay($mapAt) {
$propertyName: $FluidProp__currentPropName;
@media (min-width: #{$FluidProp__currentMapValue}px ) and (max-width: #{$mapAt}px ) {
#{$propertyName}: #{$FluidProp__currentPropValue}#{$FluidProp__currentPropUnit};
}
$FluidProp__currentMapValue: $mapAt !global;
}
@mixin FluidProp-end() {
$propertyName: $FluidProp__currentPropName;
@media (min-width: #{$FluidProp__currentMapValue}px ) {
#{$propertyName}: #{$FluidProp__currentPropValue}#{$FluidProp__currentPropUnit};
}
}
@mixin FluidProp-endless($growthRelationRatio) {
$correction: $FluidProp__currentPropValue - $FluidProp__currentMapValue * $growthRelationRatio;
$propertyName: $FluidProp__currentPropName;
@media (min-width: #{$FluidProp__currentMapValue}px ) {
#{$propertyName}: calc(#{($growthRelationRatio*100)}vw + #{$correction}#{$FluidProp__currentPropUnit});
}
}