Skip to content

Commit 069a730

Browse files
authored
feat: Use sass name-spacing (#66)
## Description Updates to use SASS name-spacing to ensure it uses best practice at this time. ## Issue https://jira.dev.bbc.co.uk/browse/GEL
1 parent 30717a5 commit 069a730

6 files changed

Lines changed: 190 additions & 174 deletions

File tree

README.md

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<h1 align="center">GEL Grid</h1>
2-
<p align="center">
3-
<a href="https://travis-ci.org/bbc/gel-grid" target="_blank"><img src="https://travis-ci.org/bbc/gel-grid.svg?branch=master"></a>
4-
</p>
52
<p align="center">
63
A flexible code implementation of the GEL Grid.<br />
74
Forms part of the <a href="https://github.com/bbc/gel-foundations" target="_blank"><b>GEL Foundations</b></a>
85
</p>
96

7+
## Breaking Change: v7.0.0
8+
9+
v7.0.0 of GEL Grid implements 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+
11+
This has a number of consequences, but mostly the impact relates to how other modules are now loaded in and how to access variables. Namespaces now come into play, so please read the sass documention linked to above.
12+
13+
For usage of GEL Grid prior to v7.0.0 please reference the [v6.3.0 readme](https://github.com/bbc/gel-grid/tree/6.3.0).
14+
1015
## What is this?
1116

1217
An implementation of the [GEL Grid Guidelines](https://www.bbc.co.uk/gel/guidelines/grid).
@@ -25,14 +30,16 @@ It can used in two forms, by simply adding the relevant classes to your markup:
2530

2631
Or using a Sass mixin:
2732

28-
```sass
33+
```scss
34+
@use 'gel-grid/grid';
35+
2936
.my-component {
30-
@include gel-layout;
37+
@include grid.gel-layout;
3138
}
3239

3340
.my-component__item {
34-
@include gel-layout-item;
35-
@include gel-columns(1/2);
41+
@include grid.gel-layout-item;
42+
@include grid.gel-columns(1/2);
3643
}
3744
```
3845

@@ -50,38 +57,45 @@ $ npm install --save gel-grid
5057

5158
```sass
5259
// your-app/main.scss
53-
@import 'node_modules/gel-sass-tools/sass-tools';
54-
@import 'node_modules/sass-mq/mq';
55-
@import 'node_modules/gel-grid/grid';
60+
@use 'gel-grid/grid';
5661
```
5762

5863
### Install manually
5964

60-
You can install this component manually by downloading the content of this Git repo into your project and use a Sass @import to include it in your project.
65+
You can install this component manually by downloading the content of this Git repo into your project and use a Sass @use to include it in your project.
6166

6267
> **Note:** you will manually need to manage the dependencies below, without these this component will fail to compile.
6368
6469
### Compiled CSS
6570

6671
If you require just the built css, it is automatically built to the [gel-grid.css](https://github.com/bbc/gel-grid.css) repository.
6772

68-
## Dependencies
73+
### Loadpaths
74+
75+
Because this module depends on other modules, [GEL Sass Tools](https://github.com/bbc/gel-sass-tools) and [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).
76+
77+
If compiling from the command line you can specify:
78+
```
79+
sass --load-path=node_modules/ <options>
80+
```
6981

70-
In order to use the component you will need the following components available:
82+
whereas within nodejs you can call compile ot compileAsync:
83+
```js
84+
await sass.compileAsync(file, { loadPaths: ['./node_modules'] })
85+
```
7186

72-
- [GEL Sass Tools](https://github.com/bbc/gel-sass-tools)
73-
- [Sass MQ](https://github.com/sass-mq/sass-mq)
87+
This ensures the dependencies required by this module can be loaded correctly.
7488

7589
## Usage
7690

77-
A collection of grid utility classes can be output by defining `$gel-grid-enable--markup-output: true;` before you `@import` the main grid partial.
91+
A collection of grid utility classes can be output by defining `$gel-grid-enable--markup-output: true` when you `@use` the main grid partial.
7892

7993
**Example:**
8094

8195
```scss
82-
$gel-grid-enable--markup-output: true;
83-
84-
@import "gel-grid/grid";
96+
@use 'gel-grid/grid' with (
97+
$gel-grid-enable--markup-output: true,
98+
);
8599
```
86100

87101
This will allow you to create grids using specific markup within your page. With the grid markup enabled, its possible to create grids like so:
@@ -174,17 +188,20 @@ The GEL grid component exposes a collection of Sass Mixins which can be called w
174188
**Example**
175189

176190
```scss
191+
@use 'gel-grid/grid';
192+
@use 'sass-mq/mq';
193+
177194
.my-component {
178-
@include gel-layout;
195+
@include grid.gel-layout;
179196
}
180197

181198
.my-component__item {
182-
@include gel-layout-item;
183-
@include gel-columns(1/2);
199+
@include grid.gel-layout-item;
200+
@include grid.gel-columns(1/2);
184201

185202
@if $enhanced {
186-
@include mq($from: gel-bp-m) {
187-
@include gel-columns(1/4);
203+
@include mq.mq($from: gel-bp-m) {
204+
@include grid.gel-columns(1/4);
188205
}
189206
}
190207
}

lib/_settings.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@use 'sass-mq/mq' as *;
2-
@use 'gel-sass-tools/sass-tools' as *;
1+
@use 'gel-sass-tools/sass-tools';
32
@use 'sass:list';
43

54
///*------------------------------------*\
@@ -18,15 +17,15 @@
1817
// @type String
1918
// @link http://bit.ly/1Z6hPfd
2019
//
21-
$gel-grid-namespace: $gel-namespace !default;
20+
$gel-grid-namespace: sass-tools.$gel-namespace !default;
2221

2322
// The prefix applied to all GEL breakpoints used by Sass MQ. By default this
2423
// inherits from the default gel-breakpoint-prefix: `gel-bp-`.
2524
//
2625
// @type String
2726
// @link http://bit.ly/1nxxE0p
2827
//
29-
$gel-grid-breakpoint-namespace: $gel-breakpoint-prefix !default;
28+
$gel-grid-breakpoint-namespace: sass-tools.$gel-breakpoint-prefix !default;
3029

3130
// Not all pages or products will be using 1280px grid, you can conditional
3231
// wrap 1280px grid styles in a class so they only apply if 1280px is required

0 commit comments

Comments
 (0)