-
Notifications
You must be signed in to change notification settings - Fork 278
Use of Sass's @extend directive inside media queries leads to sadness. #6
Comments
Thanks for pointing this out! I don't currently use SASS myself, so I can't test this out properly. I'll make a note to convert all the "LESS mixins" into proper SCSS mixins when I get the chance to do so. |
Mixins lead to duplicated code easily, while The compiled CSS will be different, but I think it would be better if GGS used the best features of each preprocessor. Example: SASS with mixins ( /* Source */
@mixin huge {
font-size: 100px;
}
.ie h1 {
@include huge;
}
/* Compiled CSS */
huge {
font-size: 100px;
}
.ie h1 {
font-size: 100px;
} SASS with /* Source */
.huge {
font-size: 100px;
}
.ie h1 {
@extend .huge
}
/* Compiled CSS */
.huge, .ie h1 {
font-size: 100px
} As you can see, in this example the filesize is almost insignificant, but in real CSS files mixins compile to a lot bigger and unperformant files. |
Yeah, using mixing produces more code … more CSS declarations, that's true. I was simply pointing out that this in Less: .huge {
/* 42px / 48px */
font-size: 42 / @em;
line-height: (@line*2) / 42 * 1em;
}
/* ... */
.ie h1 {
.huge();
margin: (48/42*1em) 0 (24/42*1em);
} … is equivalent to this in Sass: @mixin huge {
/* 42px / 48px */
font-size: #{42 / $em}em;
line-height: ($line *2) / 42 * 1em;
}
/* ... */
.ie h1 {
@include huge;
margin: (48/42*1em) 0 (24/42*1em);
} … I know mixins produce more code, but they also produce different code than |
With sass you don't HAVE to compile mixins to CSS. The sass implementation of GGS should convert all of the classes like A simple example would be to create a directory called "partials" add a file called =huge
/* 42px / 48px */
font-size: #{42 / $em}em
line-height: ($line *2) / 42 * 1em
... Then you can and use #MyOwnMarkup
+huge Then your actual CSS file won't have a bunch of unused classes. Maybe it's out of scope for this project or repo but the current GGS.scss file, although helpful and appreciated, isn't that much of a value add as it doesn't really leverage sass/scss as much as it could. It would be nice to have something like the |
Hi, I just wanted to point out that in the Sass version of the grid, the
@extend
directive is used inside "IE fixes" and themin-width: 40em
media query. Because of the way Sass handles@extend
this results in the .huge declaration being converted to:… which I don't think is what's intended. Less has a slightly simpler mixin syntax, but I think this is what you want:
… then, in the IE-specific, and media query declarations, you'd use the same,
@include huge;
… this produces a CSS document that looks more like the GGS.css that's included in the source.The text was updated successfully, but these errors were encountered: