Skip to content

Commit a48d3cb

Browse files
authored
Merge pull request #1864 from adumesny/master
use dart-sass
2 parents c9fd294 + 5c44e11 commit a48d3cb

File tree

8 files changed

+76
-313
lines changed

8 files changed

+76
-313
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function(grunt) {
99
grunt.loadNpmTasks('grunt-contrib-connect');
1010
grunt.loadNpmTasks('grunt-protractor-webdriver');
1111

12-
const sass = require('node-sass');
12+
const sass = require('sass');
1313

1414
grunt.initConfig({
1515
sass: {

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ GridStack.init( {column: N} );
189189
```html
190190
<link href="node_modules/gridstack/dist/gridstack-extra.css" rel="stylesheet"/>
191191

192-
<div class="grid-stack grid-stack-N">...</div>
192+
<div class="grid-stack">...</div>
193193
```
194194

195-
Note: class `.grid-stack-N` was added and we include `gridstack-extra.css` which defines CSS for grids with custom [2-11] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
195+
Note: class `.grid-stack-N` will automatically be added and we include `gridstack-extra.css` which defines CSS for grids with custom [2-11] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
196196

197197
See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html) with 6 columns
198198

@@ -204,11 +204,11 @@ For instance for 3-column grid you need to rewrite CSS to be:
204204

205205
```css
206206
.grid-stack-item[gs-w="3"] { width: 100% }
207-
.grid-stack-item[gs-w="2"] { width: 66.66666667% }
208-
.grid-stack-item[gs-w="1"] { width: 33.33333333% }
207+
.grid-stack-item[gs-w="2"] { width: 66.67% }
208+
.grid-stack-item[gs-w="1"] { width: 33.33% }
209209

210-
.grid-stack-item[gs-x="2"] { left: 66.66666667% }
211-
.grid-stack-item[gs-x="1"] { left: 33.33333333% }
210+
.grid-stack-item[gs-x="2"] { left: 66.67% }
211+
.grid-stack-item[gs-x="1"] { left: 33.33% }
212212
```
213213

214214
For 4-column grid it should be:
@@ -229,23 +229,23 @@ and so on.
229229
Better yet, here is a SASS code snippet which can make life much easier (Thanks to @ascendantofrain, [#81](https://github.com/gridstack/gridstack.js/issues/81) and @StefanM98, [#868](https://github.com/gridstack/gridstack.js/issues/868)) and you can use sites like [sassmeister.com](https://www.sassmeister.com/) to generate the CSS for you instead:
230230

231231
```sass
232+
@use "sass;math";
232233
.grid-stack > .grid-stack-item {
233234
234235
$gridstack-columns: 12;
235236
236-
min-width: (100% / $gridstack-columns);
237+
min-width: math.div(100%, $gridstack-columns);
237238
238-
@for $i from 1 through $gridstack-columns {
239-
&[gs-w='#{$i}'] { width: (100% / $gridstack-columns) * $i; }
240-
&[gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; }
241-
&[gs-min-w='#{$i}'] { min-width: (100% / $gridstack-columns) * $i; }
242-
&[gs-max-w='#{$i}'] { max-width: (100% / $gridstack-columns) * $i; }
239+
@for $i from 0 through $gridstack-columns {
240+
&[gs-w='#{$i}'] { width: math.div(100%, $gridstack-columns) * $i; }
241+
&[gs-x='#{$i}'] { left: math.div(100%, $gridstack-columns) * $i; }
242+
&[gs-min-w='#{$i}'] { min-width: math.div(100%, $gridstack-columns) * $i; }
243+
&[gs-max-w='#{$i}'] { max-width: math.div(100%, $gridstack-columns) * $i; }
243244
}
244245
}
245246
```
246247

247-
you can also use the SASS [src/gridstack-extra.scss](https://github.com/gridstack/gridstack.js/tree/master/src/gridstack-extra.scss) included in NPM package and modify to add more columns
248-
and also have the `.grid-stack-N` prefix to support letting the user change columns dynamically.
248+
you can also use the SASS [src/gridstack-extra.scss](https://github.com/gridstack/gridstack.js/tree/master/src/gridstack-extra.scss) included in NPM package and modify to add more columns.
249249

250250
Sample gulp command for 30 columns:
251251
```js

demo/two.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ <h1>Two grids demo</h1>
3939
<div class="col-md-6">
4040
<a onClick="toggleFloat(this, 0)" class="btn btn-primary" href="#">float: false</a>
4141
<a onClick="compact(0)" class="btn btn-primary" href="#">Compact</a>
42-
<div class="grid-stack grid-stack-6"></div>
42+
<div class="grid-stack"></div>
4343
</div>
4444
<div class="col-md-6">
4545
<a onClick="toggleFloat(this, 1)" class="btn btn-primary" href="#">float: true</a>
4646
<a onClick="compact(1)" class="btn btn-primary" href="#">Compact</a>
47-
<div class="grid-stack grid-stack-6"></div>
47+
<div class="grid-stack"></div>
4848
</div>
4949
</div>
5050
</div>

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Change log
6464

6565
## 4.2.7-dev (TBD)
6666
* fix [#1860](https://github.com/gridstack/gridstack.js/issues/1860) nested grid save inf loop fix
67+
* use latest `dart-sass`, updated comments
6768

6869
## 4.2.7 (2021-9-12)
6970

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"url": "https://github.com/gridstack/gridstack.js/issues"
5555
},
5656
"homepage": "http://gridstack.github.io/gridstack.js/",
57-
"dependencies": {},
5857
"devDependencies": {
5958
"@types/jasmine": "^3.5.9",
6059
"@types/jquery": "^3.5.1",
@@ -83,9 +82,9 @@
8382
"karma-cli": "^2.0.0",
8483
"karma-jasmine": "^4.0.1",
8584
"karma-typescript": "4.1.1",
86-
"node-sass": "^5.0.0",
8785
"protractor": "^7.0.0",
8886
"puppeteer": "^5.4.1",
87+
"sass": "^1.42.1",
8988
"serve-static": "^1.14.1",
9089
"ts-loader": "^8.0.7",
9190
"typescript": "^3.7",

src/gridstack-extra.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
44
*/
55

6+
@use "sass:math";
7+
68
$gridstack-columns-start: 2 !default;
79
$gridstack-columns: 11 !default;
810

911
@mixin grid-stack-items($columns) {
1012
.grid-stack.grid-stack-#{$columns} {
1113

1214
> .grid-stack-item {
13-
min-width: 100% / $columns;
15+
min-width: math.div(100%, $columns);
1416

1517
@for $i from 1 through $columns {
16-
&[gs-w='#{$i}'] { width: (100% / $columns) * $i; }
17-
&[gs-x='#{$i}'] { left: (100% / $columns) * $i; }
18-
&[gs-min-w='#{$i}'] { min-width: (100% / $columns) * $i; }
19-
&[gs-max-w='#{$i}'] { max-width: (100% / $columns) * $i; }
18+
&[gs-w='#{$i}'] { width: math.div(100%, $columns) * $i; }
19+
&[gs-x='#{$i}'] { left: math.div(100%, $columns) * $i; }
20+
&[gs-min-w='#{$i}'] { min-width: math.div(100%, $columns) * $i; }
21+
&[gs-max-w='#{$i}'] { max-width: math.div(100%, $columns) * $i; }
2022
}
2123
}
2224
}

src/gridstack.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
44
*/
55

6+
@use "sass:math";
7+
68
$gridstack-columns: 12 !default;
79
$animation_speed: .3s !default;
810

@@ -36,7 +38,7 @@ $animation_speed: .3s !default;
3638
}
3739

3840
> .grid-stack-item {
39-
min-width: 100% / $gridstack-columns;
41+
min-width: math.div(100%, $gridstack-columns);
4042
position: absolute;
4143
padding: 0;
4244

@@ -97,10 +99,10 @@ $animation_speed: .3s !default;
9799
}
98100

99101
@for $i from 0 through $gridstack-columns {
100-
&[gs-w='#{$i}'] { width: (100% / $gridstack-columns) * $i; }
101-
&[gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; }
102-
&[gs-min-w='#{$i}'] { min-width: (100% / $gridstack-columns) * $i; }
103-
&[gs-max-w='#{$i}'] { max-width: (100% / $gridstack-columns) * $i; }
102+
&[gs-w='#{$i}'] { width: math.div(100%, $gridstack-columns) * $i; }
103+
&[gs-x='#{$i}'] { left: math.div(100%, $gridstack-columns) * $i; }
104+
&[gs-min-w='#{$i}'] { min-width: math.div(100%, $gridstack-columns) * $i; }
105+
&[gs-max-w='#{$i}'] { max-width: math.div(100%, $gridstack-columns) * $i; }
104106
}
105107
}
106108

0 commit comments

Comments
 (0)