unit.gl 0.0.29 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/css/unit.gl.css +288 -271
  2. package/css/unit.gl.min.css +1 -1
  3. package/package.json +1 -1
  4. package/scss/_global.scss +3 -1
  5. package/scss/_reset.scss +2 -1
  6. package/scss/classes/_index.scss +17 -0
  7. package/scss/classes/_paper.scss +97 -0
  8. package/scss/{math/_math_arithmetic.scss → functions/_arithmetic.scss} +1 -1
  9. package/scss/functions/_index.scss +13 -0
  10. package/scss/{math/_math_ratio.scss → functions/_ratio.scss} +1 -1
  11. package/scss/{math/_math_scale.scss → functions/_scale.scss} +1 -1
  12. package/scss/{math/_math_sequence.scss → functions/_sequence.scss} +1 -1
  13. package/scss/index.scss +6 -19
  14. package/scss/mixins/_device.scss +42 -0
  15. package/scss/{display/_display_orientation.scss → mixins/_display.scss} +9 -13
  16. package/scss/{_guide.scss → mixins/_guide.scss} +3 -1
  17. package/scss/{_helper.scss → mixins/_helper.scss} +2 -4
  18. package/scss/mixins/_index.scss +23 -0
  19. package/scss/mixins/_paper.scss +35 -0
  20. package/scss/mixins/_ratio.scss +171 -0
  21. package/scss/mixins/_view.scss +79 -0
  22. package/scss/{display → variables}/_device.scss +5 -31
  23. package/scss/variables/_index.scss +32 -0
  24. package/scss/{_layer.scss → variables/_layer.scss} +1 -2
  25. package/scss/{_paper.scss → variables/_paper.scss} +3 -109
  26. package/scss/{_scale.scss → variables/_scale.scss} +4 -14
  27. package/scss/{_unit.scss → variables/_unit.scss} +3 -1
  28. package/scss/{_unit_conversion.scss → variables/_unit_conversion.scss} +1 -1
  29. package/scss/{_unit_functions.scss → variables/_unit_functions.scss} +14 -0
  30. package/scss/{_view.scss → variables/_view.scss} +2 -61
  31. package/scss/_ratio.scss +0 -97
@@ -0,0 +1,97 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+
16
+ // ============================================================================
17
+ // Paper Module
18
+ // ============================================================================
19
+
20
+
21
+ @use "../variables" as *;
22
+
23
+
24
+ // Usage
25
+ // ============================================================================
26
+
27
+ // .paper {
28
+
29
+ // // Q Series
30
+ // // ------------------------------------------------------------------------
31
+ // &.q0 { @include set_paper_size("q0"); }
32
+ // &.q1 { @include set_paper_size("q1"); }
33
+ // &.q2 { @include set_paper_size("q2"); }
34
+ // &.q3 { @include set_paper_size("q3"); }
35
+ // &.q4 { @include set_paper_size("q4"); }
36
+ // &.q5 { @include set_paper_size("q5"); }
37
+ // &.q6 { @include set_paper_size("q6"); }
38
+ // &.q7 { @include set_paper_size("q7"); }
39
+ // &.q8 { @include set_paper_size("q8"); }
40
+ // &.q9 { @include set_paper_size("q9"); }
41
+ // &.q10 { @include set_paper_size("q10"); }
42
+
43
+ // // ISO A Series
44
+ // // ------------------------------------------------------------------------
45
+ // &.iso_a0 { @include set_paper_size("iso_a0"); }
46
+ // &.iso_a1 { @include set_paper_size("iso_a1"); }
47
+ // &.iso_a2 { @include set_paper_size("iso_a2"); }
48
+ // &.iso_a3 { @include set_paper_size("iso_a3"); }
49
+ // &.iso_a4 { @include set_paper_size("iso_a4"); }
50
+ // &.iso_a5 { @include set_paper_size("iso_a5"); }
51
+ // &.iso_a6 { @include set_paper_size("iso_a6"); }
52
+ // &.iso_a7 { @include set_paper_size("iso_a7"); }
53
+ // &.iso_a8 { @include set_paper_size("iso_a8"); }
54
+ // &.iso_a9 { @include set_paper_size("iso_a9"); }
55
+ // &.iso_a10 { @include set_paper_size("iso_a10"); }
56
+
57
+ // }
58
+
59
+ // Function to calculate ISO paper sizes
60
+ // @function iso-paper-size($number) {
61
+ // $base-width: 841mm;
62
+ // $base-height: 1189mm;
63
+
64
+ // @for $i from 0 through $number {
65
+ // $base-width: $base-width / if($i > 0, 2, 1);
66
+ // $base-height: $base-height / if($i > 0 and $i % 2 == 0, 2, 1);
67
+ // }
68
+
69
+ // @return (width: $base-width, height: $base-height);
70
+ // }
71
+
72
+
73
+ // Function to calculate ISO B-series paper sizes
74
+ // @function iso-paper-size-b($number) {
75
+ // $base-width: 1000mm; // Approximate base width for B0
76
+ // $base-height: 1414mm; // Approximate base height for B0
77
+
78
+ // @for $i from 0 through $number {
79
+ // $base-width: $base-width / if($i > 0, sqrt(2), 1);
80
+ // $base-height: $base-height / if($i > 0 and $i % 2 == 0, sqrt(2), 1);
81
+ // }
82
+
83
+ // @return (width: $base-width, height: $base-height);
84
+ // }
85
+
86
+ // Function to calculate ISO C-series paper sizes
87
+ // @function iso-paper-size-c($number) {
88
+ // $base-width: 917mm; // Approximate base width for C0
89
+ // $base-height: 1297mm; // Approximate base height for C0
90
+
91
+ // @for $i from 0 through $number {
92
+ // $base-width: $base-width / if($i > 0, sqrt(2), 1);
93
+ // $base-height: $base-height / if($i > 0 and $i % 2 == 0, sqrt(2), 1);
94
+ // }
95
+
96
+ // @return (width: $base-width, height: $base-height);
97
+ // }
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -0,0 +1,13 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
package/scss/index.scss CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
13
13
  // limitations under the License.
14
14
 
15
15
 
16
-
17
16
  /**
18
17
  * unit.gl
19
18
  *
@@ -30,22 +29,10 @@
30
29
 
31
30
  @use "sass:math";
32
31
 
32
+ @forward "variables";
33
+ @forward "mixins";
33
34
 
34
- @import "_reset";
35
- @import "_global";
36
- @import "_layer";
37
-
38
- @import "_paper";
39
-
40
- @import "_view";
41
-
42
- @import "_unit_conversion";
43
- @import "_unit_functions";
44
- @import "_unit";
45
-
46
-
47
- @import "_ratio";
48
- @import "_scale";
35
+ @forward "reset";
36
+ @forward "global";
49
37
 
50
- @import "_helper";
51
- @import "_guide";
38
+ @forward "classes";
@@ -0,0 +1,42 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+
16
+ @use "../variables" as *;
17
+
18
+ /// Generalized Media Query Mixin
19
+ /// Creates a media query based on device attributes defined in $devices map.
20
+ /// @param $device - The key name of the device in the $devices map.
21
+ /// Usage Example:
22
+ /// @include device-media-query('iphone-6-7-8') {// Styles specific to iPhone 6, 7, 8}
23
+ @mixin device-media-query($device) {
24
+ // Retrieve the device attributes from the map
25
+ $attributes: map-get($devices, $device);
26
+
27
+ // Extract individual attributes with default fallbacks
28
+ $min-width: if(map-has-key($attributes, "min-width"), map-get($attributes, "min-width"), null);
29
+ $max-width: if(map-has-key($attributes, "max-width"), map-get($attributes, "max-width"), null);
30
+ $pixel-ratio: if(map-has-key($attributes, "pixel-ratio"), map-get($attributes, "pixel-ratio"), 1); // Default to 1
31
+
32
+ // Construct the media query string
33
+ $media-query: "only screen";
34
+ $media-query: if($min-width != null, $media-query + " and (min-device-width: #{$min-width})", $media-query);
35
+ $media-query: if($max-width != null, $media-query + " and (max-device-width: #{$max-width})", $media-query);
36
+ $media-query: if($pixel-ratio != 1, $media-query + " and (-webkit-device-pixel-ratio: #{$pixel-ratio})", $media-query);
37
+
38
+ // Apply the media query
39
+ @media #{$media-query} {
40
+ @content;
41
+ }
42
+ }
@@ -1,10 +1,10 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
- // Licensed under the Apache License, Version 2.00 (the "License");
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
5
5
  // You may obtain a copy of the License at
6
6
 
7
- // http://www.apache.org/licenses/LICENSE-2.00
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
8
 
9
9
  // Unless required by applicable law or agreed to in writing, software
10
10
  // distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,8 +13,7 @@
13
13
  // limitations under the License.
14
14
 
15
15
 
16
-
17
-
16
+ @use "../variables" as *;
18
17
 
19
18
 
20
19
 
@@ -63,14 +62,11 @@
63
62
  /// Mixin for targeting specific aspect ratios
64
63
  /// @param $width - Width of the aspect ratio
65
64
  /// @param $height - Height of the aspect ratio
66
- @mixin aspect-ratio($width, $height) {
67
- @media (aspect-ratio: #{$width}/#{$height}) {
68
- @content;
69
- }
70
- }
71
-
72
-
73
-
65
+ // @mixin aspect-ratio($width, $height) {
66
+ // @media (aspect-ratio: #{$width}/#{$height}) {
67
+ // @content;
68
+ // }
69
+ // }
74
70
 
75
71
 
76
72
 
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -13,6 +13,8 @@
13
13
  // limitations under the License.
14
14
 
15
15
 
16
+ @use "../variables" as *;
17
+
16
18
  // ============================================================================
17
19
  // Utilities | Guides
18
20
  // ============================================================================
@@ -1,4 +1,4 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -13,9 +13,7 @@
13
13
  // limitations under the License.
14
14
 
15
15
 
16
- // Shorthand helper mixins
17
-
18
-
16
+ @use "../variables" as *;
19
17
 
20
18
 
21
19
 
@@ -0,0 +1,23 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+
16
+
17
+ @forward "paper";
18
+ @forward "view";
19
+ @forward "ratio";
20
+ @forward "device";
21
+ @forward "display";
22
+ @forward "guide";
23
+ @forward "helper";
@@ -0,0 +1,35 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+
16
+ // ============================================================================
17
+ // Paper Module
18
+ // ============================================================================
19
+
20
+ @use "../variables" as *;
21
+
22
+ // Apply Function
23
+ // ============================================================================
24
+
25
+ @mixin set_paper_size($size) {
26
+ @if map-has-key($paper-sizes, $size) {
27
+ $size-map: map-get($paper-sizes, $size);
28
+ width: map-get($size-map, width);
29
+ height: map-get($size-map, height);
30
+ } @else {
31
+ @warn "Invalid paper size: #{$size}.";
32
+ }
33
+ }
34
+
35
+
@@ -0,0 +1,171 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ @use "../variables" as *;
16
+
17
+
18
+ // ============================================================================
19
+ // Layout | Ratio
20
+ // ============================================================================
21
+
22
+ // Aspect Ratio Box:
23
+ // Creates a container with a specific aspect ratio.
24
+ // @mixin aspect-ratio($width, $height) {
25
+ // position: relative;
26
+ // &:before {
27
+ // content: '';
28
+ // display: block;
29
+ // padding-top: calc(($height / $width) * 100%);
30
+ // }
31
+ // > * {
32
+ // position: absolute;
33
+ // top: 0;
34
+ // left: 0;
35
+ // right: 0;
36
+ // bottom: 0;
37
+ // }
38
+ // }
39
+
40
+ // .ratio-box {
41
+ // @include aspect-ratio(16, 9);
42
+ // }
43
+
44
+ @mixin ratio ($val01, $val02) {
45
+ aspect-ratio: calc($val01 / $val02);
46
+ width: 100%;
47
+ position: relative;
48
+ overflow: hidden;
49
+ display: inline-block;
50
+ // vertical-align: top;
51
+ }
52
+
53
+ @mixin ratio_1x1 { @include ratio(1, 1); }
54
+ @mixin ratio_1x2 { @include ratio(1, 2); }
55
+ @mixin ratio_2x1 { @include ratio(2, 1); }
56
+ @mixin ratio_1x3 { @include ratio(1, 3); }
57
+ @mixin ratio_3x1 { @include ratio(3, 1); }
58
+ @mixin ratio_1x4 { @include ratio(1, 4); }
59
+ @mixin ratio_4x1 { @include ratio(4, 1); }
60
+ @mixin ratio_3x2 { @include ratio(3, 2); }
61
+ @mixin ratio_2x3 { @include ratio(2, 3); }
62
+ @mixin ratio_4x3 { @include ratio(4, 3); }
63
+ @mixin ratio_3x4 { @include ratio(3, 4); }
64
+ @mixin ratio_16x9 { @include ratio(16, 9); }
65
+ @mixin ratio_16x10 { @include ratio(16, 10); }
66
+
67
+ .ratio_1x1 { @include ratio_1x1; }
68
+ .ratio_1x2 { @include ratio_1x2; }
69
+ .ratio_2x1 { @include ratio_2x1; }
70
+ .ratio_1x3 { @include ratio_1x3; }
71
+ .ratio_3x1 { @include ratio_3x1; }
72
+ .ratio_1x4 { @include ratio_1x4; }
73
+ .ratio_4x1 { @include ratio_4x1; }
74
+ .ratio_3x2 { @include ratio_3x2; }
75
+ .ratio_2x3 { @include ratio_2x3; }
76
+ .ratio_4x3 { @include ratio_4x3; }
77
+ .ratio_3x4 { @include ratio_3x4; }
78
+ .ratio_16x9 { @include ratio_16x9; }
79
+ .ratio_16x10 { @include ratio_16x10; }
80
+
81
+
82
+ // .
83
+ // ----------------------------------------------------------------------------
84
+
85
+ @mixin ratio_p ($val01) {
86
+ padding-bottom: $val01;
87
+ width: 100%;
88
+ position: relative;
89
+ overflow: hidden;
90
+ display: inline-block;
91
+ // vertical-align: top;
92
+ }
93
+
94
+ @mixin ratio_p_1x1 { @include ratio_p(100.00%); }
95
+ @mixin ratio_p_1x2 { @include ratio_p(200.00%); }
96
+ @mixin ratio_p_2x1 { @include ratio_p( 50.00%); }
97
+ @mixin ratio_p_1x3 { @include ratio_p(300.00%); }
98
+ @mixin ratio_p_3x1 { @include ratio_p( 33.33%); }
99
+ @mixin ratio_p_1x4 { @include ratio_p(400.00%); }
100
+ @mixin ratio_p_4x1 { @include ratio_p( 25.00%); }
101
+ @mixin ratio_p_2x3 { @include ratio_p(150.00%); }
102
+ @mixin ratio_p_3x2 { @include ratio_p( 66.67%); }
103
+ @mixin ratio_p_3x4 { @include ratio_p(133.33%); }
104
+ @mixin ratio_p_4x3 { @include ratio_p( 75.00%); }
105
+ @mixin ratio_p_16x9 { @include ratio_p( 56.25%); }
106
+ @mixin ratio_p_16x10 { @include ratio_p( 62.50%); }
107
+
108
+ .ratio_p_1x1 { @include ratio_p_1x1; }
109
+ .ratio_p_1x2 { @include ratio_p_1x2; }
110
+ .ratio_p_2x1 { @include ratio_p_2x1; }
111
+ .ratio_p_1x3 { @include ratio_p_1x3; }
112
+ .ratio_p_3x1 { @include ratio_p_3x1; }
113
+ .ratio_p_1x4 { @include ratio_p_1x4; }
114
+ .ratio_p_4x1 { @include ratio_p_4x1; }
115
+ .ratio_p_3x2 { @include ratio_p_3x2; }
116
+ .ratio_p_2x3 { @include ratio_p_2x3; }
117
+ .ratio_p_4x3 { @include ratio_p_4x3; }
118
+ .ratio_p_3x4 { @include ratio_p_3x4; }
119
+ .ratio_p_16x9 { @include ratio_p_16x9; }
120
+ .ratio_p_16x10 { @include ratio_p_16x10; }
121
+
122
+
123
+
124
+
125
+ // https://github.com/twbs/bootstrap/blob/main/scss/helpers/_ratio.scss
126
+ // Credit: Nicolas Gallagher and SUIT CSS.
127
+
128
+ // .ratio {
129
+ // position: relative;
130
+ // width: 100%;
131
+
132
+ // &::before {
133
+ // display: block;
134
+ // padding-top: var(--#{$prefix}aspect-ratio);
135
+ // content: "";
136
+ // }
137
+
138
+ // > * {
139
+ // position: absolute;
140
+ // top: 0;
141
+ // left: 0;
142
+ // width: 100%;
143
+ // height: 100%;
144
+ // }
145
+ // }
146
+
147
+ // @each $key, $ratio in $aspect-ratios {
148
+ // .ratio-#{$key} {
149
+ // --#{$prefix}aspect-ratio: #{$ratio};
150
+ // }
151
+ // }
152
+
153
+
154
+ // @mixin aspect-ratio($width, $height) {
155
+ // position: relative;
156
+
157
+ // &::before {
158
+ // display: block;
159
+ // content: "";
160
+ // width: 100%;
161
+ // padding-top: calc((#{$height} / #{$width}) * 100%);
162
+ // }
163
+
164
+ // > * {
165
+ // position: absolute;
166
+ // top: 0;
167
+ // right: 0;
168
+ // bottom: 0;
169
+ // left: 0;
170
+ // }
171
+ // }
@@ -0,0 +1,79 @@
1
+ // Copyright 2024 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+
16
+ @use "../variables" as *;
17
+
18
+ // ============================================================================
19
+ // Media | Screen
20
+ // ============================================================================
21
+
22
+ // Media Query Mixins
23
+ // ============================================================================
24
+
25
+ @mixin breakpoint($size) {
26
+ @if map-has-key($breakpoints, $size) {
27
+ @media (min-width: map-get($breakpoints, $size)) {
28
+ @content;
29
+ }
30
+ } @else {
31
+ @warn "Invalid breakpoint: #{$size}.";
32
+ }
33
+ }
34
+
35
+ @mixin media_xs {
36
+ @media (min-width: $media_xs) { @content; }
37
+ }
38
+
39
+ @mixin media_sm {
40
+ @media (min-width: $media_sm) { @content; }
41
+ }
42
+
43
+
44
+ @mixin media_md {
45
+ @media (min-width: $media_md) { @content; }
46
+ }
47
+
48
+ @mixin media_lg {
49
+ @media (min-width: $media_lg) { @content; }
50
+ }
51
+
52
+
53
+ @mixin media_xl {
54
+ @media (min-width: $media_xl) { @content; }
55
+ }
56
+
57
+ @mixin media_sl {
58
+ @media (min-width: $media_sl) { @content; }
59
+ }
60
+
61
+
62
+ // Example
63
+ // @include breakpoint(md) {
64
+ // // Styles for medium screens and up
65
+ // }
66
+
67
+
68
+ // Syntax
69
+ // @media media type and (condition: breakpoint) {
70
+ // // CSS rules
71
+ // }
72
+
73
+ // @media screen, print {
74
+ // /* … */
75
+ // }
76
+
77
+ // @media (min-width: 30em) and (orientation: landscape) {
78
+ // /* … */
79
+ // }
@@ -1,10 +1,10 @@
1
- // Copyright 2020 Scape Agency BV
1
+ // Copyright 2024 Scape Agency BV
2
2
 
3
- // Licensed under the Apache License, Version 2.00 (the "License");
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
5
5
  // You may obtain a copy of the License at
6
6
 
7
- // http://www.apache.org/licenses/LICENSE-2.00
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
8
 
9
9
  // Unless required by applicable law or agreed to in writing, software
10
10
  // distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,7 +15,6 @@
15
15
 
16
16
 
17
17
 
18
-
19
18
  // Device Attribute Map
20
19
  $devices: (
21
20
  // iPhones
@@ -63,7 +62,7 @@ $devices: (
63
62
  // ------------------------------------------------------------------------
64
63
  "macbook-air": ("min-width": 1440px, "max-width": 2560px, "pixel-ratio": 2),
65
64
  "macbook-pro": ("min-width": 1680px, "max-width": 3072px, "pixel-ratio": 2),
66
- "imac": ("min-width": 1920px, "max-width": 5120px, "pixel-ratio": 2)
65
+ "imac": ("min-width": 1920px, "max-width": 5120px, "pixel-ratio": 2),
67
66
 
68
67
  // Additional Devices
69
68
  // ------------------------------------------------------------------------
@@ -74,33 +73,8 @@ $devices: (
74
73
  "xiaomi-mi9": ("min-width": 393px, "max-width": 851px, "pixel-ratio": 3),
75
74
  "surface-book": ("min-width": 1500px, "max-width": 2000px, "pixel-ratio": 2),
76
75
  "dell-xps": ("min-width": 1920px, "max-width": 3840px, "pixel-ratio": 2),
77
- "lenovo-thinkpad": ("min-width": 1440px, "max-width": 2560px, "pixel-ratio": 2)
76
+ "lenovo-thinkpad": ("min-width": 1440px, "max-width": 2560px, "pixel-ratio": 2),
78
77
 
79
78
  );
80
79
 
81
80
 
82
- /// Generalized Media Query Mixin
83
- /// Creates a media query based on device attributes defined in $devices map.
84
- /// @param $device - The key name of the device in the $devices map.
85
- /// Usage Example:
86
- /// @include device-media-query('iphone-6-7-8') {// Styles specific to iPhone 6, 7, 8}
87
- @mixin device-media-query($device) {
88
- // Retrieve the device attributes from the map
89
- $attributes: map-get($devices, $device);
90
-
91
- // Extract individual attributes with default fallbacks
92
- $min-width: if(map-has-key($attributes, "min-width"), map-get($attributes, "min-width"), null);
93
- $max-width: if(map-has-key($attributes, "max-width"), map-get($attributes, "max-width"), null);
94
- $pixel-ratio: if(map-has-key($attributes, "pixel-ratio"), map-get($attributes, "pixel-ratio"), 1); // Default to 1
95
-
96
- // Construct the media query string
97
- $media-query: "only screen";
98
- $media-query: if($min-width != null, $media-query + " and (min-device-width: #{$min-width})", $media-query);
99
- $media-query: if($max-width != null, $media-query + " and (max-device-width: #{$max-width})", $media-query);
100
- $media-query: if($pixel-ratio != 1, $media-query + " and (-webkit-device-pixel-ratio: #{$pixel-ratio})", $media-query);
101
-
102
- // Apply the media query
103
- @media #{$media-query} {
104
- @content;
105
- }
106
- }