Skip to content

Instantly share code, notes, and snippets.

@danilostrazzullo
Last active March 15, 2017 11:03
Show Gist options
  • Save danilostrazzullo/fe1f46869d904f4a9bd59b1035d5f6f5 to your computer and use it in GitHub Desktop.
Save danilostrazzullo/fe1f46869d904f4a9bd59b1035d5f6f5 to your computer and use it in GitHub Desktop.
Useful Sass Mixins
/// Responsive breakpoint manager
/// @access public
/// @param {String} $breakpoint - Breakpoint name
/// @requires $breakpoints
@mixin respond-to($breakpoint) {
$raw-query: map-get($breakpoints, $breakpoint);
@if $raw-query {
$query: if(
type-of($raw-query) == 'string',
unquote($raw-query),
inspect($raw-query)
);
@media #{$query} {
@content;
}
} @else {
@error 'No value found for `#{$breakpoint}`. '
+ 'Please make sure it is defined in `$breakpoints` map.';
}
}
/// Calculate 'letter-spacing' from Photoshop value to ems
/// @access public
/// @param {Number} $value - Unitless letter spacing value
@mixin letter-spacing($value: 0) {
letter-spacing: ($value / 1000) * 1em;
}
/// Font smoothing
/// @access public
/// @param {Boolean} $bool - Boolean value
@mixin font-smoothing($bool: true) {
@if $bool == true {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
} @else {
-webkit-font-smoothing: subpixel-antialiased;
-moz-osx-font-smoothing: auto;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment