Created
February 18, 2015 05:14
-
-
Save bookwyrm/e842edc61fa7379b672d to your computer and use it in GitHub Desktop.
Better Sass through Susy with-layout mixin
This file contains hidden or 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
// Get Layout | |
// ---------- | |
// Return a new layout based on current and given settings | |
// - $layout: <settings> | |
// - $clean: boolean | |
@function _get-layout( | |
$layout, | |
$clean: false | |
) { | |
$layout: layout($layout); | |
@return if($clean, $layout, _susy-deep-merge($susy, $layout)); | |
} |
This file contains hidden or 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
// Susy Inspect | |
// ------------ | |
// Output arguments passed to a inspect. | |
// - $mixin : <susy mixin> | |
// - $inspec : <mixin arguments> | |
@mixin susy-inspect($mixin, $inspect...) { | |
$show: false; | |
@each $item in $inspect { | |
@if index($item, inspect) { | |
$show: true; | |
} | |
} | |
@if $show or susy-get(debug inspect) { | |
-susy-#{$mixin}: inspect($inspect); | |
} | |
} |
This file contains hidden or 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
// Use Grid | |
// -------- | |
// Use an arbitrary layout for a section of code | |
// - $layout: <settings> | |
// - $clean: boolean | |
@mixin with-layout( | |
$layout, | |
$clean: false | |
) { | |
$inspect : $layout; | |
$old : $susy; | |
$susy : _get-layout($layout, $clean) !global; | |
@include susy-inspect(with-layout, $inspect); | |
@content; | |
$susy: $old !global; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment