unit.gl 0.0.35 → 0.0.39

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 (72) hide show
  1. package/LICENSE +21 -201
  2. package/README.md +30 -74
  3. package/css/unit.gl.css +28 -65
  4. package/css/unit.gl.min.css +1 -1
  5. package/package.json +13 -8
  6. package/scss/_global.scss +5 -23
  7. package/scss/_reset.scss +13 -15
  8. package/scss/classes/_guide.scss +126 -0
  9. package/scss/classes/_index.scss +25 -11
  10. package/scss/classes/_ratio.scss +30 -0
  11. package/scss/dev/_banner.scss +30 -1
  12. package/scss/dev/_index.scss +0 -0
  13. package/scss/functions/_color.scss +40 -0
  14. package/scss/functions/_index.scss +39 -16
  15. package/scss/functions/_layer.scss +48 -0
  16. package/scss/functions/_ratio.scss +58 -157
  17. package/scss/functions/_scale.scss +55 -49
  18. package/scss/functions/_sequence.scss +154 -126
  19. package/scss/functions/_view.scss +40 -0
  20. package/scss/functions/math/_arithmetic.scss +102 -0
  21. package/scss/functions/math/_index.scss +30 -0
  22. package/scss/functions/unit/_index.scss +30 -0
  23. package/scss/functions/unit/_unit_conversion.scss +94 -0
  24. package/scss/functions/{_unit_functions.scss → unit/_unit_functions.scss} +70 -36
  25. package/scss/index.scss +2 -16
  26. package/scss/maps/_color.scss +43 -0
  27. package/scss/maps/_index.scss +1 -0
  28. package/scss/mixins/_device.scss +63 -25
  29. package/scss/mixins/_display.scss +106 -44
  30. package/scss/mixins/_guide.scss +191 -158
  31. package/scss/mixins/_helper.scss +287 -52
  32. package/scss/mixins/_index.scss +50 -17
  33. package/scss/mixins/_paper.scss +38 -17
  34. package/scss/mixins/_ratio.scss +30 -13
  35. package/scss/mixins/_unit.scss +94 -0
  36. package/scss/mixins/_view.scss +123 -44
  37. package/scss/tags/_index.scss +30 -0
  38. package/scss/tags/_unit.scss +40 -0
  39. package/scss/utilities/_guides.scss +103 -0
  40. package/scss/utilities/_index.scss +6 -0
  41. package/scss/variables/_color.scss +83 -0
  42. package/scss/variables/_device.scss +140 -50
  43. package/scss/variables/_index.scss +84 -16
  44. package/scss/variables/_layer.scss +148 -51
  45. package/scss/variables/_paper.scss +243 -17
  46. package/scss/variables/_ratio.scss +224 -0
  47. package/scss/variables/_scale.scss +230 -104
  48. package/scss/variables/_unit.scss +76 -72
  49. package/scss/variables/_view.scss +135 -39
  50. package/ts/AspectRatio.ts +29 -0
  51. package/ts/Border.ts +29 -0
  52. package/ts/BoxModel.ts +40 -0
  53. package/ts/FlexContainer.ts +48 -0
  54. package/ts/Grid.ts +21 -0
  55. package/ts/GridContainer.ts +33 -0
  56. package/ts/Layout.ts +34 -0
  57. package/ts/Position.ts +28 -0
  58. package/ts/Rectangle.ts +28 -0
  59. package/ts/ResponsiveImage.ts +28 -0
  60. package/ts/ResponsiveScale.ts +21 -0
  61. package/ts/Size.ts +32 -0
  62. package/ts/Spacing.ts +68 -0
  63. package/ts/Transform.ts +38 -0
  64. package/ts/Typography.ts +41 -0
  65. package/ts/Unit.ts +57 -0
  66. package/ts/Viewport.ts +24 -0
  67. package/js/index.d.ts +0 -1
  68. package/js/index.js +0 -3
  69. package/js/unit.gl.min.js +0 -1
  70. package/scss/classes/_paper.scss +0 -97
  71. package/scss/functions/_arithmetic.scss +0 -64
  72. package/scss/functions/_unit_conversion.scss +0 -77
@@ -0,0 +1,94 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Unit Functions Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Unit
11
+ /// @author Scape Agency
12
+ /// @link https://unit.gl
13
+ /// @since 0.1.0 initial release
14
+ /// @todo None
15
+ /// @access public
16
+ ///
17
+ ////
18
+
19
+
20
+ // ============================================================================
21
+ // Use
22
+ // ============================================================================
23
+
24
+
25
+ // ============================================================================
26
+ // Functions
27
+ // ============================================================================
28
+
29
+
30
+
31
+
32
+
33
+ /// Unit Conversion Functions
34
+ /// ---------------------------------------------------------------------------
35
+ /// Create functions to convert between different measurement units, such as
36
+ /// pixels to rem, em to pixels, etc.
37
+
38
+ @function px_to_rem($size, $base: 16px) {
39
+ @return $size / $base * 1rem;
40
+ }
41
+
42
+ @function rem_to_px($size, $base: 16px) {
43
+ @return $size * $base;
44
+ }
45
+
46
+ @function em_to_px($size, $context: 16px) {
47
+ @return $size * $context;
48
+ }
49
+
50
+ @function px_to_em($size, $context: 16px) {
51
+ @return $size / $context * 1em;
52
+ }
53
+
54
+
55
+ /// Base font-size for the document
56
+ $base-font-size: 16px !default;
57
+
58
+ /// Validate that the input is a pixel value
59
+ @function validate-px($value) {
60
+ @if unit($value) != 'px' {
61
+ @error "Expected a pixel value, but got `#{$value}`.";
62
+ }
63
+ @return $value;
64
+ }
65
+
66
+ /// Convert pixels to rem
67
+ @function px_to_rem($size) {
68
+ $validated-size: validate-px($size);
69
+ @return $validated-size / $base-font-size * 1rem;
70
+ }
71
+
72
+ /// Convert rem to pixels
73
+ @function rem_to_px($size) {
74
+ @if unit($size) != 'rem' {
75
+ @error "Expected a rem value, but got `#{$size}`.";
76
+ }
77
+ @return $size * $base-font-size;
78
+ }
79
+
80
+ /// Convert em to pixels
81
+ @function em_to_px($size, $context: $base-font-size) {
82
+ $validated-context: validate-px($context);
83
+ @if unit($size) != 'em' {
84
+ @error "Expected an em value, but got `#{$size}`.";
85
+ }
86
+ @return $size * $validated-context;
87
+ }
88
+
89
+ /// Convert pixels to em
90
+ @function px_to_em($size, $context: $base-font-size) {
91
+ $validated-size: validate-px($size);
92
+ $validated-context: validate-px($context);
93
+ @return $validated-size / $validated-context * 1em;
94
+ }
@@ -1,28 +1,41 @@
1
- // Copyright 2024 Scape Agency BV
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
2
4
 
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
5
+ ////
6
+ ///
7
+ /// Unit Functions Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Unit
11
+ /// @author Scape Agency
12
+ /// @link https://unit.gl
13
+ /// @since 0.1.0 initial release
14
+ /// @todo None
15
+ /// @access public
16
+ ///
17
+ ////
6
18
 
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
19
 
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.
20
+ // ============================================================================
21
+ // Use
22
+ // ============================================================================
14
23
 
15
24
 
16
25
  // ============================================================================
17
- // Unit | Functions
26
+ // Functions
18
27
  // ============================================================================
19
28
 
20
29
 
30
+ ///
21
31
  /// Strip Unit Function
22
- /// Function to remove the unit from a numerical value
23
- /// Ensures compatibility with various SCSS versions
24
- /// @param $value - The numerical value with or without a unit
25
- /// @return - The raw numerical value without its unit
32
+ /// ---------------------------------------------------------------------------
33
+ ///
34
+ /// Removes the unit from a numerical value, ensuring compatibility with various SCSS versions.
35
+ ///
36
+ /// @param {Number} $value - The numerical value with or without a unit.
37
+ /// @return {Number} - The raw numerical value without its unit, or the original value if unitless or non-numerical.
38
+ ///
26
39
  @function unit_strip($value) {
27
40
  // Check if the input is a number with a unit
28
41
  @if type-of($value) == "number" and not unitless($value) {
@@ -46,15 +59,20 @@
46
59
  }
47
60
 
48
61
 
62
+ ///
49
63
  /// Linear Interpolation Function
64
+ /// ---------------------------------------------------------------------------
65
+ ///
50
66
  /// Interpolates linearly between two values across a range, useful for
51
67
  /// fluid scaling.
52
- /// @param $start - Starting value at the lower bound (can include units)
53
- /// @param $end - Ending value at the upper bound (can include units)
54
- /// @param $min - Lower bound for interpolation (must be unitless or in 'px')
55
- /// @param $max - Upper bound for interpolation (must be unitless or in 'px')
56
- /// @param $actual - Current value to interpolate (default is 100vw)
57
- /// @return - Interpolated value (in the same units as $start and $end)
68
+ ///
69
+ /// @param {Number} $start - Starting value at the lower bound (can include units).
70
+ /// @param {Number} $end - Ending value at the upper bound (can include units).
71
+ /// @param {Number} $min - Lower bound for interpolation (must be unitless or in 'px').
72
+ /// @param {Number} $max - Upper bound for interpolation (must be unitless or in 'px').
73
+ /// @param {Number} $actual - Current value to interpolate (default is 100vw).
74
+ /// @return {Number} - Interpolated value (in the same units as $start and $end).
75
+ ///
58
76
  @function linear_interpolation($start, $end, $min, $max, $actual: 100vw) {
59
77
 
60
78
  // Validate parameters
@@ -92,13 +110,18 @@
92
110
  }
93
111
 
94
112
 
95
- /// Function: scale_dynamic_clamp
96
- /// Calculates font size using clamp-based responsive typography
97
- /// @param $_font_size_min - Minimum font size
98
- /// @param $_font_size_max - Maximum font size
99
- /// @param $_viewport_width_min - Minimum viewport width where scaling starts
100
- /// @param $_viewport_width_max - Maximum viewport width where scaling stops
101
- /// @return - Calculated size using clamp
113
+ ///
114
+ /// Clamp-based Responsive Typography Function
115
+ /// ---------------------------------------------------------------------------
116
+ ///
117
+ /// Calculates font size using clamp-based responsive typography.
118
+ ///
119
+ /// @param {Number} $_font_size_min - Minimum font size.
120
+ /// @param {Number} $_font_size_max - Maximum font size.
121
+ /// @param {Number} $_viewport_width_min - Minimum viewport width where scaling starts.
122
+ /// @param {Number} $_viewport_width_max - Maximum viewport width where scaling stops.
123
+ /// @return {Number} - Calculated size using clamp.
124
+ ///
102
125
  @function scale_dynamic_clamp(
103
126
  $_viewport_width_min,
104
127
  $_viewport_width_max,
@@ -119,10 +142,8 @@
119
142
 
120
143
 
121
144
 
122
-
123
-
124
- // Fluid Typography Mixin
125
- // ============================================================================
145
+ /// Fluid Typography Mixin
146
+ /// ---------------------------------------------------------------------------
126
147
  /// Mixin: fluid_type
127
148
  /// Creates fluid typography rules to scale font sizes responsively between a
128
149
  /// minimum and maximum viewport width.
@@ -149,7 +170,7 @@
149
170
  // // $u4: $_font_size_max;
150
171
 
151
172
  // @if $u1 == $u2 and $u1 == $u3 and $u1 == $u4 {
152
- // font-size: $_font_size_min * 16;
173
+ // font-size: $_font_size_min/// 16;
153
174
  // // Apply fluid font-size between the min and max viewport widths
154
175
  // @media screen and (min-width: $_viewport_width_min) {
155
176
  // font-size: linear_interpolation(
@@ -157,11 +178,11 @@
157
178
  // $_font_size_max,
158
179
  // $_viewport_width_min,
159
180
  // $_viewport_width_max
160
- // ) * 16;
181
+ // )/// 16;
161
182
  // }
162
183
  // // Set to max font-size for viewports wider than the max viewport width
163
184
  // @media screen and (min-width: $_viewport_width_max) {
164
- // font-size: $_font_size_max * 16;
185
+ // font-size: $_font_size_max/// 16;
165
186
  // }
166
187
  // } @else {
167
188
  // @warn "Inconsistent units provided for fluid typography.";
@@ -169,7 +190,20 @@
169
190
  // }
170
191
 
171
192
 
172
-
193
+ ///
194
+ /// Dynamic Scaling Function
195
+ /// ---------------------------------------------------------------------------
196
+ ///
197
+ /// Calculates font size dynamically based on viewport width, allowing for
198
+ /// fluid scaling.
199
+ ///
200
+ /// @param {Number} $_viewport_width_min - Minimum viewport width where scaling starts.
201
+ /// @param {Number} $_viewport_width_max - Maximum viewport width where scaling stops.
202
+ /// @param {Number} $_font_size_min - Minimum font size.
203
+ /// @param {Number} $_font_size_max - Maximum font size.
204
+ /// @param {Number} $_current_width - Current viewport width.
205
+ /// @return {Number} - The calculated font size based on the current width, or null if units are inconsistent.
206
+ ///
173
207
  @function scale_dynamic(
174
208
  $_viewport_width_min,
175
209
  $_viewport_width_max,
package/scss/index.scss CHANGED
@@ -1,18 +1,3 @@
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
1
  @charset "utf-8";
17
2
 
18
3
  @use "sass:math";
@@ -20,8 +5,9 @@
20
5
  @forward "reset";
21
6
  @forward "global";
22
7
 
23
- @forward "variables";
24
8
  @forward "functions";
9
+ @forward "variables";
25
10
  @forward "mixins";
26
11
 
27
12
  @forward "classes";
13
+ @forward "tags";
@@ -0,0 +1,43 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Color Variables Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// These colors are used for visual guides such as grid overlays, baselines,
11
+ /// and alignment guides. The colors are defined with varying levels of opacity
12
+ /// to ensure they are visible yet non-intrusive on the design.
13
+ ///
14
+ /// @group Color
15
+ /// @author Scape Agency
16
+ /// @link https://unit.gl
17
+ /// @since 0.1.0 initial release
18
+ /// @todo None
19
+ /// @access public
20
+ ///
21
+ ////
22
+
23
+
24
+ // ============================================================================
25
+ // Use
26
+ // ============================================================================
27
+
28
+
29
+ // ============================================================================
30
+ // Maps
31
+ // ============================================================================
32
+
33
+ /// Color Set for Easy Adjustments
34
+ /// ---------------------------------------------------------------------------
35
+ ///
36
+ $guide_colors: (
37
+ "primary": $guide_color_primary,
38
+ "secondary": $guide_color_secondary,
39
+ "tertiary": $guide_color_tertiary,
40
+ "quaternary": $guide_color_quaternary,
41
+ "light": $guide_color_light,
42
+ "dark": $guide_color_dark,
43
+ );
@@ -0,0 +1 @@
1
+ @forward "color";
@@ -1,39 +1,77 @@
1
- // Copyright 2024 Scape Agency BV
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
2
4
 
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
5
+ ////
6
+ ///
7
+ /// Device Mixins Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Device
11
+ /// @author Scape Agency
12
+ /// @link https://unit.gl
13
+ /// @since 0.1.0 initial release
14
+ /// @todo None
15
+ /// @access public
16
+ ///
17
+ ////
6
18
 
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
19
 
20
+ // ============================================================================
21
+ // Use
22
+ // ============================================================================
15
23
 
16
24
  @use "../variables" as *;
17
25
 
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
26
+
27
+ // ============================================================================
28
+ // Mixins
29
+ // ============================================================================
30
+
31
+
32
+ ///
33
+ /// Creates a media query based on device attributes defined in the `$devices`
34
+ /// map. The media query supports min-width, max-width, and pixel-ratio.
35
+ ///
36
+ /// @name device_media_query
37
+ /// @param {String} $device - The key name of the device in the $devices map.
38
+ /// @content Styles to be applied within the media query.
39
+ ///
40
+ /// @example scss - Usage
41
+ /// @include device-media-query('iphone-6') {
42
+ /// // Styles specific to iPhone 6
43
+ /// }
44
+ ///
45
+ @mixin device_media_query($device) {
46
+ // Retrieve the device attributes from the $devices map
25
47
  $attributes: map-get($devices, $device);
26
-
48
+
49
+ // Validate that the device exists in the $devices map
50
+ @if $attributes == null {
51
+ @warn "Device `#{$device}` not found in $devices map.";
52
+ // @return;
53
+ }
54
+
27
55
  // 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
56
+ $min-width: map-get($attributes, "min-width");
57
+ $max-width: map-get($attributes, "max-width");
58
+ $pixel-ratio: map-get($attributes, "pixel-ratio", 1); // Default to 1
31
59
 
32
60
  // Construct the media query string
33
61
  $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);
62
+
63
+ @if $min-width != null {
64
+ $media-query: "#{$media-query} and (min-width: #{$min-width})";
65
+ }
66
+
67
+ @if $max-width != null {
68
+ $media-query: "#{$media-query} and (max-width: #{$max-width})";
69
+ }
70
+
71
+ @if $pixel-ratio != 1 {
72
+ $media-query: "#{$media-query} and (-webkit-device-pixel-ratio: #{$pixel-ratio})";
73
+ $media-query: "#{$media-query} and (min-resolution: #{($pixel-ratio * 96)}dpi)";
74
+ }
37
75
 
38
76
  // Apply the media query
39
77
  @media #{$media-query} {
@@ -1,34 +1,53 @@
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
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
6
4
 
7
- // http://www.apache.org/licenses/LICENSE-2.0
5
+ ////
6
+ ///
7
+ /// Display Mixins Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// These mixins provide a convenient way to apply styles based on device
11
+ /// orientation and display characteristics such as aspect ratio and pixel
12
+ /// density. They are essential for creating responsive designs that adapt
13
+ /// seamlessly to different device configurations, especially on mobile
14
+ /// devices.
15
+ ///
16
+ /// @group Display
17
+ /// @author Scape Agency
18
+ /// @link https://unit.gl
19
+ /// @since 0.1.0 initial release
20
+ /// @todo None
21
+ /// @access public
22
+ ///
23
+ ////
8
24
 
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
25
 
26
+ // ============================================================================
27
+ // Use
28
+ // ============================================================================
15
29
 
16
30
  @use "../variables" as *;
17
31
 
18
32
 
19
-
20
-
21
- // Mixins for Media Queries Based on Device Orientation
22
33
  // ============================================================================
23
- // These mixins provide a convenient way to apply styles based on the orientation of the device.
24
- // Useful for responsive designs that need to adapt to landscape or portrait modes, especially on tablets and smartphones.
34
+ // Mixins
35
+ // ============================================================================
25
36
 
26
- /// Mixin for landscape orientation with optional breakpoint
27
- /// Use this mixin to apply styles when the device is in landscape mode.
28
- /// @param $min-width (optional) - The minimum width at which the styles should apply
29
- /// Example usage:
30
- /// @include orientation-landscape(1024px) { /* styles */ }
31
- @mixin orientation-landscape($min-width: null) {
37
+
38
+ ///
39
+ /// Applies styles when the device is in landscape mode. An optional
40
+ /// minimum width can be specified to target specific breakpoints.
41
+ ///
42
+ /// @name display-orientation-landscape
43
+ /// @param {Length} $min-width (optional) - The minimum width at which the styles should apply.
44
+ ///
45
+ /// @example scss - Usage
46
+ /// @include display-orientation-landscape(1024px) {
47
+ /// // Styles for landscape orientation and min-width 1024px
48
+ /// }
49
+ ///
50
+ @mixin display_orientation_landscape($min-width: null) {
32
51
  @if $min-width {
33
52
  @media (orientation: landscape) and (min-width: $min-width) {
34
53
  @content;
@@ -40,12 +59,23 @@
40
59
  }
41
60
  }
42
61
 
62
+
63
+ ///
43
64
  /// Mixin for portrait orientation with optional breakpoint
44
- /// Use this mixin to apply styles when the device is in portrait mode.
45
- /// @param $min-width (optional) - The minimum width at which the styles should apply
46
- /// Example usage:
47
- /// @include orientation-portrait { /* styles */ }
48
- @mixin orientation-portrait($min-width: null) {
65
+ /// ---------------------------------------------------------------------------
66
+ ///
67
+ /// Applies styles when the device is in portrait mode. An optional
68
+ /// minimum width can be specified to target specific breakpoints.
69
+ ///
70
+ /// @name display-orientation-portrait
71
+ /// @param {Length} $min-width (optional) - The minimum width at which the styles should apply.
72
+ ///
73
+ /// @example scss - Usage
74
+ /// @include display-orientation-portrait(768px) {
75
+ /// // Styles for portrait orientation and min-width 768px
76
+ /// }
77
+ ///
78
+ @mixin display_orientation_portrait($min-width: null) {
49
79
  @if $min-width {
50
80
  @media (orientation: portrait) and (min-width: $min-width) {
51
81
  @content;
@@ -58,26 +88,58 @@
58
88
  }
59
89
 
60
90
 
61
-
91
+ ///
62
92
  /// Mixin for targeting specific aspect ratios
63
- /// @param $width - Width of the aspect ratio
64
- /// @param $height - Height of the aspect ratio
65
- // @mixin aspect-ratio($width, $height) {
66
- // @media (aspect-ratio: #{$width}/#{$height}) {
67
- // @content;
68
- // }
69
- // }
70
-
71
-
93
+ /// ---------------------------------------------------------------------------
94
+ ///
95
+ /// Applies styles based on a specific aspect ratio. This mixin is
96
+ /// useful for targeting devices or elements that have a particular
97
+ /// aspect ratio, ensuring that your design adapts perfectly to
98
+ /// screens of varying shapes and sizes.
99
+ ///
100
+ /// @name aspect_ratio
101
+ /// @param {Number} $width - The width component of the aspect ratio.
102
+ /// @param {Number} $height - The height component of the aspect ratio.
103
+ ///
104
+ /// @example scss - Basic Usage
105
+ /// @include aspect_ratio(16, 9) {
106
+ /// // Styles for devices with a 16:9 aspect ratio
107
+ /// .video {
108
+ /// max-width: 100%;
109
+ /// }
110
+ /// }
111
+ ///
112
+ /// @example scss - Complex Usage
113
+ /// // Apply styles for both 16:9 and 4:3 aspect ratios
114
+ /// @include aspect_ratio(16, 9), aspect_ratio(4, 3) {
115
+ /// // Styles for devices with either a 16:9 or 4:3 aspect ratio
116
+ /// .content {
117
+ /// padding: 20px;
118
+ /// }
119
+ /// }
120
+ ///
121
+ @mixin aspect_ratio($width, $height) {
122
+ @media (aspect-ratio: #{$width} / #{$height}) {
123
+ @content;
124
+ }
125
+ }
72
126
 
73
127
 
74
- // Mixin for High-Density (Retina) Displays
75
- // ============================================================================
76
- /// This mixin targets high-density displays like Retina screens.
77
- /// It covers various methods to detect high pixel density to ensure broad compatibility.
78
- /// Usage:
79
- /// @include retina { /* styles for retina displays */ }
80
- @mixin retina {
128
+ ///
129
+ /// Mixin for High-Density (Retina) Displays
130
+ /// ---------------------------------------------------------------------------
131
+ ///
132
+ /// Targets high-density displays, such as Retina screens, using various
133
+ /// methods to ensure broad compatibility across devices.
134
+ ///
135
+ /// @name display_retina
136
+ ///
137
+ /// @example scss - Usage
138
+ /// @include display-retina {
139
+ /// // Styles for high-density displays
140
+ /// }
141
+ ///
142
+ @mixin display_retina {
81
143
  // Webkit-based browsers
82
144
  @media only screen and (-webkit-min-device-pixel-ratio: 2),
83
145
  // Standard way to target high-resolution displays