Skip to content

Instantly share code, notes, and snippets.

View argyleink's full-sized avatar
💀
calc(dev*design)

Adam Argyle argyleink

💀
calc(dev*design)
View GitHub Profile
@tbeseda
tbeseda / isMobile.js
Last active December 11, 2015 10:48
// Simple method to detect a mobile device
function isMobile(){
return (/iphone|ipod|android|blackberry/).test(navigator.userAgent.toLowerCase());
}
// Example usage:
if(isMobile()){
console.log('This is a mobile device.');
} else {
console.log('This is not a mobile device');
@ninjascribble
ninjascribble / gist:4602255
Last active December 11, 2015 12:38
jQuery $.Deferred chaining example. jsfiddle: http://jsfiddle.net/B5eZ9/1/
var a = getPromise(50)
, b = getPromise.bind(document, 1200)
, c = getPromise.bind(document, 400);
a.then(b).then(c).done(finish);
function getPromise(ttl) {
var deferred = $.Deferred();
@ninjascribble
ninjascribble / user-agent-match.js
Created March 8, 2013 22:07
user agent matching on the client-side
/** User-agent pattern matching */
var browser = 'unknown'
, version = 'unknown'
, patterns = {
android: /android\s([0-9.]*)/i
chrome: /chrome\/([0-9.]*)/i,
firefox: /firefox\/([0-9.]*)/i,
ie: /msie\s([0-9.]*)/i,
ipad: /ipad.version\/([0-9.]*).safari/i,
iphone_4: /iphone\sos\s4.version.mobile\/([0-9.]*).safari/i,
@mattyoho
mattyoho / ios-test.css
Created October 19, 2011 19:12 — forked from tonywok/ios-test.css
iOS Media Queries
// iOS Media Queries
// Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2
//
// Author: Tony Schneider (@tonywok)
// Please tell me where I fail. :)
// iPhone v(4,4S) portrait
// test: black text (overwritten by v* portrait) with blue background
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) {
a {
@staltz
staltz / .bashrc
Created March 7, 2017 13:08
Show a macOS notification when a terminal task is done
# Name it whatever you want. I like `y` because in my keyboard layout it's close to `;`
function y() {
previous=$?
if [ $previous -eq 0 ]; then
osascript -e "display notification \"Done\" with title \"Terminal Task\"" && say "it is done";
else
osascript -e "display notification \"Failed\" with title \"Terminal Task\"" && say "it went to the trees";
fi
}
@eklimcz-zz
eklimcz-zz / touchEventWireup
Created September 25, 2012 16:52
Cross browser touch event wireup
function inferInputModel() {
if (window.navigator.msPointerEnabled) {
return 'pointer';
} else if (window.ontouchstart !== undefined) {
return 'touch';
} else {
return 'unknown';
}
}
@christopherdebeer
christopherdebeer / snippet.js
Created September 7, 2011 09:22
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
@argyleink
argyleink / blingbling.js
Last active May 19, 2018 01:04 — forked from paulirish/bling.js
add some sugar to bling dot js
const sugar = {
on: function(names, fn) {
names
.split(' ')
.forEach(name =>
this.addEventListener(name, fn))
},
setAttributes: function(attrs) {
Object.entries(attrs)
.forEach(([key, val]) =>
@tomhodgins
tomhodgins / css-input.css
Last active September 5, 2019 16:51
Code from “How to Design & Support Your Own Custom CSS Features”, watch on YouTube → https://youtu.be/Q3yruVWYHWk
@--variation 1 {
body { background: lime; }
h1 { font-size: 10pt; }
}
@--variation 2 {
body { background: orange; }
h1 { font-size: 99pt; }
}
@una
una / color-functions.md
Last active March 11, 2020 13:15
CSS Color Functions

CSS Color Functions

Web developers and design systems developers often use functions to design components. With the increasing usage of design systems that support multiple platforms, and increased capability of Dark Mode in UI, this becomes even more useful to not need to manually set color, and to instead have a single source from which layouts are calculated. Currently Sass, calc() on HSL values, or PostCSS is used to do this.

Examples:

  • Components with color variations based on calculations from a parent. (i.e. Button with outline that uses the primary button color to adjust the size)
  • Theming - Palletes based on a color or set of colors for themes. Especially when a single base system is used with multiple themes
  • Uniformity among transformations between components with different primary colors

Proposal