unit.gl 0.1.3 → 0.1.9

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 (71) hide show
  1. package/css/unit.gl.css +253 -122
  2. package/css/unit.gl.min.css +1 -1
  3. package/js/grids.js +59 -0
  4. package/js/grids.js.map +1 -0
  5. package/js/unit.gl.js +10 -0
  6. package/js/unit.gl.js.map +1 -0
  7. package/package.json +1 -1
  8. package/scss/_reset.scss +15 -1
  9. package/scss/classes/_guide.scss +56 -54
  10. package/scss/classes/_index.scss +1 -5
  11. package/scss/classes/_ratio.scss +56 -6
  12. package/scss/dev/_banner.scss +0 -4
  13. package/scss/functions/_color.scss +1 -5
  14. package/scss/functions/_index.scss +0 -4
  15. package/scss/functions/_layer.scss +3 -6
  16. package/scss/functions/_ratio.scss +2 -5
  17. package/scss/functions/_scale.scss +8 -14
  18. package/scss/functions/_sequence.scss +0 -5
  19. package/scss/functions/_view.scss +0 -4
  20. package/scss/functions/math/_arithmetic.scss +12 -10
  21. package/scss/functions/math/_index.scss +0 -4
  22. package/scss/functions/unit/_index.scss +0 -4
  23. package/scss/functions/unit/_unit_conversion.scss +6 -30
  24. package/scss/functions/unit/_unit_functions.scss +2 -16
  25. package/scss/index.scss +12 -1
  26. package/scss/maps/_color.scss +1 -5
  27. package/scss/{variables → maps}/_device.scss +78 -73
  28. package/scss/maps/_index.scss +36 -5
  29. package/scss/{variables/_ratio.scss → maps/_interval.scss} +1 -6
  30. package/scss/{variables → maps}/_layer.scss +24 -20
  31. package/scss/{variables → maps}/_paper.scss +613 -414
  32. package/scss/maps/_ratio.scss +76 -0
  33. package/scss/maps/_scale.scss +82 -0
  34. package/scss/mixins/_device.scss +11 -8
  35. package/scss/mixins/_display.scss +35 -72
  36. package/scss/mixins/_guide.scss +151 -43
  37. package/scss/mixins/_helper.scss +2 -6
  38. package/scss/mixins/_index.scss +0 -4
  39. package/scss/mixins/_paper.scss +3 -7
  40. package/scss/mixins/_ratio.scss +79 -238
  41. package/scss/mixins/_unit.scss +1 -10
  42. package/scss/mixins/_view.scss +1 -5
  43. package/scss/tags/_index.scss +0 -4
  44. package/scss/tags/_unit.scss +0 -4
  45. package/scss/test.scss +0 -0
  46. package/scss/variables/_color.scss +7 -7
  47. package/scss/variables/_guide.scss +0 -0
  48. package/scss/variables/_index.scss +6 -40
  49. package/scss/variables/_scale.scss +4 -89
  50. package/scss/variables/_unit.scss +2 -5
  51. package/scss/variables/_view.scss +2 -7
  52. package/ts/grids.ts +92 -0
  53. package/ts/index.ts +19 -1
  54. package/scss/classes/_guides.scss +0 -141
  55. package/ts/AspectRatio.ts +0 -50
  56. package/ts/Border.ts +0 -60
  57. package/ts/BoxModel.ts +0 -68
  58. package/ts/FlexContainer.ts +0 -75
  59. package/ts/Grid.ts +0 -46
  60. package/ts/GridContainer.ts +0 -59
  61. package/ts/Layout.ts +0 -64
  62. package/ts/Position.ts +0 -53
  63. package/ts/Rectangle.ts +0 -51
  64. package/ts/ResponsiveImage.ts +0 -47
  65. package/ts/ResponsiveScale.ts +0 -44
  66. package/ts/Size.ts +0 -54
  67. package/ts/Spacing.ts +0 -106
  68. package/ts/Transform.ts +0 -71
  69. package/ts/Typography.ts +0 -75
  70. package/ts/Unit.ts +0 -81
  71. package/ts/Viewport.ts +0 -52
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Guide Class Module
@@ -42,9 +38,6 @@
42
38
  .guide {
43
39
  @include guide;
44
40
  }
45
- .guide_overlay {
46
- @include guide;
47
- }
48
41
 
49
42
  ///
50
43
  /// Applies a grid overlay with a customizable grid size and color.
@@ -55,7 +48,10 @@
55
48
  /// <div class="guide_graph"></div>
56
49
  ///
57
50
  .guide_graph {
58
- @include guide_graph($rhythm_base); // Default size, customize as needed
51
+ @include guide_graph;
52
+ }
53
+ .guide_graph_centered {
54
+ @include guide_graph_centered;
59
55
  }
60
56
 
61
57
  ///
@@ -67,55 +63,61 @@
67
63
  /// <div class="guide_baseline"></div>
68
64
  ///
69
65
  .guide_baseline {
70
- @include guide_baseline(
71
- $line_height_base
72
- ); // Default size, customize as needed
66
+ @include guide_baseline; // Default size, customize as needed
73
67
  }
74
68
 
75
- ///
76
- /// Applies a full baseline grid with both vertical and horizontal lines.
77
- ///
78
- /// @name baseline_grid
79
- ///
80
- /// @example HTML
81
- /// <div class="baseline-grid"></div>
82
- ///
83
- .baseline_grid {
84
- @include baseline_grid(60px, 24px); // Default sizes, customize as needed
69
+ html,
70
+ body {
71
+ height: 100%;
85
72
  }
73
+ // #baseline-guide {
74
+ // @include guide_baseline; // uses default size & color
75
+ // }
86
76
 
87
- ///
88
- /// Creates a centered guide box for alignment checks.
89
- ///
90
- /// @name guide_centered
91
- ///
92
- /// @example HTML
93
- /// <div class="guide_centered"></div>
94
- ///
95
- .guide_centered {
96
- @include guide_centered(200px, 200px); // Default size, customize as needed
97
- }
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
+ // }
98
88
 
99
- ///
100
- /// Visualizes the margin area around content.
101
- ///
102
- /// @name guide_margin
103
- ///
104
- /// @example HTML
105
- /// <div class="guide_margin"></div>
106
- ///
107
- .guide_margin {
108
- @include guide_margin(20px); // Default margin size, customize as needed
109
- }
89
+ // ///
90
+ // /// Creates a centered guide box for alignment checks.
91
+ // ///
92
+ // /// @name guide_centered
93
+ // ///
94
+ // /// @example HTML
95
+ // /// <div class="guide_centered"></div>
96
+ // ///
97
+ // .guide_centered {
98
+ // @include guide_centered(200px, 200px); // Default size, customize as needed
99
+ // }
110
100
 
111
- ///
112
- /// Visualizes a larger margin area around content.
113
- ///
114
- /// @name guide_margin)_wide
115
- ///
116
- /// @example HTML
117
- /// <div class="guide_margin_wide"></div>
118
- ///
119
- .guide_margin_wide {
120
- @include guide_margin(40px); // Wider margin size, customize as needed
121
- }
101
+ // ///
102
+ // /// Visualizes the margin area around content.
103
+ // ///
104
+ // /// @name guide_margin
105
+ // ///
106
+ // /// @example HTML
107
+ // /// <div class="guide_margin"></div>
108
+ // ///
109
+ // .guide_margin {
110
+ // @include guide_margin(20px); // Default margin size, customize as needed
111
+ // }
112
+
113
+ // ///
114
+ // /// Visualizes a larger margin area around content.
115
+ // ///
116
+ // /// @name guide_margin)_wide
117
+ // ///
118
+ // /// @example HTML
119
+ // /// <div class="guide_margin_wide"></div>
120
+ // ///
121
+ // .guide_margin_wide {
122
+ // @include guide_margin(40px); // Wider margin size, customize as needed
123
+ // }
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Class Module
@@ -26,4 +22,4 @@
26
22
 
27
23
  /// Forwarding modules for global access
28
24
  @forward "ratio";
29
- // @forward "guide";
25
+ @forward "guide";
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Ratio Class Module
@@ -20,9 +16,63 @@
20
16
  // Use
21
17
  // ============================================================================
22
18
 
23
- @use "../variables" as *;
24
- @use "../mixins" as *;
19
+ @use "sass:list";
20
+ @use "sass:map";
21
+
22
+ @use "../variables" as vars;
23
+ @use "../maps" as maps;
24
+ @use "../mixins" as mixins;
25
25
 
26
26
  // ============================================================================
27
27
  // Classes
28
28
  // ============================================================================
29
+
30
+ // ============================================================================
31
+ // Utility Classes (declarative usage)
32
+ // ============================================================================
33
+
34
+ @each $name, $ratio in maps.$ratio_map {
35
+ .ratio_#{$name} {
36
+ @include mixins.aspect_ratio(list.nth($ratio, 1), list.nth($ratio, 2));
37
+ }
38
+ }
39
+
40
+ // .ratio_1x1 {
41
+ // @include aspect_ratio_1x1;
42
+ // }
43
+ // .ratio_1x2 {
44
+ // @include aspect_ratio_1x2;
45
+ // }
46
+ // .ratio_2x1 {
47
+ // @include aspect_ratio_2x1;
48
+ // }
49
+ // .ratio_1x3 {
50
+ // @include aspect_ratio_1x3;
51
+ // }
52
+ // .ratio_3x1 {
53
+ // @include aspect_ratio_3x1;
54
+ // }
55
+ // .ratio_1x4 {
56
+ // @include aspect_ratio_1x4;
57
+ // }
58
+ // .ratio_4x1 {
59
+ // @include aspect_ratio_4x1;
60
+ // }
61
+ // .ratio_3x2 {
62
+ // @include aspect_ratio_3x2;
63
+ // }
64
+ // .ratio_2x3 {
65
+ // @include aspect_ratio_2x3;
66
+ // }
67
+ // .ratio_4x3 {
68
+ // @include aspect_ratio_4x3;
69
+ // }
70
+ // .ratio_3x4 {
71
+ // @include aspect_ratio_3x4;
72
+ // }
73
+ // .ratio_16x9 {
74
+ // @include aspect_ratio_16x9;
75
+ // }
76
+ // .ratio_16x10 {
77
+ // @include aspect_ratio_16x10;
78
+ // }
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Dev Functions Module
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Color Variables Module
@@ -33,5 +29,5 @@
33
29
  /// ---------------------------------------------------------------------------
34
30
  ///
35
31
  @function guide_color($name) {
36
- @return map-get($guide_colors, $name);
32
+ @return map.get($guide_color_map, $name);
37
33
  }
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Functions Module
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Layer Functions Module
@@ -33,12 +29,13 @@
33
29
  ///
34
30
  /// @name z
35
31
  /// @param {String} $layer - The name of the layer to retrieve the z-index for.
36
- /// @return {Number | Null} - The z-index value associated with the layer, or null if not found.
32
+ /// @return {Number | Null} - The z-index value associated with the layer,
33
+ /// or null if not found.
37
34
  ///
38
35
  @function z($layer) {
39
36
  @if not map-has-key($layers, $layer) {
40
37
  @warn "Layer `#{$layer}` not found in the $layers map. z-index property omitted.";
41
38
  @return null;
42
39
  }
43
- @return map-get($layers, $layer);
40
+ @return map.get($layers, $layer);
44
41
  }
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Ratio Functions Module
@@ -38,7 +34,8 @@
38
34
  ///
39
35
  /// @name ratio_golden
40
36
  /// @param {Number} $size - The base size to scale.
41
- /// @param {Number} $increment - The exponent applied to the golden ratio, default is 1.
37
+ /// @param {Number} $increment - The exponent applied to the golden ratio,
38
+ /// default is 1.
42
39
  /// @return {Number} - The calculated size based on the golden ratio.
43
40
  ///
44
41
  /// @example scss - Usage Example
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Scale Functions Module
@@ -37,18 +33,16 @@
37
33
  /// scale. This helps maintain harmonious proportions across a design.
38
34
  ///
39
35
  /// @name modular_scale
40
- /// @param {Number} $increment - The step on the scale, can be positive or negative.
41
- /// @param {Number} $base - The base value to scale from, defaults to 1em (typographic base size).
42
- /// @param {Number} $ratio - The ratio to use for scaling, defaults to the Golden Ratio (1.618).
36
+ /// @param {Number} $increment - The step on the scale, can be positive or
37
+ /// negative.
38
+ /// @param {Number} $base - The base value to scale from, defaults to 1em
39
+ /// (typographic base size).
40
+ /// @param {Number} $ratio - The ratio to use for scaling, defaults to the
41
+ /// olden Ratio (1.618).
43
42
  /// @return {Number} - The calculated value based on the modular scale.
44
43
  ///
45
- @function modular_scale(
46
- $increment: 1,
47
- $base: 1em,
48
- $ratio: 1.618
49
- ) {
50
-
51
- // Validate inputs
44
+ @function modular_scale($increment: 1, $base: 1em, $ratio: 1.618) {
45
+ // Validate inputs
52
46
  @if type-of($increment) != "number" {
53
47
  @error "Step must be a number.";
54
48
  }
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Sequence Functions Module
@@ -277,7 +273,6 @@
277
273
  }
278
274
  @return 2 * $n * $n - $n;
279
275
  }
280
-
281
276
  ///
282
277
  /// Cube Number Sequence
283
278
  /// ---------------------------------------------------------------------------
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// View Functions Module
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Math Functions Module
@@ -43,9 +39,12 @@
43
39
  /// units, they must be the same unit; otherwise, a warning is issued and
44
40
  /// `null` is returned.
45
41
  ///
46
- /// @param {Number} $value1 - The first value, which may or may not include units.
47
- /// @param {Number} $value2 - The second value, which may or may not include units.
48
- /// @return {Number} - The sum of the two values, or null if the units are incompatible.
42
+ /// @param {Number} $value1 - The first value, which may or may not include
43
+ /// units.
44
+ /// @param {Number} $value2 - The second value, which may or may not include
45
+ /// units.
46
+ /// @return {Number} - The sum of the two values, or null if the units are
47
+ /// incompatible.
49
48
  ///
50
49
  @function add($value1, $value2) {
51
50
  @if unitless($value1) and unitless($value2) {
@@ -73,9 +72,12 @@
73
72
  /// units, they must be the same unit; otherwise, a warning is issued and
74
73
  /// `null` is returned.
75
74
  ///
76
- /// @param {Number} $value1 - The first value, which may or may not include units.
77
- /// @param {Number} $value2 - The second value, which may or may not include units.
78
- /// @return {Number} - The difference between the two values, or null if the units are incompatible.
75
+ /// @param {Number} $value1 - The first value, which may or may not include
76
+ /// units.
77
+ /// @param {Number} $value2 - The second value, which may or may not include
78
+ /// units.
79
+ /// @return {Number} - The difference between the two values, or null if the
80
+ /// units are incompatible.
79
81
  ///
80
82
  @function subtract($value1, $value2) {
81
83
  @if unitless($value1) and unitless($value2) {
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Math Functions Module
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Unit Functions Module
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Unit Functions Module
@@ -20,11 +16,9 @@
20
16
  // Use
21
17
  // ============================================================================
22
18
 
23
-
24
19
  /// Base font-size for the document
25
20
  $base-font-size: 16px !default;
26
21
 
27
-
28
22
  // ============================================================================
29
23
  // Functions
30
24
  // ============================================================================
@@ -34,31 +28,19 @@ $base-font-size: 16px !default;
34
28
  /// Create functions to convert between different measurement units, such as
35
29
  /// pixels to rem, em to pixels, etc.
36
30
 
37
- @function px_to_rem(
38
- $size,
39
- $base: 16px
40
- ) {
31
+ @function px_to_rem($size, $base: 16px) {
41
32
  @return $size / $base * 1rem;
42
33
  }
43
34
 
44
- @function rem_to_px(
45
- $size,
46
- $base: 16px
47
- ) {
35
+ @function rem_to_px($size, $base: 16px) {
48
36
  @return $size * $base;
49
37
  }
50
38
 
51
- @function em_to_px(
52
- $size,
53
- $context: 16px
54
- ) {
39
+ @function em_to_px($size, $context: 16px) {
55
40
  @return $size * $context;
56
41
  }
57
42
 
58
- @function px_to_em(
59
- $size,
60
- $context: 16px
61
- ) {
43
+ @function px_to_em($size, $context: 16px) {
62
44
  @return $size / $context * 1em;
63
45
  }
64
46
 
@@ -85,10 +67,7 @@ $base-font-size: 16px !default;
85
67
  }
86
68
 
87
69
  /// Convert em to pixels
88
- @function em_to_px(
89
- $size,
90
- $context: $base-font-size
91
- ) {
70
+ @function em_to_px($size, $context: $base-font-size) {
92
71
  $validated_context: validate_px($context);
93
72
  @if unit($size) != "em" {
94
73
  @error "Expected an em value, but got `#{$size}`.";
@@ -97,10 +76,7 @@ $base-font-size: 16px !default;
97
76
  }
98
77
 
99
78
  /// Convert pixels to em
100
- @function px_to_em(
101
- $size,
102
- $context: $base-font-size
103
- ) {
79
+ @function px_to_em($size, $context: $base-font-size) {
104
80
  $validated_size: validate_px($size);
105
81
  $validated_context: validate_px($context);
106
82
  @return $validated_size / $validated_context * 1em;
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Unit Functions Module
@@ -39,8 +35,7 @@
39
35
  ///
40
36
  @function unit_strip($value) {
41
37
  // Check if the input is a number with a unit
42
- @if meta.type-of($value)=="number" and not math.is-unitless($value) {
43
-
38
+ @if meta.type-of($value) == "number" and not math.is-unitless($value) {
44
39
  // Convert the value to a string
45
40
  // $value-str: inspect($value);
46
41
  $value-str: meta.inspect($value);
@@ -54,9 +49,7 @@
54
49
 
55
50
  // Return the number without its unit
56
51
  @return $value-no-unit;
57
-
58
52
  } @else if type-of($value) != "number" {
59
-
60
53
  // Handle non-number inputs gracefully
61
54
  // @warn "Input `#{$value}` is not a number. Returning value as-is.";
62
55
  @return $value;
@@ -80,14 +73,7 @@
80
73
  /// @param {Number} $actual - Current value to interpolate (default is 100vw).
81
74
  /// @return {Number} - Interpolated value (in the same units as $start and $end).
82
75
  ///
83
- @function linear_interpolation(
84
- $start,
85
- $end,
86
- $min,
87
- $max,
88
- $actual: 100vw
89
- ) {
90
-
76
+ @function linear_interpolation($start, $end, $min, $max, $actual: 100vw) {
91
77
  // Validate parameters
92
78
  @if unitless($min) == false and unit($min) != "px" {
93
79
  @error "Parameter `$min` must be unitless or in 'px'.";
package/scss/index.scss CHANGED
@@ -1,5 +1,16 @@
1
+ ////
2
+ ///
3
+ /// Unit.gl
4
+ /// ===========================================================================
5
+ ///
6
+ /// @author Scape Agency
7
+ /// @link https://unit.gl
8
+ /// @since 0.1.0 initial release
9
+ /// @todo None
10
+ /// @access public
11
+ ///
12
+ ////
1
13
  @charset "utf-8";
2
-
3
14
  @use "sass:math";
4
15
 
5
16
  @forward "reset";
@@ -1,7 +1,3 @@
1
- // ============================================================================
2
- // Poster
3
- // ============================================================================
4
-
5
1
  ////
6
2
  ///
7
3
  /// Color Maps Module
@@ -33,7 +29,7 @@
33
29
  /// Color Set for Easy Adjustments
34
30
  /// ---------------------------------------------------------------------------
35
31
  ///
36
- $guide_colors: (
32
+ $guide_color_map: (
37
33
  "primary": $guide_color_primary,
38
34
  "secondary": $guide_color_secondary,
39
35
  "tertiary": $guide_color_tertiary,