Skip to content

Instantly share code, notes, and snippets.

View lunelson's full-sized avatar
👀
Reading

Lu Nelson lunelson

👀
Reading
View GitHub Profile
@lunelson
lunelson / SassMeister-input.scss
Last active December 16, 2015 22:39
Generated by SassMeister.com, the Sass playground.
// 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 {
@lunelson
lunelson / SassMeister-input.scss
Last active December 16, 2015 22:39
Generated by SassMeister.com, the Sass playground.
// 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;
@lunelson
lunelson / SassMeister-input.scss
Last active December 16, 2015 22:39
GCD and Grid width setup routine with query namespacing
// 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;
@lunelson
lunelson / SassMeister-input.scss
Last active December 16, 2015 22:49
Generated by SassMeister.com, the Sass playground.
// 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%;
@lunelson
lunelson / SassMeister-input.scss
Created May 4, 2013 10:18
Strip() and Assert() functions; original version
// ---
// Breakpoint (v2.0.5)
// Sass (v3.2.8)
// ---
// fiddling with auto conversion between rem and px
$base-font-size: 16;
@lunelson
lunelson / SassMeister-input.scss
Last active December 17, 2015 00:19
Working area for fully featured BBX Streetgang Grid
// ---
// Breakpoint (v2.0.5)
// Sass (v3.2.8)
// ---
@import "compass";
// grid variables
$grid-gutter: 30px !default;
@lunelson
lunelson / SassMeister-input.scss
Created May 6, 2013 09:37
Generated by SassMeister.com, the Sass playground.
$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)} + &"));
}
@lunelson
lunelson / SassMeister-input.scss
Created May 6, 2013 09:43
Generated by SassMeister.com, the Sass playground.
// automatic adjacent selector generation
$heading-blocks: h1 h2 h3 h4 h5 h6;
$other-blocks: p, ul, ol;
@mixin adjacent($list:()) {
@lunelson
lunelson / SassMeister-input.sass
Last active December 17, 2015 02:59
Generated by SassMeister.com, the Sass playground.
// advanced list operation experiments; part of a larger codebase
@function contains($list, $var)
@return index($list, $var) != false
@function nested-contains($list, $key)
@lunelson
lunelson / SassMeister-input.scss
Last active December 17, 2015 08:58
Compound Sum, Length and Average
// 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 {