unit.gl 0.0.34 → 0.0.38

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 +20 -70
  3. package/css/unit.gl.css +182 -341
  4. package/css/unit.gl.min.css +1 -1
  5. package/package.json +11 -5
  6. package/scss/_global.scss +5 -25
  7. package/scss/_reset.scss +13 -16
  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 +40 -0
  12. package/scss/dev/_index.scss +0 -0
  13. package/scss/functions/_color.scss +40 -0
  14. package/scss/functions/_index.scss +39 -14
  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/{variables → functions/unit}/_unit_functions.scss +70 -36
  25. package/scss/index.scss +5 -31
  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 +144 -57
  43. package/scss/variables/_index.scss +85 -18
  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 +231 -105
  48. package/scss/variables/_unit.scss +77 -59
  49. package/scss/variables/_view.scss +137 -33
  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/variables/_unit_conversion.scss +0 -77
@@ -0,0 +1,126 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Guide Class Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// This module creates utility classes for visual guides, such as grid
11
+ /// overlays and baseline grids, using predefined mixins. These classes can
12
+ /// be applied directly in your HTML for rapid prototyping or debugging.
13
+ ///
14
+ /// Dependencies:
15
+ /// - Mixins from the Guides module
16
+ ///
17
+ /// @group Guides
18
+ /// @author Scape Agency
19
+ /// @link https://unit.gl
20
+ /// @since 0.1.0 initial release
21
+ /// @todo None
22
+ /// @access public
23
+ ///
24
+ ////
25
+
26
+
27
+ // ============================================================================
28
+ // Use
29
+ // ============================================================================
30
+
31
+ @use "../variables" as *;
32
+ @use "../mixins" as *;
33
+
34
+
35
+ // ============================================================================
36
+ // Classes
37
+ // ============================================================================
38
+
39
+ ///
40
+ /// Applies a full-page guide overlay with a high z-index.
41
+ ///
42
+ /// @name guide_overlay
43
+ ///
44
+ .guide {
45
+ @include guide;
46
+ }
47
+ .guide_overlay {
48
+ @include guide;
49
+ }
50
+
51
+ ///
52
+ /// Applies a grid overlay with a customizable grid size and color.
53
+ ///
54
+ /// @name guide_graph
55
+ ///
56
+ /// @example HTML
57
+ /// <div class="guide_graph"></div>
58
+ ///
59
+ .guide_graph {
60
+ @include guide_graph($rhythm_base); // Default size, customize as needed
61
+ }
62
+
63
+
64
+ ///
65
+ /// Applies a baseline grid overlay to maintain vertical rhythm.
66
+ ///
67
+ /// @name guide_baseline
68
+ ///
69
+ /// @example HTML
70
+ /// <div class="guide_baseline"></div>
71
+ ///
72
+ .guide_baseline {
73
+ @include guide_baseline($line_height_base); // Default size, customize as needed
74
+ }
75
+
76
+
77
+ ///
78
+ /// Applies a full baseline grid with both vertical and horizontal lines.
79
+ ///
80
+ /// @name baseline_grid
81
+ ///
82
+ /// @example HTML
83
+ /// <div class="baseline-grid"></div>
84
+ ///
85
+ .baseline_grid {
86
+ @include baseline_grid(60px, 24px); // Default sizes, customize as needed
87
+ }
88
+
89
+
90
+ ///
91
+ /// Creates a centered guide box for alignment checks.
92
+ ///
93
+ /// @name guide_centered
94
+ ///
95
+ /// @example HTML
96
+ /// <div class="guide_centered"></div>
97
+ ///
98
+ .guide_centered {
99
+ @include guide_centered(200px, 200px); // Default size, customize as needed
100
+ }
101
+
102
+
103
+ ///
104
+ /// Visualizes the margin area around content.
105
+ ///
106
+ /// @name guide_margin
107
+ ///
108
+ /// @example HTML
109
+ /// <div class="guide_margin"></div>
110
+ ///
111
+ .guide_margin {
112
+ @include guide_margin(20px); // Default margin size, customize as needed
113
+ }
114
+
115
+
116
+ ///
117
+ /// Visualizes a larger margin area around content.
118
+ ///
119
+ /// @name guide_margin)_wide
120
+ ///
121
+ /// @example HTML
122
+ /// <div class="guide_margin_wide"></div>
123
+ ///
124
+ .guide_margin_wide {
125
+ @include guide_margin(40px); // Wider margin size, customize as needed
126
+ }
@@ -1,17 +1,31 @@
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
+ /// Class Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Classes
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
 
25
+ // ============================================================================
26
+ // Forward
27
+ // ============================================================================
16
28
 
17
- @forward "paper";
29
+ /// Forwarding modules for global access
30
+ @forward "ratio";
31
+ // @forward "guide";
@@ -0,0 +1,30 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Ratio Class Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Ratio
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
+ @use "../variables" as *;
25
+ @use "../mixins" as *;
26
+
27
+
28
+ // ============================================================================
29
+ // Classes
30
+ // ============================================================================
@@ -0,0 +1,40 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Dev Functions Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Dev
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
+ // Variables
27
+ // ============================================================================
28
+
29
+
30
+ /**
31
+ * unit.gl
32
+ *
33
+ * @description Dynamic Layout Engine
34
+ * @author Scape Agency (https://www.scape.agency)
35
+ * @version v1.0.0
36
+ * @copyright 2020-2024 Scape Agency (https://www.scape.agency)
37
+ * @website https://www.unit.gl/
38
+ * @repository https://github.com/scape-agency/unit.gl/
39
+ * @license Apache 2.0 License (https://github.com/scape-agency/unit.gl/blob/main/LICENSE)
40
+ */
File without changes
@@ -0,0 +1,40 @@
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
+ // Functions
31
+ // ============================================================================
32
+
33
+
34
+ ///
35
+ /// Function to Retrieve Guide Colors (Optional for Flexibility)
36
+ /// ---------------------------------------------------------------------------
37
+ ///
38
+ @function guide_color($name) {
39
+ @return map-get($guide_colors, $name);
40
+ }
@@ -1,20 +1,45 @@
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
+ /// Functions Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// This module serves as a central hub for all core SCSS functions used across
11
+ /// the project. By forwarding various function modules, it allows for
12
+ /// consistent access to utilities like mathematical operations, ratio
13
+ /// calculations, scaling utilities, sequence generation, and unit handling.
14
+ ///
15
+ /// Forwarded Modules:
16
+ /// - math: Core mathematical operations and utilities.
17
+ /// - ratio: Functions for handling and calculating various ratios.
18
+ /// - scale: Utilities for implementing modular scales in responsive design.
19
+ /// - sequence: Functions for generating and working with numeric sequences.
20
+ /// - unit: Functions for unit conversions and calculations.
21
+ ///
22
+ /// @group Functions
23
+ /// @author Scape Agency
24
+ /// @link https://unit.gl
25
+ /// @since 0.1.0 initial release
26
+ /// @todo None
27
+ /// @access public
28
+ ///
29
+ ////
6
30
 
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
31
 
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.
32
+ // ============================================================================
33
+ // Use
34
+ // ============================================================================
14
35
 
15
36
 
16
- @forward "ratio";
17
- @forward "arithmetic";
18
- @forward "scale";
19
- @forward "sequence";
37
+ // ============================================================================
38
+ // Forward
39
+ // ============================================================================
20
40
 
41
+ @forward "math"; // Core mathematical operations and utilities
42
+ @forward "ratio"; // Functions for handling and calculating ratios
43
+ @forward "scale"; // Scaling utilities for responsive design
44
+ @forward "sequence"; // Functions for numeric sequence generation
45
+ @forward "unit"; // Functions for unit conversion and calculations
@@ -0,0 +1,48 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Layer Functions Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Layer
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
+ /// Z-Index Layer Function
33
+ /// ---------------------------------------------------------------------------
34
+ ///
35
+ /// This function retrieves the z-index value from the $layers map based on
36
+ /// the provided layer name. If the layer is not found, a warning is issued.
37
+ ///
38
+ /// @name z
39
+ /// @param {String} $layer - The name of the layer to retrieve the z-index for.
40
+ /// @return {Number | Null} - The z-index value associated with the layer, or null if not found.
41
+ ///
42
+ @function z($layer) {
43
+ @if not map-has-key($layers, $layer) {
44
+ @warn "Layer `#{$layer}` not found in the $layers map. z-index property omitted.";
45
+ @return null;
46
+ }
47
+ @return map-get($layers, $layer);
48
+ }
@@ -1,172 +1,73 @@
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
  // ============================================================================
17
- // Math | Ratio's
2
+ // Poster
18
3
  // ============================================================================
19
4
 
5
+ ////
6
+ ///
7
+ /// Ratio Functions Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// This module provides functions for calculating sizes based on well-known
11
+ /// mathematical ratios, such as the golden ratio. These functions are useful
12
+ /// for maintaining harmonious proportions in design elements like spacing,
13
+ /// typography, and layout.
14
+ ///
15
+ /// @group Ratio
16
+ /// @author Scape Agency
17
+ /// @link https://unit.gl
18
+ /// @since 0.1.0 initial release
19
+ /// @todo None
20
+ /// @access public
21
+ ///
22
+ ////
20
23
 
21
24
 
25
+ // ============================================================================
26
+ // Use
27
+ // ============================================================================
22
28
 
23
- // Modular Scale Ratios Map
24
- // This map contains common ratios used in modular scale calculations.
25
- $ratio: (
26
-
27
- // Musical Minor Interval
28
- // ------------------------------------------------------------------------
29
- "minor_second": 1.067, // Minor second interval
30
- "minor_third": 1.2, // Minor third interval
31
- "minor_fourth": 1.334, // Minor fourth interval (also known as diminished fifth)
32
- "minor_fifth": 1.5, // Minor fifth interval
33
- "minor_sixth": 1.6, // Minor sixth interval
34
- "minor_seventh": 1.778, // Minor seventh interval
35
- "minor_octave": 2, // Minor octave interval
36
-
37
- // Musical Major Interval
38
- // ------------------------------------------------------------------------
39
- "major_second": 1.125, // Major second interval
40
- "major_third": 1.25, // Major third interval
41
- "major_fourth": 1.333, // Major fourth interval (perfect fourth)
42
- "major_fifth": 1.5, // Major fifth interval (perfect fifth)
43
- "major_sixth": 1.667, // Major sixth interval
44
- "major_seventh": 1.875, // Major seventh interval
45
- "major_octave": 2, // Major octave interval (perfect octave)
46
-
47
- // Musical Perfect Interval
48
- // ------------------------------------------------------------------------
49
- "perfect_unison": 1, // Perfect unison, the same note
50
- "perfect_second": 1.125, // Perfect second interval
51
- "perfect_third": 1.25, // Perfect third interval
52
- "perfect_fourth": 1.333, // Perfect fourth interval
53
- "perfect_fifth": 1.5, // Perfect fifth interval
54
- "perfect_sixth": 1.667, // Perfect sixth interval
55
- "perfect_seventh": 1.875, // Perfect seventh interval
56
- "perfect_octave": 2, // Perfect octave, double the frequency
57
- "perfect_ninth": 2.25, // Perfect ninth interval
58
- "perfect_tenth": 2.5, // Perfect tenth interval
59
- "perfect_eleventh": 2.667, // Perfect eleventh interval
60
- "perfect_twelfth": 3, // Perfect twelfth interval
61
- "perfect_thirteenth": 3.333, // Perfect thirteenth interval
62
- "perfect_fourteenth": 3.667, // Perfect fourteenth interval
63
- "perfect_fifteenth": 4, // Perfect fifteenth interval, double octave
64
- "double_octave": 4, // Twice the frequency of the perfect octave
65
- "triple_octave": 8, // Three times the frequency of the perfect octave
66
-
67
- // Musical Augmented Interval
68
- // ------------------------------------------------------------------------
69
- "augmented_unison": 1.059, // Slightly higher than perfect unison
70
- "augmented_second": 1.122, // Slightly higher than major second
71
- "augmented_third": 1.189, // Slightly higher than major third
72
- "augmented_fourth": 1.414, // Augmented fourth, also known as tritone
73
- "augmented_fifth": 1.587, // Slightly higher than perfect fifth
74
- "augmented_sixth": 1.682, // Slightly higher than major sixth
75
- "augmented_seventh": 1.782, // Slightly higher than major seventh
76
- "augmented_octave": 2.059, // Slightly higher than perfect octave
77
-
78
- // Musical Diminished Interval
79
- // ------------------------------------------------------------------------
80
- "diminished_unison": 0.943, // A diminished unison, slightly less than a perfect unison
81
- "diminished_second": 1.053, // Diminished second interval, slightly less than a minor second
82
- "diminished_third": 1.122, // Diminished third interval, slightly less than a minor third
83
- "diminished_fourth": 1.260, // Diminished fourth, slightly less than a perfect fourth
84
- "diminished_fifth": 1.414, // Tritone, halfway between a perfect fourth and perfect fifth
85
- "diminished_sixth": 1.587, // Diminished sixth interval, slightly less than a major sixth
86
- "diminished_seventh": 1.782, // Diminished seventh interval, slightly less than a major seventh
87
- "diminished_octave": 1.961, // A diminished octave, slightly less than a perfect octave
88
-
89
- // Root
90
- // ------------------------------------------------------------------------
91
- "root_two": 1.414, // Square root of 2
92
- "root_three": 1.732, // Square root of 3
93
- "root_four": 2, // Square root of 4
94
- "root_five": 2.236, // Square root of 5
95
-
96
- // Special
97
- // ------------------------------------------------------------------------
98
- "golden_ratio": 1.618,
99
- "silver_ratio": 2.414, // Analogous to the golden ratio
100
- "bronze_ratio": 1.927, // Analogous to silver and golden ratios
101
- "pythagorean": 1.732, // Pythagorean constant, square root of 3
102
- "phi": 1.618, // Another name for the golden ratio
103
- "pi": 3.142, // Mathematical Pi value
104
- "euler": 2.718, // Euler's number
105
- "square": 1.414, // Square root of 2
106
- "fibonacci": 1.618, // Fibonacci sequence ratio
107
- "plastic_number": 1.324, // Plastic constant, another unique irrational number
108
- "feigenbaum": 4.669, // Feigenbaum constant in chaos theory
109
- "apollonian": 1.306, // Apollonian gasket, related to circle packing
110
- "cosmic_ratio": 1.273, // Based on cosmic geometry
111
- "parthenon_ratio": 1.618, // Ratio used in the Parthenon's architecture
112
- "le_corbusier": 1.618, // Le Corbusier's modulor ratio
113
- "vesica_piscis": 1.732, // Ratio from the vesica piscis shape
114
- "egyptian_fraction": 1.571, // Ancient Egyptian architecture ratio
115
- "harmonic_mean": 1.455, // Harmonic mean, a type of average
116
- "gauss_constant": 0.834, // Gauss's constant related to the arithmetic-geometric mean
117
- "super_golden": 2.058, // Super golden ratio, a higher order of the golden ratio
118
29
 
119
- ) !default;
30
+ // ============================================================================
31
+ // Functions
32
+ // ============================================================================
120
33
 
121
34
 
35
+ ///
122
36
  /// Golden Ratio Function
123
- /// A simple function to calculate sizes using the golden ratio, which can be
124
- /// used for spacing, sizing elements, etc.
125
- @function golden-ratio($size, $increment: 1) {
37
+ /// ---------------------------------------------------------------------------
38
+ ///
39
+ /// Calculates a size using the golden ratio (approximately 1.618), which is
40
+ /// widely used in design for its aesthetically pleasing proportions.
41
+ ///
42
+ /// @name ratio_golden
43
+ /// @param {Number} $size - The base size to scale.
44
+ /// @param {Number} $increment - The exponent applied to the golden ratio, default is 1.
45
+ /// @return {Number} - The calculated size based on the golden ratio.
46
+ ///
47
+ /// @example scss - Usage Example
48
+ /// // Increase size using the golden ratio
49
+ /// .element {
50
+ /// width: golden_ratio(16px, 1); // Output: 25.888px
51
+ /// }
52
+ ///
53
+ /// // Decrease size using the golden ratio
54
+ /// .small-element {
55
+ /// width: golden_ratio(16px, -1); // Output: 9.888px
56
+ /// }
57
+ ///
58
+ @function ratio_golden($size, $increment: 1) {
126
59
  $golden-ratio: 1.618;
127
- @return $size * pow($golden-ratio, $increment);
128
- }
129
-
130
-
131
60
 
61
+ // Validate the input size
62
+ @if not unitless($size) and type-of($size) != 'number' {
63
+ @error "The size parameter must be a valid number or unitless value.";
64
+ }
132
65
 
133
- // Modular Scale Function
134
- /// Calculates sizes (like font-size, spacing) based on a modular scale.
135
- /// This is useful for maintaining harmonious proportions in typography and layout.
136
- /// @param $increment - The step on the scale, can be positive or negative.
137
- /// @param $base - The base value to scale from, defaults to 1em (typographic base size).
138
- /// @param $ratio - The ratio to use for scaling, defaults to the Golden Ratio.
139
- /// @return - The calculated value based on the modular scale.
140
- @function modular-scale($increment: 1, $base: 1em, $ratio: 1.618) {
141
- // Validate inputs
66
+ // Validate the increment
142
67
  @if type-of($increment) != 'number' {
143
- @error "Step must be a number.";
144
- }
145
-
146
- @if type-of($base) != 'number' and not unitless($base) {
147
- @error "Base must be a number with or without units.";
148
- }
149
-
150
- @if type-of($ratio) != 'number' or $ratio <= 0 {
151
- @error "Ratio must be a positive number.";
68
+ @error "The increment parameter must be a valid number.";
152
69
  }
153
-
154
- // Calculate the modular scale value
155
- @return $base * pow($ratio, $increment);
156
- }
157
-
158
- // $ratio: map-get($ratio, $ratio-name);
159
-
160
-
161
- // body {
162
- // font-size: modular-scale(0); // Equal to the base size, 1em
163
- // }
164
-
165
- // h1 {
166
- // font-size: modular-scale(2); // Larger than the base size
167
- // }
168
-
169
- // .small-text {
170
- // font-size: modular-scale(-1); // Smaller than the base size
171
- // }
172
-
70
+
71
+ // Return the size scaled by the golden ratio raised to the increment
72
+ @return $size * pow($golden-ratio, $increment);
73
+ }