Compass compile error on Susy's at-breakpoint mixin - sass

I'm using Susy/Compass/SASS for a simple responsive grid on my current project. However, the Compass compiler won't compile Susy's at-breakpoint mixin. Here's my grid:
+border-box-sizing
$total-columns : 3
$column-width : 4.5em
$gutter-width : 1em
$grid-padding : $gutter-width
$container-style: fluid
$break-1: 6
$break-2: 10
body
+container($total-columns, $break-1, $break-2)
.list
+span-columns(3)
.detail
display: none
+at-breakpoint($break-1) {
.detail
+squish(1)
+span-columns(3)
.list
+span-columns(2 omega)
}
+at-breakpoint($break-2) {
.detail
+squish(1,1)
+span-columns(5)
.list
+span-columns(3 omega)
}
When Compass tries to compile, I get an error: error screen.sass (Line 20 of _grid.sass: Invalid CSS after "($break-1) ": expected expression (e.g. 1px, bold), was "{")
identical screen.css.
If found a previous question similar to mine that suggested the compass-susy-plugin was the culprit. I have removed that (not sure that I had it to begin with) and installed the Susy gem again to be safe, but I still get the error.
Has anyone had this or a similar problem? Thanks in advance for your help!

Susy does support the indented Sass syntax. The problem is you're currently using a hybrid of both syntaxes. Try this:
#import "susy"
+border-box-sizing
$total-columns : 3
$column-width : 4.5em
$gutter-width : 1em
$grid-padding : $gutter-width
$container-style: fluid
$break-1: 6
$break-2: 10
body
+container($total-columns, $break-1, $break-2)
.list
+span-columns(3)
.detail
display: none
+at-breakpoint($break-1)
.detail
+squish(1)
+span-columns(3)
.list
+span-columns(2 omega)
+at-breakpoint($break-2)
.detail
+squish(1,1)
+span-columns(5)
.list
+span-columns(3 omega)
Notice there are not curly brackets after the at-breakpoint() mixins. Just indent.

I found the problem. Susy doesn't support SASS's indented syntax. Boo!
I added in tons of curly braces, semicolons, and #includes to fix it.
UPDATE:
OK, the problem was not support for the SASS syntax. It was my use of the curly braces in the indented syntax! For some reason, my brain decided that the code block would need to be in braces since it would be passed to a mixin. My mistake and my apologies to the devs of Susy.

Related

SCSS divide operator not compiling

I am using Sublime Text 2 and LiveReload to compile my .scss file. I also tried codekit with the same problem.
Using + and - work no problem, but * and / don't compile.
font-size: 30px / 2px; doesn't compile to font-size: 15px;
but
font-size: 30px + 2px; does compile to font-size: 32px;
Any ideas? The code hinting also doesn't seem to be working for the multiply and divide operators, could it be a package conflict? Seems unlikely.
Put it in parenthesis so SCSS understands you want it to do an arithmetic operation. Also, you do not want to divide px by another px number as this will result in a unitless number.
This is what you are looking for:
div {
font-size: (30px / 2)
}

Pass a block to Sass mixin results in "mixin doesn't accept a content block"

I can't get a mixin to accept a block:
=my-mixin($some-var)
width: $some-var
#content // Is this correct?
+my-mixin(123px)
height: 100px
This results in a "mixin doesn't accept a content block" error. I'm using the current version of Sass. Thanks for help.
syntax is ok with version 3.2 of SASS, double check that
For me the problem was with SASS indentation.
You can't nest another block within a mixin like this:
.button-cta
+button (transparent, tomato)
&:hover
background-color: tomato
color: #fff
instead:
.button-cta
+button (transparent, tomato)
&:hover
background-color: tomato
color: #fff
hover state must not be nested
I was getting this error too. Turned out that somewhere else in my scss I was using #mixin mobile-only instead of #include mobile-only - aka, I was accidentally redefining the mixin later in the code.

Check if SASS parent selector exists. Is it possible

I have a question. So in a mixing I am making a reference to the parent selector "&". This works as long as the mixin is not nested. Is there a way to to detect if the mixing is being used in a non nested scenario, or to check if "&" is null?
This works when the mixin call is not nested
=myresponsiveMixin($media)
#if $media == small {
#media only screen and (max-width: $break-small)
#content
#else if $media == medium
#media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1)
#content
This works great when the mixin call is nested, but will not resolve '&' when not nested
=myresponsiveMixin($media)
#if $media == small {
#media only screen and (max-width: $break-small)
.classInHTMLToAllowMediaQueries &
#content
#else if $media == medium
#media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1)
.classInHTMLToAllowMediaQueries &
#content
So the question is, if there is a way to be able to check the value of parent selector "&", so I can cover all bases in a single mixin?
#mixin does-parent-exist {
#if & {
.exists & {
color: red;
}
} #else {
.doesnt-exist {
color: red;
}
}
}
http://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-script
You're trying a wrong solution to solve your issue.
Have a look at how this problem is addressed in powerful SASS frameworks. Let's take Susy by Eric Meyer as a great example.
Let's imagine you've got the following HTML:
<div class="container">
<div class="parent">
<div class="child">
Bla bla
</div>
</div>
</div>
When you call a mixin for the first time, you're doing it simply (the code is in the indented .sass syntax):
$total-columns: 8 // Declaring a varible that will be used by the mixin
.parent
+span-columns(4) // Span four of eight columns
But when you call that for a child element, the proportions would be crooked, because the parent is already proportioned:
.child
+span-columns(2) // This will fail. You want 2 of 8 columns,
// but due to nesting the math is crooked.
// It will be "2 of (4 of 8)".
To address the issue, you provide an optional argument: a context that is used to do the math:
.child
+span-columns(2, 4) // Now the mixin will take 2 parts of 4
// instead of 2 parts of four
The source code for this mixin is available on GitHub.
In short, it creates an optional argument like this (the code is in the CSS-like .scss syntax):
#mixin span-columns(
$columns,
$context: $total-columns
//...
) {
//...
width: columns($cols, $context /*...*/);
//...
}
See how $context has a default value? Thanks to the default value this argument can be omitted. In other words, $context is an optional argument.
When calling this mixin, if $context is not provided (e. g. span-columns(2)), then it is set equal to $total-columns. The $total-columns variable should be set prior to calling the mixin for the first time (see my example above).
Then the two arguments are used to calculate the width.
UPD 2013-03-30
I am not trying to figure out things in regards to columns... I have modifier my question to make it clearer.
First of all, my recommendation concerns not only grid columns. It's a universal technique you can adopt.
Secondly, now i see that you're trying to nest media queries.
Well, some media queries of different type can be combined in CSS3: e. g. print and width. But you can't put a min-width: 601px inside max-width: 600px, this just won't work!
There's an extensive answer here on StackOverflow describing why you should not nest media queries of the same type: https://stackoverflow.com/a/11747166/901944
Thirdly, you're trying to invent the wheel. There's already a fantastic mixin for crunching media queries: Respond To by Snugug. It's super easy to use and very effective.
Fourthly, the XY thing. Instead of asking about your crooked mixin, please describe the problem that you're trying to solve with it! Show us the actual HTML and explain what behavior you would like to achieve.
We will show you that it can be solved with a simple, elegant, semantic solution that does not require SASS hacking.

Sass syntax using 960gs framework

I'm attempting to re-learn 960gs using sass syntax. I am confused on the difference between "+" and "=" sass syntax. For example:
.wrapper
+grid-container
and
.wrapper
#include grid_container
would produce the same results in my compiled css file
.wrapper {
margin-left: auto;
margin-right: auto;
width: 960px;
}
So what is the difference between using "+" and "#include"?
No difference at all. Quoting Sass documentation:
Sass supports shorthands for the #mixin and #include directives. Instead of writing #mixin, you can use the character =; instead of writing #include, you can use the character +.

Using a SASS variable as a value for CSS `content` property

Hi!
This might be caused by my lack of understanding of SASS/Compass.
I'm trying to output grid width with the following SASS code:
$total-columns : 4
$column-width : 4em // each column is 4em wide
$gutter-width : $column-width / 2 // 1em gutters between columns
$grid-padding : $gutter-width / 2 // grid-padding equal to gutters
#page
+container
+susy-grid-background
#block-block-3
div.content
p:first-of-type:after
content: columns-width()
Nothing is printed into block 3. :(
I also tried content: columns-width($total-columns), still nothing. If i do content: "foo", "foo" does get printed.
What am i doing wrong? How do i see susy-calculated grid width? Also, can it be printed in compass watch output?
Ok, the solution is using interpolation:
content: "#{columns-width($total-columns)}"

Resources