Skip to content

Instantly share code, notes, and snippets.

@bookwyrm
Created February 18, 2015 05:14
Show Gist options
  • Save bookwyrm/e842edc61fa7379b672d to your computer and use it in GitHub Desktop.
Save bookwyrm/e842edc61fa7379b672d to your computer and use it in GitHub Desktop.
Better Sass through Susy with-layout mixin
// 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));
}
// 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);
}
}
// 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