5 // Foundation for Apps has three core breakpoints: small (> 0), medium (>= 640), and large (>= 1024).
6 // There are two additional breakpoints, xlarge, and xxlarge, which (by default) do not output as sizing classes.
7 // Access named breakpoints using the mixin breakpoint($size), where $size is a breakpoint value.
8 // You can also pass an em, rem, or pixel value into this mixin to generate an em-based media query.
9 // Create new named breakpoints using the $breakpoints map. Change which named breakpoints get their own classes by modifying the $breakpoint-classes map.
10 // NOTE: If you change the $breakpoints map, know that all values must be ordered by width, smallest width first. So 0 is always your first value.
13 // - - - - - - - - - - - - - - -
15 /// @Foundation.settings
17 // These are our named breakpoints. You can use them in our breakpoint function like this: @include breakpoint(medium) { // Medium and larger styles }
20 medium: rem-calc(640),
21 large: rem-calc(1200),
22 xlarge: rem-calc(1440),
23 xxlarge: rem-calc(1920),
26 // All of the names in this list will be output as classes in your CSS, like small-12, medium-6, and so on.
27 $breakpoint-classes: (small medium large) !default;
31 // - - - - - - - - - - - - - - -
33 /// Wraps a media query around the content you put inside the mixin. This mixin accepts a number of values:
34 /// - If a string is passed, the mixin will look for it in the $breakpoints map, and use a media query there.
35 /// - If a pixel value is passed, it will be converted to an em value using $rem-base.
36 /// - If a rem value is passed, the unit will be changed to em.
37 /// - If an em value is passed, the value will be used as-is.
39 /// @param {mixed} $val - Breakpoint name or px/em/rem value to process.
41 /// @output If the breakpoint is "0px and larger", outputs the content. Otherwise, outputs the content wrapped in a media query.
42 @mixin breakpoint($val: small) {
45 // Value for max-width media queries
47 // Direction of media query (up, down, or only)
48 $dir: if(length($val) > 1, nth($val, 2), up);
51 // Is it a named media query?
54 // Orientation media queries have a unique syntax
55 @if $bp == 'landscape' or $bp == 'portrait' {
56 $str: $str + ' and (orientation: #{$bp})';
60 // Try to pull a named breakpoint out of the $breakpoints map
61 @if type-of($bp) == 'string' {
62 @if map-has-key($breakpoints, $bp) {
64 $next-bp: map-next($breakpoints, $bp);
65 @if $next-bp == null {
69 $bpMax: $next-bp - (1/16);
72 $bp: map-get($breakpoints, $bp);
80 // Pixel and unitless values are converted to rems
81 @if unit($bp) == 'px' or unit($bp) == '' {
84 // Finally, the rem value is turned into an em value
85 $bp: strip-unit($bp) * 1em;
87 // Skip media query creation if the input is "0 up" or "0 down"
88 @if $bp > 0 or $dir == 'only' {
89 // And lo, a media query was born
92 $str: $str + ' and (min-width: #{$bp})';
94 $str: $str + ' and (max-width: #{$bpMax})';
98 @debug 'ERROR: Only named media queries can have an "only" range.';
101 @else if $dir == 'down' {
103 $str: $str + ' and (max-width: #{$max})';
106 $str: $str + ' and (min-width: #{$bp})';
112 @if $bp == 0em and $dir != 'only' {
122 /// Prefixes selector $class with breakpoint keywords, allowing you to create a batch of breakpoint classes with one chunk of code. If you want to skip a breakpoint (like small, because mobile first and all that), add values to the $omit parameter.
124 /// @param {string} $class - Class to prefix with the breakpoint name and a hyphen.
125 /// @param {list} $omit - Named breakpoints to skip. No class will be added with breakpoints in this list.
126 @mixin each-breakpoint($class, $omit: ()) {
127 // Iterate through breakpoint classes
128 @each $size in $breakpoint-classes {
129 // Only do something if the breakpoint is not in $omit
130 @if index($omit, $size) == null {
131 $val: map-get($breakpoints, $size);
132 // Prefix $class with $size and a hyphen
133 .#{$size + '-' + $class} {
134 @include breakpoint($size) {
143 // - - - - - - - - - - - - - - -
145 // Meta styles are included in all builds, as they are a dependancy of the Javascript.
146 // Used to provide media query values for javascript components.
147 // Forward slash placed around everything to convince PhantomJS to read the value.
149 meta.foundation-version {
150 font-family: "#{$foundation-version}";
153 font-family: "#{map-serialize($breakpoints)}";