Skip to content

Instantly share code, notes, and snippets.

View krambuhl's full-sized avatar
❤️
I love you!

Eevee Kreevee krambuhl

❤️
I love you!
  • Boogie Woogie Industrial Complex
  • Portland, Oregon
  • 05:20 (UTC -07:00)
View GitHub Profile
@krambuhl
krambuhl / viewport-type.scss
Last active October 28, 2016 22:33
example of viewport based type sizing using viewport units
// requires: respond.scss
// https://gist.github.com/krambuhl/9dd229f391aceb3012b4
$vptext-viewport: 960px;
$vptext-min: 640px;
$vptext-max: 1180px;
@mixin viewport-text($font-size: 24px) {
font-size: #{($font-size / $vptext-viewport * 100) + vw};
@krambuhl
krambuhl / equal-heights.js
Last active August 29, 2015 14:06
EqualHeights Class
var EqualHeights = (function($, _) {
function EqualHeights (el, opts) {
this.options = _.extend({ item: '.equal-item' }, opts);
this.items = $(el).find(this.options.item);
$(window).on('resize', _.bind(this.resize, this)).trigger('resize');
}
EqualHeights.prototype.resize = function() {
this.items.height(getMaxHeight(this.items));
@krambuhl
krambuhl / result.js
Created September 24, 2014 05:43
gets result of an expression.
function result(expr, context) {
return typeof expr === 'function' ? expr.apply(context) : expr;
}
@krambuhl
krambuhl / firstdef.js
Last active August 29, 2015 14:06
gets first argument that is not undefined;
function firstdef() {
var isDefined = function(arg) { return !_.isUndefined(arg); };
return _.find(arguments, isDefined);
}
@krambuhl
krambuhl / diffCollection.js
Last active August 29, 2015 14:12
diffCollection
function diffCollection(oldColl, newColl, key) {
var oldVal = _.map(oldColl, function(model) {
return model.get(key);
});
var newVal = _.map(newColl, function(model) {
return model.get(key);
});
var changed = [];
// create media queries from min/max
@mixin respond($min: 0, $max: null, $media: screen) {
@if $min > 0 and $max {
@include respond-between($min, $max, $media) { @content };
} @else if $min == 0 and $max {
@include respond-below($max, $media) { @content };
} @else if $min and $max == null {
@include respond-above($min, $media) { @content };
}
}
@krambuhl
krambuhl / hidpi.scss
Created November 9, 2015 01:59
sass mixin for hidpi responsive behavior
@mixin hidpi {
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) { @content; }
}
class Car {
options() {
return { truckmode: false, big: false };
}
static config(ops) {
return class extends this {
options() {
return Object.assign({}, super.options(), ops);
}
@krambuhl
krambuhl / build-styles.js
Last active April 26, 2016 18:31
POC. Gulp tasks as modules.
const path = require('path');
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer-core');
module.exports = function(opts) {
return function() {
@krambuhl
krambuhl / templates.js
Created July 14, 2016 06:40
Atomic components using ES6 template literals
const stringify = children =>
Array.isArray(children) ? children.join('') : children;
// atoms
const Card = (attrs, children) =>
`<div class="card">
${ stringify(children) }
</div>`;
const Header = (attrs, children) =>