-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.scss
158 lines (140 loc) · 4.26 KB
/
helpers.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// ---------- REM-CALC mixin
// Shamlessly taken from Zurb-Foundation Framework.
$rem-base: 14px;
// STRIP UNIT
// It strips the unit of measure and returns it
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
// CONVERT TO REM
@function convert-to-rem($value, $base-value: $rem-base) {
$value: strip-unit($value) / strip-unit($base-value) * 1rem;
@if ($value == 0rem) { $value: 0; } // Turn 0rem into 0
@return $value;
}
// REM CALC
// New Syntax, allows to optionally calculate on a different base value to counter compounding effect of rem's.
// Call with 1, 2, 3 or 4 parameters, 'px' is not required but supported:
//
// rem-calc(10 20 30px 40);
//
// Space delimited, if you want to delimit using comma's, wrap it in another pair of brackets
//
// rem-calc((10, 20, 30, 40px));
//
// Optionally call with a different base (eg: 8px) to calculate rem.
//
// rem-calc(16px 32px 48px, 8px);
//
// If you require to comma separate your list
//
// rem-calc((16px, 32px, 48), 8px);
@function rem-calc($values, $base-value: $rem-base) {
$max: length($values);
@if $max == 1 { @return convert-to-rem(nth($values, 1), $base-value); }
$remValues: ();
@for $i from 1 through $max {
$remValues: append($remValues, convert-to-rem(nth($values, $i), $base-value));
}
@return $remValues;
}
// Horizontal center align
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
// Vertical center align
.valign-wrapper {
-webkit-align-items: center;
align-items: center;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-ms-flex-align: center;
-webkit-flex-align: center;
.valign {
display: block;
}
}
// Transform <hr/> element into a vertical line divider
.v-line-divider {
border: 1px solid;
border-color: black;
content: '';
display: inline;
margin: 0 rem-calc(10);
width: 0;
}
// Transform <hr/> element into a dot divider
.v-dot-divider {
@extend .v-line-divider;
display: inline-block;
}
// Generate empty vertical div from 2 to 50 px high.
@mixin make-vseparator-classes($iterations) {
@for $i from 2 through $iterations {
.v-separator-#{$i} {
content: '';
display: block;
padding: rem-calc($i / 2) 0;
}
}
}
@include make-vseparator-classes(50);
// $name: name of the class (will be suffixed with numerical value)
// $iterations: number of values to generate.
// $property: the css property to generate
// $unit: the unit to use, if no unit is specified then rem is used.
@mixin make-numeric-class($name, $iterations, $property, $unit:false) {
@for $i from 0 through $iterations {
@if $unit {
.#{$name + $i} {
#{$property}: #{$i + $unit} !important;
}
} @else {
.#{$name + $i} {
#{$property}: rem-calc($i) !important;
}
}
}
}
// Auto-generate margin and padding classes
// EX:
// ml30 = margin-left: 30px;
// p12 = padding: 12px;
@include make-numeric-class('m', 100, 'margin');
@include make-numeric-class('ml', 100, 'margin-left');
@include make-numeric-class('mr', 100, 'margin-right');
@include make-numeric-class('mt', 100, 'margin-top');
@include make-numeric-class('mb', 100, 'margin-bottom');
@include make-numeric-class('p', 100, 'padding');
@include make-numeric-class('pl', 100, 'padding-left');
@include make-numeric-class('pr', 100, 'padding-right');
@include make-numeric-class('pt', 100, 'padding-top');
@include make-numeric-class('pb', 100, 'padding-bottom');
// Fonction de debug permetant d'entourer les elements de la classe
// passé en armument en rouge,
// et optionellement de rajouter un fond bleu-clair.
@mixin debug($class, $with-background:false) {
.#{$class} {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 1px solid red;
@if $with-background {
background-color: rgba(lightblue, .7);
}
}
}
// Classe permetant de mettre en evidence
// qu'il reste queleque-chose a faire sur un element
.todo {
text-decoration: underline $orange;
&:before {
color: yellow;
content: 'TODO:';
}
}