##Sass Functions Cheat Sheet
This file contains hidden or 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
// Get a simple array of objects | |
var drinks = [ | |
{ 'name': 'Coke', 'quantity': 2 }, | |
{ 'name': 'Red Bull', 'quantity': 6 } | |
]; | |
// Get all the drink names using the _.pluck() function | |
var currentDrinks = _.pluck(drinks, 'name'); | |
console.log(currentDrinks); | |
// → ['Coke', 'Red Bull'] |
This file contains hidden or 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
(function () { | |
'use strict'; | |
var Λ_Λ = console.log, | |
ಠ_ಠ = "feeling happy", | |
ↂ = "look mom no hands", | |
iǃ = Infinity, | |
Θ_Θ = "hey buddy", | |
Ψ = function(e){throw e;}; | |
This file contains hidden or 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
/* iPhone 6 landscape */ | |
@media only screen and (min-device-width: 375px) | |
and (max-device-width: 667px) | |
and (orientation: landscape) | |
and (-webkit-min-device-pixel-ratio: 2) | |
{ } | |
/* iPhone 6 portrait */ | |
@media only screen | |
and (min-device-width: 375px) |
This file contains hidden or 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
var runSequence = require('run-sequence'); // https://www.npmjs.com/package/run-sequence | |
//Each successive argument waits for the previous task(s) to finish | |
gulp.task('some-task', function () { | |
runSequence( | |
['task-1', 'task-2', 'task-3'], // These 3 can be done in parallel | |
'task-4', // ...then just do this | |
['task-5', 'task-5'], // ...then do these things in parallel | |
'task-6', // ...then do this | |
// ... |
This file contains hidden or 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
/* | |
@supports(test condition) { | |
apply rules | |
} | |
@supports not(test condition) { | |
apply rules | |
} | |
*/ | |
/* use CSS variable */ | |
@supports (background-color: var(--bg-color)) { /* support: http://caniuse.com/#feat=css-variables */ |
This file contains hidden or 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
/* old Sass 3.3 */ | |
/* nest keyframe rules inside their modules with `@at-root` */ | |
.bunny { | |
animation: hop 2s ease-in-out infinite, | |
move 6s ease-out forwards; | |
@at-root { | |
@keyframes hop { | |
50% { transform: translateY(40px); } | |
} |
This file contains hidden or 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
// Streamlined CTM method using Page Visibility API (http://caniuse.com/#feat=pagevisibility) | |
if ('visibilityState' in document) { | |
// Modern browser, add JS functionality | |
} | |
// Previous CTM method based on which DOM features are present | |
if('querySelector' in document | |
&& 'localStorage' in window | |
&& 'addEventListener' in window) { | |
// Modern browser, add JS functionality |
This file contains hidden or 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
// localStorage example | |
var hasStorage = (function () { | |
try { | |
localStorage.setItem(mod, mod); | |
localStorage.removeItem(mod); | |
return true; | |
} catch (exception) { | |
return false; | |
} | |
}()); |
This file contains hidden or 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
var getAbsoluteUrl = (function () { | |
var a; | |
return function (url) { | |
if(!a) a = document.createElement('a'); | |
a.href = url; | |
return a.href; | |
}; | |
})(); |