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
// two functions to deal with removing or setting units; | |
// aliased to strip() and assert() respectively | |
@function remove-unit($n) { @return $n / ($n * 0 + 1); } | |
@function strip($n) { @return remove-unit($n); } | |
@function set-unit($n, $u) { @return remove-unit($n) * 1#{$u}; } | |
@function assert($n, $u) { @return set-unit($n, $u); } | |
.test { |
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
// fiddling with auto conversion between rem and px | |
$base-font-size: 10px; | |
@function rem($n) { | |
@if unitless($n) { | |
@return $n * 1rem; | |
} | |
@else if unit($n) == 'px' { | |
@return $n / $base-font-size * 1rem; |
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
// demo of using greatest-common-denominator function to chain extensions of classes | |
// meant for grid width classes; would normally be done with placeholder selectors | |
@function gcd($n,$d) { | |
$num: if($n < $d,$d,$n); | |
$denom: if($n < $d,$n,$d); | |
$rem: $num; | |
$last_rem: $num; | |
@while $rem != 0 { | |
$last_rem: $rem; |
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
// beginning of a grid-column sizing mixin | |
// requires compass | |
@mixin g-cell($n, $d, $args...) { | |
width: $n / $d * 100%; | |
// @if length($args) >= 1 { position: relative; } | |
@each $arg in $args { | |
$dir: nth($arg,1); $p: nth($arg,2); | |
@if $p == outside { | |
margin-#{opposite-position($dir)}: 100%; |
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
// --- | |
// Breakpoint (v2.0.5) | |
// Sass (v3.2.8) | |
// --- | |
// fiddling with auto conversion between rem and px | |
$base-font-size: 16; |
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
// --- | |
// Breakpoint (v2.0.5) | |
// Sass (v3.2.8) | |
// --- | |
@import "compass"; | |
// grid variables | |
$grid-gutter: 30px !default; |
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
$body-blocks: p ul ol dl table pre blockquote figure img; | |
$heading-blocks: h1 h2 h3 h4 h5 h6; | |
@function proc($list) { | |
$arr: unquote("#{nth($list, 1)} + &"); | |
@for $n from 2 through length($list) { | |
$arr: append($arr, unquote(", #{nth($list,$n)} + &")); | |
} |
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
// automatic adjacent selector generation | |
$heading-blocks: h1 h2 h3 h4 h5 h6; | |
$other-blocks: p, ul, ol; | |
@mixin adjacent($list:()) { |
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
// advanced list operation experiments; part of a larger codebase | |
@function contains($list, $var) | |
@return index($list, $var) != false | |
@function nested-contains($list, $key) |
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
// functions for finding sum, length and averages | |
// supports complex/compound lists of values | |
// assumes either no units or identical units | |
@function compound-sum($args...) { | |
$sum: 0; | |
@each $arg in $args { |