Created
August 19, 2012 05:12
-
-
Save dannyprose/3392213 to your computer and use it in GitHub Desktop.
Primary HAML Layout File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$total-columns : 7; | |
$column-width : 4em; | |
$gutter-width : 1em; | |
$grid-padding : $gutter-width; | |
$break : 12; | |
.container { | |
@include container($total-columns, $break); | |
} | |
@include at-breakpoint($break) { | |
.container { | |
section[role="main"] { | |
@include span-columns(7, 12); | |
} | |
section[role="secondary"] { | |
@include span-columns(4 omega, 12); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
%section{:class => "container main"} | |
%section{:role => "main"}= yield | |
-if current_page.data.secondary_content | |
%section{:role => "secondary"}= partial "#{'partials/_' + current_page.data.secondary_content}" | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will always give you a 7-column "main" with space for a 4-column "secondary" whenever it is present. If you want main to take up all 12 columns when secondary is absent, you'll need a bit more. Unfortunately that little bit has to be in the markup (whether or not you are using Susy). You need to let main know if secondary is there or not. You can either do that by adding a class somewhere:
or by placing secondary first in the markup:
(best practice these days is also to simplify selectors as mush as possible, removing tags (section, etc) whenever you can).