You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v4.0.0 of GEL Grid uses the [@use](https://sass-lang.com/documentation/at-rules/use/) and [@forward](https://sass-lang.com/documentation/at-rules/forward/) approach and removes [@import](https://sass-lang.com/documentation/at-rules/import/).
10
10
11
-
The `@import` directive is now deprecated in favour of `@use` and `@forward`, see [SASS documentation](https://sass-lang.com/documentation/at-rules/use/) for more information.
11
+
This has a number of consequences, but mostly the impact comes to how other modules are now loaded in and how you can access variables. Namespaces now come into play so please read the sass documention linked to above.
12
12
13
-
GEL Sass Tools has now been updated to `@use` and `@forward`to remove a large number of deprecation notices.
13
+
In addition there were a number of __browser prefixes__ used in versions prior to v4. Given how much the browser landscape has changed since they were added, it is __now time to remove them__.
14
14
15
-
With the new @use directive, no var, function, or mixin is placed in global scope, and they are all scoped within the file.
16
-
17
-
This means that users will explicitly need to include the partial file in each file that may use its vars, functions or mixins.
18
-
19
-
As a result the right-to-left functionality will not work in the way it used to, because you can only bring in an external file once via `@use`.
20
-
21
-
Previously you could have:
22
-
```
23
-
.ltr {
24
-
#{$margin-right}: 10px;
25
-
#{$margin-left}: 10px;
26
-
}
27
-
28
-
$rtl: true;
29
-
@import '../sass-tools';
30
-
31
-
.rtl {
32
-
#{$margin-right}: 10px;
33
-
#{$margin-left}: 10px;
34
-
}
35
-
```
36
-
37
-
which compiled to:
38
-
```
39
-
.ltr {
40
-
margin-right: 10px;
41
-
margin-left: 10px;
42
-
}
43
-
44
-
.rtl {
45
-
margin-left: 10px;
46
-
margin-right: 10px;
47
-
}
48
-
```
49
-
50
-
You can no longer do this, the rtl paramater must be set at the point of loading:
51
-
```
52
-
@use '../sass-tools';
53
-
54
-
.ltr {
55
-
#{sass-tools.$margin-right}: 10px;
56
-
#{sass-tools.$margin-left}: 10px;
57
-
}
58
-
```
59
-
compiles to
60
-
61
-
```
62
-
.ltr {
63
-
margin-right: 10px;
64
-
margin-left: 10px;
65
-
}
66
-
```
67
-
68
-
Whereas:
69
-
```
70
-
@use '../sass-tools' with ($rtl: true);
71
-
72
-
.rtl {
73
-
#{sass-tools.$margin-right}: 10px;
74
-
#{sass-tools.$margin-left}: 10px;
75
-
}
76
-
```
77
-
compiles to
78
-
79
-
```
80
-
.rtl {
81
-
margin-left: 10px;
82
-
margin-right: 10px;
83
-
}
84
-
```
85
-
86
-
87
-
### Browser Prefixes
88
-
89
-
Browsers have moved forward considerably since GEL Sass Tools was created and the browser vendor prefixes are no longer required and have therefore been removed.
15
+
For usage of GEL Sass Tools prior to v4.0.0 please reference the [v3.4.0 readme](https://github.com/bbc/gel-sass-tools/tree/3.4.0).
90
16
91
17
92
18
## What is this?
93
19
94
-
GEL Sass Tools is a collection of Sass variables, functions and mixins which allows you to work with GEL units consistently within your Sass. It is also required by other [GEL Foundations](https://github.com/bbc/gel-foundations) components.
20
+
GEL Sass Tools is a collection of Sass variables, functions and mixins which allows you to work with GEL units consistently within your Sass. It is also used by other [GEL Foundations](https://github.com/bbc/gel-foundations) components.
95
21
96
22
Here is how you could use these tools in your Sass:
@@ -139,11 +68,22 @@ You can install this component manually by downloading the content of this Git r
139
68
140
69
> **Note:** you will manually need to manage the dependencies below, without these this component will fail to compile.
141
70
142
-
## Dependencies
143
71
144
-
In order to use the component you will need the following components available:
72
+
### IMPORTANT: Specify a Loadpath
145
73
146
-
-[Sass MQ](https://github.com/sass-mq/sass-mq)
74
+
Because this module depends on other modules such as [Sass MQ](https://github.com/sass-mq/sass-mq), when compiling your Sass it needs to know where find the referenced modules. It does this via a [loadPath](https://sass-lang.com/documentation/at-rules/use/#load-paths).
75
+
76
+
If compiling from the command line you can specify:
77
+
```
78
+
sass --load-path=node_modules/ <options>
79
+
```
80
+
81
+
whereas within nodejs you can call compile ot compileAsync:
The `rem` tool can be used in two ways. Either by directly calling the `toRem($value)` function, which will convert the supplied value and return a `rem` unit. E.g:
@@ -233,9 +181,11 @@ The `rem` tool can be used in two ways. Either by directly calling the `toRem($v
233
181
You can also use the `@include toRem($value);` mixin, which by default returns a `px` fallback to allow support for older browsers which don't support `rem` units. E.g:
234
182
235
183
**Sass**
236
-
```sass
184
+
```scss
185
+
@use'gel-sass-tools/sass-tools';
186
+
237
187
.my-component {
238
-
@include toRem('margin-bottom', 16px);
188
+
@includesass-tools.toRem('margin-bottom', 16px);
239
189
}
240
190
```
241
191
@@ -281,7 +231,7 @@ Interpolation should be used for any property which has a direction (e.g. `paddi
281
231
282
232
Taking the following CSS as an example:
283
233
284
-
```sass
234
+
```scss
285
235
// Original Sass
286
236
.my-component {
287
237
float: left;
@@ -290,25 +240,30 @@ Taking the following CSS as an example:
290
240
291
241
For a RTL layout, `float: left;` should be flipped to `float: right;`. We can use the `flip()` function to accomplish this.
292
242
293
-
```sass
294
-
// Flipped Sass
295
-
.my-component {
296
-
float: flip(left, right);
243
+
```scss
244
+
@use'gel-sass-tools/sass-tools';
245
+
246
+
.ltr {
247
+
float: sass-tools.flip(left, right);
248
+
}
249
+
250
+
sass-tools.$rtl: true;
251
+
252
+
.rtl {
253
+
float: sass-tools.flip(left, right);
297
254
}
298
255
```
299
256
300
257
When Sass comes across the `flip()` function, it will check the value of the `$rtl` variable. If `$rtl` is `false`, the `flip()` function will take the first parameter. If `$rtl` is `true`, the `flip()` function will take the second parameter.
301
258
302
259
The Sass will compile out as follows:
303
260
304
-
```sass
305
-
// Compiled LTR style
306
-
.my-component {
261
+
```css
262
+
.ltr {
307
263
float: left;
308
264
}
309
265
310
-
// Compiled RTL style
311
-
.my-component {
266
+
.rtl {
312
267
float: right;
313
268
}
314
269
```
@@ -319,34 +274,42 @@ Interpolation is used to adjust CSS properties which contain a direction within
0 commit comments