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
+ /// Device Mixins 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
+ @use "../variables" as *;
25
+ @use "../functions" as *;
26
+
27
+
28
+ // ============================================================================
29
+ // Mixins
30
+ // ============================================================================
31
+
32
+
33
+ ///
34
+ /// This mixin applies a CSS property with a value calculated in Kyū units.
35
+ ///
36
+ /// @name q
37
+ /// @param {Number} $multiplier - The multiplier to apply to the base Kyū unit.
38
+ /// @param {String} $property - The CSS property to which the calculated value is applied.
39
+ ///
40
+ /// @example scss - Usage
41
+ /// .element {
42
+ /// @include q(4, 'padding'); // Applies padding using 4 times the base Kyū unit
43
+ /// }
44
+ ///
45
+ @mixin q($multiplier, $property) {
46
+ #{$property}: q($multiplier);
47
+ }
48
+
49
+
50
+ ///
51
+ /// A mixin for fluid typography that scales font sizes between a specified
52
+ /// minimum and maximum viewport width, ensuring a smooth transition.
53
+ ///
54
+ /// @name fluid_type
55
+ /// @param {Length} $min_vw - The minimum viewport width where the fluid scaling starts.
56
+ /// @param {Length} $max_vw - The maximum viewport width where the fluid scaling ends.
57
+ /// @param {Length} $min_font_size - The minimum font size for the smallest viewport.
58
+ /// @param {Length} $max_font_size - The maximum font size for the largest viewport.
59
+ ///
60
+ /// @example scss - Usage
61
+ /// html {
62
+ /// @include fluid_type(320px, 1440px, 1rem, 2rem);
63
+ /// }
64
+ ///
65
+ @mixin fluid_type(
66
+ $min_vw,
67
+ $max_vw,
68
+ $min_font_size,
69
+ $max_font_size
70
+ ) {
71
+
72
+ $u1: unit($min_vw);
73
+ $u2: unit($max_vw);
74
+ $u3: unit($min_font_size);
75
+ $u4: unit($max_font_size);
76
+
77
+ @if $u1 == $u2 and $u1 == $u3 and $u1 == $u4 {
78
+ & {
79
+ font-size: $min_font_size;
80
+
81
+ @media screen and (min-width: $min_vw) {
82
+ font-size: calc(
83
+ #{$min_font_size} + #{unit_strip($max_font_size - $min_font_size)} * ((100vw - #{$min_vw}) / #{unit_strip($max_vw - $min_vw)})
84
+ );
85
+ }
86
+
87
+ @media screen and (min-width: $max_vw) {
88
+ font-size: $max_font_size;
89
+ }
90
+ }
91
+ } @else {
92
+ @warn "Units do not match across all parameters in fluid_type mixin.";
93
+ }
94
+ }
@@ -1,27 +1,52 @@
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
+ /// View Mixins Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// This module provides a set of mixins for applying media queries based on
11
+ /// predefined breakpoints. These mixins allow for a clean, semantic way to
12
+ /// handle responsive design across different screen sizes.
13
+ ///
14
+ /// @group View
15
+ /// @author Scape Agency
16
+ /// @link https://unit.gl
17
+ /// @since 0.1.0 initial release
18
+ /// @todo None
19
+ /// @require "../variables" - for access to the $breakpoints map and related variables.
20
+ /// @access public
21
+ ///
22
+ ////
8
23
 
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
24
 
25
+ // ============================================================================
26
+ // Use
27
+ // ============================================================================
15
28
 
16
29
  @use "../variables" as *;
17
30
 
31
+
18
32
  // ============================================================================
19
- // Media | Screen
33
+ // Mixins
20
34
  // ============================================================================
21
35
 
22
- // Media Query Mixins
23
- // ============================================================================
24
36
 
37
+ ///
38
+ /// Applies styles for the specified breakpoint. If the breakpoint
39
+ /// is not found, a warning is issued.
40
+ ///
41
+ /// @name breakpoint
42
+ /// @param {String} $size - The name of the breakpoint as defined in the $breakpoints map.
43
+ /// @content
44
+ ///
45
+ /// @example scss - Usage
46
+ /// @include breakpoint(md) {
47
+ /// // Styles for medium screens and up
48
+ /// }
49
+ ///
25
50
  @mixin breakpoint($size) {
26
51
  @if map-has-key($breakpoints, $size) {
27
52
  @media (min-width: map-get($breakpoints, $size)) {
@@ -32,48 +57,102 @@
32
57
  }
33
58
  }
34
59
 
60
+
61
+ ///
62
+ /// Applies styles for extra-small devices and up (min-width: 320px).
63
+ ///
64
+ /// @name media_xs
65
+ /// @example scss - Usage
66
+ /// @include media_xs {
67
+ /// // Styles for extra-small devices and up
68
+ /// }
69
+ ///
35
70
  @mixin media_xs {
36
- @media (min-width: $media_xs) { @content; }
71
+ @media (min-width: $media_xs) {
72
+ @content;
73
+ }
37
74
  }
38
-
75
+
76
+
77
+ ///
78
+ /// Applies styles for small devices and up (min-width: 480px).
79
+ ///
80
+ /// @name media_sm
81
+ /// @example scss - Usage
82
+ /// @include media_sm {
83
+ /// // Styles for small devices and up
84
+ /// }
85
+ ///
39
86
  @mixin media_sm {
40
- @media (min-width: $media_sm) { @content; }
87
+ @media (min-width: $media_sm) {
88
+ @content;
89
+ }
41
90
  }
42
91
 
43
92
 
93
+ ///
94
+ /// Applies styles for medium devices and up (min-width: 768px).
95
+ ///
96
+ /// @name media_md
97
+ ///
98
+ /// @example scss - Usage
99
+ /// @include media_md {
100
+ /// // Styles for medium devices and up
101
+ /// }
102
+ ///
44
103
  @mixin media_md {
45
- @media (min-width: $media_md) { @content; }
104
+ @media (min-width: $media_md) {
105
+ @content;
106
+ }
46
107
  }
47
-
108
+
109
+
110
+ ///
111
+ /// Applies styles for large devices and up (min-width: 1024px).
112
+ ///
113
+ /// @name media_lg
114
+ ///
115
+ /// @example scss - Usage
116
+ /// @include media_lg {
117
+ /// // Styles for large devices and up
118
+ /// }
119
+ ///
48
120
  @mixin media_lg {
49
- @media (min-width: $media_lg) { @content; }
121
+ @media (min-width: $media_lg) {
122
+ @content;
123
+ }
50
124
  }
51
-
52
125
 
126
+
127
+ ///
128
+ /// Applies styles for extra-large devices and up (min-width: 1280px).
129
+ ///
130
+ /// @name media_xl
131
+ ///
132
+ /// @example scss - Usage
133
+ /// @include media_xl {
134
+ /// // Styles for extra-large devices and up
135
+ /// }
136
+ ///
53
137
  @mixin media_xl {
54
- @media (min-width: $media_xl) { @content; }
138
+ @media (min-width: $media_xl) {
139
+ @content;
140
+ }
55
141
  }
56
-
142
+
143
+
144
+ ///
145
+ /// Applies styles for super-large devices and up (min-width: 1440px).
146
+ ///
147
+ /// @name media_sl
148
+ ///
149
+ /// @example scss - Usage
150
+ /// @include media_sl {
151
+ /// // Styles for super-large devices and up
152
+ /// }
153
+ ///
57
154
  @mixin media_sl {
58
- @media (min-width: $media_sl) { @content; }
155
+ @media (min-width: $media_sl) {
156
+ @content;
157
+ }
59
158
  }
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
- // }
@@ -0,0 +1,30 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Tags Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Tags
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
+ // Forward
27
+ // ============================================================================
28
+
29
+ /// Forwarding modules for global access
30
+ @forward "unit";
@@ -0,0 +1,40 @@
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
+ // ============================================================================
31
+
32
+ // Example usage of fluid typography for the html element
33
+ html {
34
+ @include fluid_type(
35
+ $media_xs,
36
+ $media_sl,
37
+ $font_min,
38
+ $font_max
39
+ );
40
+ }
@@ -0,0 +1,103 @@
1
+ @use "../dev" as *;
2
+ @use "../variables" as *;
3
+ @use "../mixins" as *;
4
+
5
+
6
+ // ============================================================================
7
+ // Utilities | Guides
8
+ // ============================================================================
9
+
10
+
11
+ .guide { @include guide; }
12
+
13
+ @mixin guide_graph {
14
+ @include guide;
15
+ background-size: 4*$q 4*$q;
16
+ background-image:
17
+ repeating-linear-gradient(rgb(66, 61, 61) 0 1px, transparent 1px 100%),
18
+ repeating-linear-gradient(90deg,rgb(66, 61, 61) 0 1px, transparent 1px 100%);
19
+ }
20
+
21
+ .guide_graph { @include guide_graph; }
22
+
23
+ @mixin guide_baseline {
24
+ @include guide;
25
+ // background: repeating-linear-gradient(#e66465, #e66465 20px, #9198e5 20px, #9198e5 25px);
26
+ // background: repeating-linear-gradient(transparent, transparent 20px, transparent 20px, transparent 25px);
27
+ // background-repeat: repeat-y;
28
+ background-repeat: repeat;
29
+
30
+ background-size: map-get($baseline, 4) map-get($baseline, 4);
31
+ @include guide;
32
+ background-image:
33
+ repeating-linear-gradient(cyan 0 1px, transparent 1px 100%);
34
+ }
35
+
36
+ .guide_baseline { @include guide_baseline; }
37
+
38
+
39
+ .baseline-grid {
40
+ @include guide;
41
+
42
+ background-image:
43
+ // -webkit-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
44
+ -webkit-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
45
+
46
+
47
+ background-image:
48
+ // -moz-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
49
+ -moz-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
50
+ background-image:
51
+ // -o-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
52
+ -o-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
53
+
54
+ background-size: 100% 100%, 100% 100%;
55
+ // background-size: 60px 100%, 100% 22px;
56
+ // background-position: 10px 0px;
57
+ }
58
+
59
+
60
+
61
+ // .guide_graph {
62
+ // @include guide;
63
+ // background-image:
64
+ // repeating-linear-gradient(#ccc 0 1px, transparent 1px 100%),
65
+ // repeating-linear-gradient(90deg, #ccc 0 1px, transparent 1px 100%);
66
+ // }
67
+
68
+ // .guide_baseline {
69
+ // @include guide;
70
+ // background-image:
71
+ // repeating-linear-gradient(cyan 0 2px, transparent 2px 100%);
72
+ // }
73
+
74
+ .page {
75
+ border: $q*2 solid red;
76
+ }
77
+
78
+
79
+ $body-width: 960px;
80
+ $baseline: 22px;
81
+ @mixin baseline-grid {
82
+ $columns: 16;
83
+ $column-color: rgba(200,0,0,.2);
84
+ $baseline-color: rgba(56,255,255,.8);
85
+
86
+ // These are all automatically calculated
87
+ $gutter-width: 20px; // Change if you like
88
+ $gutters: ($columns - 1);
89
+ $column-width: calc($body-width / $columns);
90
+
91
+ background-image: -webkit-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
92
+ -webkit-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
93
+ background-image: -moz-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
94
+ -moz-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
95
+ background-image: -o-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
96
+ -o-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
97
+ background-size: ($column-width + $gutter-width) 100%, 100% $baseline;
98
+ background-position: 10px 0px; // Use to offset and center your grid
99
+ }
100
+
101
+ // Example call
102
+ .baseline-grid {
103
+ }
@@ -0,0 +1,6 @@
1
+ // ============================================================================
2
+ // Utilities | Main
3
+ // ============================================================================
4
+
5
+
6
+ // @forward "guides";
@@ -0,0 +1,83 @@
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
+ // Variables
31
+ // ============================================================================
32
+
33
+ $guide_color: rgba(50, 50, 50, 0.25);
34
+ $guide_color_2: rgba(178, 51, 170, 0.5);
35
+
36
+
37
+ ///
38
+ /// Primary Guide Color
39
+ /// ---------------------------------------------------------------------------
40
+ ///
41
+ /// Neutral gray for general guide overlays
42
+ ///
43
+ $guide_color_primary: rgba(50, 50, 50, 0.25);
44
+
45
+ ///
46
+ /// Secondary Guide Color
47
+ /// ---------------------------------------------------------------------------
48
+ ///
49
+ /// Highlight color for key guides or emphasis
50
+ ///
51
+ $guide_color_secondary: rgba(178, 51, 170, 0.5);
52
+
53
+ ///
54
+ /// Tertiary Guide Color (Extended)
55
+ /// ---------------------------------------------------------------------------
56
+ ///
57
+ /// A warm orange for alternate guide markings
58
+ ///
59
+ $guide_color_tertiary: rgba(255, 102, 0, 0.3);
60
+
61
+ ///
62
+ /// Quaternary Guide Color (Extended)
63
+ /// ---------------------------------------------------------------------------
64
+ ///
65
+ /// A cool blue for additional grid or alignment lines
66
+ ///
67
+ $guide_color_quaternary: rgba(0, 102, 255, 0.3);
68
+
69
+ ///
70
+ /// Light Guide Color (Extended)
71
+ /// ---------------------------------------------------------------------------
72
+ ///
73
+ /// Light color for subtle or background guides
74
+ ///
75
+ $guide_color_light: rgba(255, 255, 255, 0.2);
76
+
77
+ ///
78
+ /// Dark Guide Color (Extended)
79
+ /// ---------------------------------------------------------------------------
80
+ ///
81
+ /// Dark color for use on lighter backgrounds
82
+ ///
83
+ $guide_color_dark: rgba(0, 0, 0, 0.2);