Debian Codegraph @

debian/missing-sources/bourbon-neat/app/assets/stylesheets/grid/_media.scss

raw
1 @charset "UTF-8";
2
3 /// Outputs a media-query block with an optional grid context (the total number of columns used in the grid).
4 ///
5 /// @param {List} $query
6 /// A list of media query features and values, where each `$feature` should have a corresponding `$value`.
7 /// For a list of valid values for `$feature`, click [here](http://www.w3.org/TR/css3-mediaqueries/#media1).
8 ///
9 /// If there is only a single `$value` in `$query`, `$default-feature` is going to be used.
10 ///
11 /// The number of total columns in the grid can be set by passing `$columns` at the end of the list (overrides `$total-columns`).
12 ///
13 ///
14 /// @param {Number (unitless)} $total-columns [$grid-columns]
15 /// - Number of columns to use in the new grid context. Can be set as a shorthand in the first parameter.
16 ///
17 /// @example scss - Usage
18 /// .responsive-element {
19 /// @include media(769px) {
20 /// @include span-columns(6);
21 /// }
22 /// }
23 ///
24 /// .new-context-element {
25 /// @include media(min-width 320px max-width 480px, 6) {
26 /// @include span-columns(6);
27 /// }
28 /// }
29 ///
30 /// @example css - CSS Output
31 /// @media screen and (min-width: 769px) {
32 /// .responsive-element {
33 /// display: block;
34 /// float: left;
35 /// margin-right: 2.35765%;
36 /// width: 48.82117%;
37 /// }
38 ///
39 /// .responsive-element:last-child {
40 /// margin-right: 0;
41 /// }
42 /// }
43 ///
44 /// @media screen and (min-width: 320px) and (max-width: 480px) {
45 /// .new-context-element {
46 /// display: block;
47 /// float: left;
48 /// margin-right: 4.82916%;
49 /// width: 100%;
50 /// }
51 ///
52 /// .new-context-element:last-child {
53 /// margin-right: 0;
54 /// }
55 /// }
56
57 @mixin media($query: $feature $value $columns, $total-columns: $grid-columns) {
58 @if length($query) == 1 {
59 @media screen and ($default-feature: nth($query, 1)) {
60 $default-grid-columns: $grid-columns;
61 $grid-columns: $total-columns !global;
62 @content;
63 $grid-columns: $default-grid-columns !global;
64 }
65 } @else {
66 $loop-to: length($query);
67 $media-query: "screen and ";
68 $default-grid-columns: $grid-columns;
69 $grid-columns: $total-columns !global;
70
71 @if is-not(is-even(length($query))) {
72 $grid-columns: nth($query, $loop-to) !global;
73 $loop-to: $loop-to - 1;
74 }
75
76 $i: 1;
77 @while $i <= $loop-to {
78 $media-query: $media-query + "(" + nth($query, $i) + ": " + nth($query, $i + 1) + ") ";
79
80 @if ($i + 1) != $loop-to {
81 $media-query: $media-query + "and ";
82 }
83
84 $i: $i + 2;
85 }
86
87 @media #{$media-query} {
88 @content;
89 $grid-columns: $default-grid-columns !global;
90 }
91 }
92 }