Ghost/core/client/assets/sass/modules/breakpoint.scss
2013-10-27 16:25:26 +01:00

152 lines
3.4 KiB
SCSS

/*
* Breakpoint Sass 2.0.6
* Last updated: July 2013
* Copyright: Mason Wendell 2012 - MIT Licensed
* Source: https://github.com/canarymason/breakpoint
*/
//////////////////////////////
// Default Variables
//////////////////////////////
// Default Features
$breakpoint-default-media: all !default;
$breakpoint-default-feature: min-width !default;
$breakpoint-default-pair: width !default;
// Default Transforms
$breakpoint-force-media-all: false !default;
$breakpoint-to-ems: false !default;
$breakpoint-resolutions: true !default;
// Default No Query Options
$breakpoint-no-queries: false !default;
$breakpoint-no-query-fallbacks: false !default;
// Deftault Base Font Size
$breakpoint-base-font-size: 16px !default;
// Legacy Syntax Support
$breakpoint-legacy-syntax: false !default;
//////////////////////////////
// Imports
//////////////////////////////
@import 'breakpoint/context';
@import 'breakpoint/helpers';
@import 'breakpoint/parsers';
@import 'breakpoint/no-query';
@import 'breakpoint/respond-to';
//////////////////////////////
// Breakpoint Mixin
//////////////////////////////
@mixin breakpoint($query, $no-query: false) {
// Internal Variables
$query-string: '';
// Reset contexts
@include private-breakpoint-reset-contexts();
// Test to see if it's a comma-separated list
$or-list: is-breakpoint-list($query);
$query-fallback: false;
@if ($or-list != false and $breakpoint-legacy-syntax == false) {
$length: length($query);
$last: nth($query, $length);
$query-fallback: breakpoint-no-query($last);
@if ($query-fallback != false) {
$length: $length - 1;
}
@for $i from 1 through $length {
@if $i == 1 {
$query-string: breakpoint-parse(nth($query, $i));
}
@else {
$query-string: $query-string + ', ' + breakpoint-parse(nth($query, $i));
}
}
}
@else {
@if ($breakpoint-legacy-syntax == true) {
$length: length($query);
$last: nth($query, $length);
$query-fallback: breakpoint-no-query($last);
@if ($query-fallback != false) {
$length: $length - 1;
}
$mq: ();
@for $i from 1 through $length {
$mq: append($mq, nth($query, $i), comma);
}
$query-string: breakpoint-parse($mq);
}
@else {
$query-string: breakpoint-parse($query);
}
}
// Allow for an as-needed override or usage of no query fallback.
@if $no-query != false {
$query-fallback: $no-query;
}
// Print Out Query String
@if not $breakpoint-no-queries {
@media #{$query-string} {
@content;
}
}
@if $breakpoint-no-query-fallbacks != false {
$type: type-of($breakpoint-no-query-fallbacks);
$print: false;
@if ($type == 'bool') {
$print: true;
}
@else if ($type == 'string') {
@if $query-fallback == $breakpoint-no-query-fallbacks {
$print: true;
}
}
@else if ($type == 'list') {
@each $wrapper in $breakpoint-no-query-fallbacks {
@if $query-fallback == $wrapper {
$print: true;
}
}
}
// Write Fallback
@if ($query-fallback != false) and ($print == true) {
$type-fallback: type-of($query-fallback);
@if ($type-fallback != 'bool') {
#{$query-fallback} & {
@content;
}
}
@else {
@content;
}
}
}
@include private-breakpoint-reset-contexts();
}