Skip to content

Instantly share code, notes, and snippets.

@jtwalters
Created November 12, 2014 20:34
Show Gist options
  • Save jtwalters/81552e16e6ba43b3c240 to your computer and use it in GitHub Desktop.
Save jtwalters/81552e16e6ba43b3c240 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// Susy (v2.1.3)
// ----
@import "susy";
// Returns $list as a string
// -------------------------------------------------------------------------------
// @documentation http://sassylists.com/documentation/#debug
// -------------------------------------------------------------------------------
// @example debug(a b c d e) => [ a, b, c, d, e ]
// @example debug(a b (c d e)) => [ a, b, [ c, d, e ] ]
// -------------------------------------------------------------------------------
// @param $list [List] : list
// @param $pre [Boolean] : enable/disable variables type and proper indentation
// @param $level [Number] : internal variable for recursivity
// -------------------------------------------------------------------------------
// @return [String]
@function debug($list, $pre: false, $level: 1) {
$tab: " ";
$indent: "";
$break: if($pre, "\A ", "");
@if length($list) == 0 {
@return "( )";
}
@if length($list) == 1 {
@return if($pre, "(" + type-of($list) + ") ", "") + $list;
}
@for $i from 1 to $level {
$indent: $indent + $tab;
}
$result: "[" + $break;
@for $i from 1 through length($list) {
$item: nth($list, $i);
$result: $result + if($pre, $indent + $tab, " ");
@if length($item) > 1 {
$result: $result
+ if($pre, "(list: " + length($item) + ") ", "")
+ debug($item, $pre, $level + 1);
}
@else {
@if $pre {
$result: $result + "(" + type-of($item) + ") ";
}
@if length($item) == 0 {
$result: $result + "( )";
}
@else if type-of($item) == string {
$result: $result + quote($item);
}
@else if $item == null {
$result: $result + "null";
}
@else {
$result: $result + $item;
}
}
@if $i != length($list) {
$result: $result + "," + $break;
}
}
$result: $result + $break + if($pre, if($level > 1, $indent, ""), " ") + "]";
@return quote($result);
}
// Mixin displaying clean debug
// -------------------------------------------------------------------------------
// @param $list [List] : list
@mixin debug($list) {
body:before {
content: debug($list, true) !important;
display: block !important;
margin: 1em !important;
padding: .5em !important;
background: #EFEFEF !important;
border: 1px solid #DDD !important;
border-radius: .2em !important;
color: #333 !important;
font: .75em/1.5 "Courier New", monospace !important;
text-shadow: 0 1px white !important;
white-space: pre-wrap !important;
}
}
$span-test: 3 of 12 no-gutter;
/**
* Simple debug function
*/
body:after {
display: block;
content: debug(parse-span($span-test));
}
.gallery-item {
height: 100px;
background: red;
@include gallery($span-test);
}
/**
* Simple debug function
*/
body:after {
display: block;
content: "[ [ span, 3 ], [ gutter-override, no-gutter ], [ columns, 12 ] ]";
}
.gallery-item {
height: 100px;
background: red;
width: 23.7288135593%;
float: left;
}
.gallery-item:nth-child(4n + 1) {
margin-left: 0;
margin-right: -100%;
clear: both;
margin-left: 0;
}
.gallery-item:nth-child(4n + 2) {
margin-left: 25.4237288136%;
margin-right: -100%;
clear: none;
}
.gallery-item:nth-child(4n + 3) {
margin-left: 50.8474576271%;
margin-right: -100%;
clear: none;
}
.gallery-item:nth-child(4n + 4) {
margin-left: 76.2711864407%;
margin-right: -100%;
clear: none;
}
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment