-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
_index.scss
170 lines (148 loc) · 5.12 KB
/
_index.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
159
160
161
162
163
164
165
166
167
168
169
170
/* ==========================================================================
settings.defaults
Supple default variables. Redefine and override them with your
application-level variables.
/ =========================================================================== */
@use 'sass:map';
@use 'sass:math';
@use 'sass:meta';
@use 'sass:string';
/* --------------------------------------------------------------------------
Baseline
As per:
https://builttoadapt.io/intro-to-the-8-point-grid-system-d2573cde8632
https://medium.freecodecamp.org/8-point-grid-typography-on-the-web-be5dc97db6bc
/ --------------------------------------------------------------------------- */
$baseline: 8px !default;
/* --------------------------------------------------------------------------
Spacing
Multiply our `$baseline` to new spacing variables for
more transparency & consistency.
/ --------------------------------------------------------------------------- */
/**
* How many lines should our spacing units span?
* Each value should be an unitless integer.
*/
$space-factors: (
'tiny': 1,
// 1*8px = 8px
'small': 2,
// 2*8px = 16px
'base': 3,
// 3*8px = 24px
'large': 6,
// 6*8px = 48px
'huge': 12,
// 12*8px = 96px
) !default;
/* --------------------------------------------------------------------------
Typography
/ --------------------------------------------------------------------------- */
$font-size: 16px !default;
$line-height: map.get($space-factors, 'base') * $baseline !default;
$line-height-ratio: math.div($line-height, $font-size);
/* --------------------------------------------------------------------------
Grid
/ --------------------------------------------------------------------------- */
$columns: 12 !default;
/* --------------------------------------------------------------------------
Responsive
/ --------------------------------------------------------------------------- */
/**
* Breakpoints sass map
*/
$breakpoints: (
palm: 320px,
lap: 640px,
desk: 960px,
wall: 1280px,
) !default;
/**
* Queries sass map
*/
$queries: (
palm: palm,
lap: lap,
desk: desk,
wall: wall,
) !default;
/* --------------------------------------------------------------------------
Namespace
Would you like supple classes to be used with a different namespace?
/ --------------------------------------------------------------------------- */
$responsive-modifier: string.unquote('\\@') !default;
/* --------------------------------------------------------------------------
Technology
Allows us to use supple alongside other technologies like css-modules etc.
/ --------------------------------------------------------------------------- */
$css-modules: false !default;
/* --------------------------------------------------------------------------
Checks
A couple of checks for correct formatting of variables in this file
/ --------------------------------------------------------------------------- */
/**
* Check that the chosen font rules are pixel numbers.
*/
$should-be-pixel-values: (
'baseline': $baseline,
'font-size': $font-size,
'line-height': $line-height,
);
@each $key, $value in $should-be-pixel-values {
@if meta.type-of($value) == number {
@if math.unit($value) != 'px' {
@error '`#{$key}: #{$value}` needs to be a pixel unit.';
}
} @else {
@error '`#{$key}: #{$value}` needs to be a number.';
}
}
/**
* check that breakpoints are defined in px or em
*/
@each $key, $value in $breakpoints {
@if meta.type-of($value) == number {
@if math.unit($value) != 'px' and math.unit($value) != 'em' {
@error 'Breakpoint `#{$key}: #{$value}` needs to be a pixel or em unit.';
}
} @else {
@error '`#{$key}: #{$value}` needs to be a number.';
}
}
/**
* Check that the chosen size factors are unitless, integer numbers.
*/
$should-be-unitless-integers: (
'columns': $columns,
);
@each $key, $value in map.merge($space-factors, $should-be-unitless-integers) {
@if meta.type-of($value) == number {
@if math.is-unitless($value) == false {
@error '`#{$key}: #{$value}` needs to be unitless.';
}
@if $value != math.ceil($value) {
@error '`#{$key}: #{$value}` needs to be an integer.';
}
} @else {
@error '`#{$key}: #{$value}` needs to be a number.';
}
}
/**
* Check if `$space-factors` has the mandatory `base` entry
*/
@if not map.has-key($space-factors, 'base') {
@error '`$space-factors` needs to contain atleast one entry named 'base' since supple-css internally relies on this.';
}
/**
* Check if $queries is in the right format
*/
@each $key, $value in $queries {
@if meta.type-of($value) == map {
@if map.has-key($value, min) and map.has-key($value, min-width) {
@error 'defaults.$queries: "min" and "min-width" keys are both compiled to "min-width" queries. Use one or the other.'; // stylelint-disable-line max-line-length
}
@if map.has-key($value, max) and map.has-key($value, max-width) {
@error 'defaults.$queries: "max" and "max-width" keys are both compiled to "min-width" queries. Use one or the other.'; // stylelint-disable-line max-line-length
}
}
}