Skip to content

Instantly share code, notes, and snippets.

@hotmeteor
Last active December 15, 2015 01:09
Show Gist options
  • Save hotmeteor/5177934 to your computer and use it in GitHub Desktop.
Save hotmeteor/5177934 to your computer and use it in GitHub Desktop.
These are my common SCSS mixins and helpers. Requires bourbon (http://bourbon.io)
$buttons-list: '.btn',
'button',
'input[type=submit]',
'input[type=button]';
$unquoted-buttons-list: ();
@each $button-type in $buttons-list {
$unquoted-buttons-list: append($unquoted-buttons-list, unquote($button-type), comma);
}
$all-buttons: $unquoted-buttons-list;
@mixin font-size($base-font-size) {
$rem-ratio: $base-font-size / 16px;
font-size: $base-font-size;
font-size: #{$rem-ratio}rem;
}
@mixin filter($value) {
@include prefixer(filter, $value, webkit spec);
}
@mixin appearance($value:none) {
@include prefixer(appearance, $value, webkit moz ms o spec);
}
@mixin ellipsis($use: true) {
@if($use) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
}
@else {
white-space: normal;
overflow: visible;
text-overflow: visible;
-o-text-overflow: visible;
}
}
// none | text | toggle | element | elements | all | inherit
@mixin user-select($value: none) {
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
@include prefixer(user-select, $value, webkit moz ms o spec);
}
// Media Query breaks.
//$break-small: 480px;
$break-device: 600px;
$break-smallscreen: 800px;
$break-large: 980px;
$break-xlarge: 1180px;
$break-xxlarge: 1620px;
$break-tv: 1900px;
@mixin respond-to($media) {
@if $media == device-max {
@media only screen and (max-width: $break-device) { @content; }
}
@else if $media == tablet {
@media only screen and (min-width: $break-device + 1) { @content; }
}
@else if $media == smallscreen {
@media only screen and (min-width: $break-smallscreen) { @content; }
}
@else if $media == desktop {
@media only screen and (min-width: $break-large) { @content; }
}
@else if $media == desktop-large {
@media only screen and (min-width: $break-xlarge) { @content; }
}
@else if $media == widescreen {
@media only screen and (min-width: $break-xxlarge) { @content; }
}
/* iPhone 5 or iPod Touch 5th generation */
@else if $media == iphone5 {
@media (device-height: 568px) and (-webkit-min-device-pixel-ratio: 1.5) { @content; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment