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.
- package/LICENSE +21 -201
- package/README.md +30 -74
- package/css/unit.gl.css +28 -65
- package/css/unit.gl.min.css +1 -1
- package/package.json +13 -8
- package/scss/_global.scss +5 -23
- package/scss/_reset.scss +13 -15
- package/scss/classes/_guide.scss +126 -0
- package/scss/classes/_index.scss +25 -11
- package/scss/classes/_ratio.scss +30 -0
- package/scss/dev/_banner.scss +30 -1
- package/scss/dev/_index.scss +0 -0
- package/scss/functions/_color.scss +40 -0
- package/scss/functions/_index.scss +39 -16
- package/scss/functions/_layer.scss +48 -0
- package/scss/functions/_ratio.scss +58 -157
- package/scss/functions/_scale.scss +55 -49
- package/scss/functions/_sequence.scss +154 -126
- package/scss/functions/_view.scss +40 -0
- package/scss/functions/math/_arithmetic.scss +102 -0
- package/scss/functions/math/_index.scss +30 -0
- package/scss/functions/unit/_index.scss +30 -0
- package/scss/functions/unit/_unit_conversion.scss +94 -0
- package/scss/functions/{_unit_functions.scss → unit/_unit_functions.scss} +70 -36
- package/scss/index.scss +2 -16
- package/scss/maps/_color.scss +43 -0
- package/scss/maps/_index.scss +1 -0
- package/scss/mixins/_device.scss +63 -25
- package/scss/mixins/_display.scss +106 -44
- package/scss/mixins/_guide.scss +191 -158
- package/scss/mixins/_helper.scss +287 -52
- package/scss/mixins/_index.scss +50 -17
- package/scss/mixins/_paper.scss +38 -17
- package/scss/mixins/_ratio.scss +30 -13
- package/scss/mixins/_unit.scss +94 -0
- package/scss/mixins/_view.scss +123 -44
- package/scss/tags/_index.scss +30 -0
- package/scss/tags/_unit.scss +40 -0
- package/scss/utilities/_guides.scss +103 -0
- package/scss/utilities/_index.scss +6 -0
- package/scss/variables/_color.scss +83 -0
- package/scss/variables/_device.scss +140 -50
- package/scss/variables/_index.scss +84 -16
- package/scss/variables/_layer.scss +148 -51
- package/scss/variables/_paper.scss +243 -17
- package/scss/variables/_ratio.scss +224 -0
- package/scss/variables/_scale.scss +230 -104
- package/scss/variables/_unit.scss +76 -72
- package/scss/variables/_view.scss +135 -39
- package/ts/AspectRatio.ts +29 -0
- package/ts/Border.ts +29 -0
- package/ts/BoxModel.ts +40 -0
- package/ts/FlexContainer.ts +48 -0
- package/ts/Grid.ts +21 -0
- package/ts/GridContainer.ts +33 -0
- package/ts/Layout.ts +34 -0
- package/ts/Position.ts +28 -0
- package/ts/Rectangle.ts +28 -0
- package/ts/ResponsiveImage.ts +28 -0
- package/ts/ResponsiveScale.ts +21 -0
- package/ts/Size.ts +32 -0
- package/ts/Spacing.ts +68 -0
- package/ts/Transform.ts +38 -0
- package/ts/Typography.ts +41 -0
- package/ts/Unit.ts +57 -0
- package/ts/Viewport.ts +24 -0
- package/js/index.d.ts +0 -1
- package/js/index.js +0 -3
- package/js/unit.gl.min.js +0 -1
- package/scss/classes/_paper.scss +0 -97
- package/scss/functions/_arithmetic.scss +0 -64
- package/scss/functions/_unit_conversion.scss +0 -77
package/scss/mixins/_guide.scss
CHANGED
|
@@ -1,44 +1,56 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
//
|
|
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
|
-
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// Guide Mixins Module
|
|
8
|
+
/// ===========================================================================
|
|
9
|
+
///
|
|
10
|
+
/// This module provides mixins for creating visual guides, such as grid
|
|
11
|
+
/// overlays and baseline grids, to assist in design alignment and consistency.
|
|
12
|
+
//
|
|
13
|
+
/// @group Guide
|
|
14
|
+
/// @author Scape Agency
|
|
15
|
+
/// @link https://unit.gl
|
|
16
|
+
/// @since 0.1.0 initial release
|
|
17
|
+
/// @todo None
|
|
18
|
+
/// @requires "../variables" - for accessing project-specific variables.
|
|
19
|
+
/// @access public
|
|
20
|
+
///
|
|
21
|
+
////
|
|
8
22
|
|
|
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
23
|
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Use
|
|
26
|
+
// ============================================================================
|
|
15
27
|
|
|
16
28
|
@use "../variables" as *;
|
|
17
29
|
|
|
30
|
+
|
|
18
31
|
// ============================================================================
|
|
19
|
-
//
|
|
32
|
+
// Mixins
|
|
20
33
|
// ============================================================================
|
|
21
34
|
|
|
22
|
-
$guide_color: rgba(50, 50, 50, 0.25);
|
|
23
|
-
$guide_color_2: rgba(178, 51, 170, 0.5);
|
|
24
35
|
|
|
36
|
+
///
|
|
37
|
+
/// Guide Mixin
|
|
38
|
+
/// ---------------------------------------------------------------------------
|
|
39
|
+
///
|
|
40
|
+
/// Creates a full-page guide overlay with a high z-index to ensure
|
|
41
|
+
/// visibility over other elements.
|
|
42
|
+
///
|
|
43
|
+
/// @name guide
|
|
44
|
+
///
|
|
45
|
+
/// @example scss - Usage
|
|
46
|
+
/// .guide {
|
|
47
|
+
/// @include guide;
|
|
48
|
+
/// }
|
|
49
|
+
///
|
|
25
50
|
@mixin guide {
|
|
26
51
|
z-index: z("guides");
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
width: 100%;
|
|
30
|
-
margin: 0;
|
|
31
|
-
top:0;
|
|
32
|
-
left:0;
|
|
33
|
-
opacity: 100%;
|
|
34
|
-
// background-size: $baseline_04 $baseline_04;
|
|
35
|
-
pointer-events: none;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Mixins for Guide Visualization
|
|
40
|
-
// @mixin guide($z-index: z('guides')) {
|
|
41
|
-
@mixin guide($z-index: 9999) {
|
|
52
|
+
// @mixin guide($z-index: 9999) {
|
|
53
|
+
// z-index: $z-index;
|
|
42
54
|
position: absolute;
|
|
43
55
|
top: 0;
|
|
44
56
|
left: 0;
|
|
@@ -46,151 +58,172 @@ $guide_color_2: rgba(178, 51, 170, 0.5);
|
|
|
46
58
|
height: 100%;
|
|
47
59
|
margin: 0;
|
|
48
60
|
pointer-events: none;
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
opacity: 100%;
|
|
62
|
+
// background-size: $baseline_04 $baseline_04;
|
|
63
|
+
}
|
|
51
64
|
|
|
52
|
-
.guide { @include guide; }
|
|
53
65
|
|
|
54
66
|
|
|
55
|
-
|
|
67
|
+
///
|
|
68
|
+
/// Guide Graph Mixin
|
|
69
|
+
/// ---------------------------------------------------------------------------
|
|
70
|
+
///
|
|
71
|
+
/// Generates a grid overlay with customizable grid size and color,
|
|
72
|
+
/// useful for ensuring consistent spacing and alignment in your designs.
|
|
73
|
+
///
|
|
74
|
+
/// @name guide_graph
|
|
75
|
+
/// @param {Length} $size - The size of the grid cells.
|
|
76
|
+
/// @param {Color} $color - The color of the grid lines. Defaults to `$guide_color`.
|
|
77
|
+
///
|
|
78
|
+
/// @example scss - Usage
|
|
79
|
+
/// .guide_graph {
|
|
80
|
+
/// @include guide_graph(10px, #ccc);
|
|
81
|
+
/// }
|
|
82
|
+
///
|
|
83
|
+
@mixin guide_graph(
|
|
84
|
+
$size,
|
|
85
|
+
$color: $guide_color,
|
|
86
|
+
) {
|
|
56
87
|
@include guide;
|
|
57
88
|
background-size: $size $size;
|
|
58
89
|
background-image: repeating-linear-gradient(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
to bottom,
|
|
91
|
+
$color 0 1px,
|
|
92
|
+
transparent 1px 100%
|
|
93
|
+
),
|
|
94
|
+
repeating-linear-gradient(
|
|
95
|
+
to right,
|
|
96
|
+
$color 0 1px,
|
|
97
|
+
transparent 1px 100%
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
///
|
|
103
|
+
/// Guide Baseline Mixin
|
|
104
|
+
/// ---------------------------------------------------------------------------
|
|
105
|
+
///
|
|
106
|
+
/// Creates a baseline grid overlay, essential for maintaining
|
|
107
|
+
/// a consistent vertical rhythm across your designs.
|
|
108
|
+
///
|
|
109
|
+
/// @name guide_baseline
|
|
110
|
+
/// @param {Length} $size - The height of the baseline grid.
|
|
111
|
+
/// @param {Color} $color - The color of the baseline lines. Defaults to cyan.
|
|
112
|
+
///
|
|
113
|
+
/// @example scss - Usage
|
|
114
|
+
/// .guide_baseline {
|
|
115
|
+
/// @include guide_baseline(20px, cyan);
|
|
116
|
+
/// }
|
|
117
|
+
///
|
|
118
|
+
@mixin guide_baseline(
|
|
119
|
+
$size,
|
|
120
|
+
$color: $guide_color,
|
|
121
|
+
) {
|
|
71
122
|
@include guide;
|
|
72
123
|
background-size: 100% $size;
|
|
73
124
|
background-image: repeating-linear-gradient(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// .guide_graph { @include guide_graph; }
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// @mixin guide_baseline {
|
|
84
|
-
// @include guide;
|
|
85
|
-
// // background: repeating-linear-gradient(#e66465, #e66465 20px, #9198e5 20px, #9198e5 25px);
|
|
86
|
-
// // background: repeating-linear-gradient(transparent, transparent 20px, transparent 20px, transparent 25px);
|
|
87
|
-
// // background-repeat: repeat-y;
|
|
88
|
-
// background-repeat: repeat;
|
|
89
|
-
|
|
90
|
-
// background-size: map-get($baseline, 4) map-get($baseline, 4);
|
|
91
|
-
// @include guide;
|
|
92
|
-
// background-image:
|
|
93
|
-
// repeating-linear-gradient(cyan 0 1px, transparent 1px 100%);
|
|
94
|
-
// }
|
|
125
|
+
to bottom,
|
|
126
|
+
$color 0 1px,
|
|
127
|
+
transparent 1px 100%
|
|
128
|
+
);
|
|
129
|
+
}
|
|
95
130
|
|
|
96
131
|
|
|
97
|
-
|
|
98
|
-
|
|
132
|
+
///
|
|
133
|
+
/// Baseline Grid Mixin
|
|
134
|
+
/// ---------------------------------------------------------------------------
|
|
135
|
+
///
|
|
136
|
+
/// Provides a customizable baseline grid overlay with both vertical
|
|
137
|
+
/// and horizontal grid lines, useful for designing layouts with consistent
|
|
138
|
+
/// column widths and baseline spacing.
|
|
139
|
+
///
|
|
140
|
+
/// @name guide_baseline
|
|
141
|
+
/// @param {Length} $column_width - The width of each column in the grid.
|
|
142
|
+
/// @param {Length} $baseline_height - The height of each baseline.
|
|
143
|
+
/// @param {Color} $column_color - The color of the column lines. Defaults to rgba(200, 0, 0, 0.2).
|
|
144
|
+
/// @param {Color} $baseline_color - The color of the baseline lines. Defaults to rgba(56, 255, 255, 0.8).
|
|
145
|
+
///
|
|
146
|
+
/// @example scss - Usage
|
|
147
|
+
/// .guide_baseline {
|
|
148
|
+
/// @include guide_baseline(60px, 20px);
|
|
149
|
+
/// }
|
|
150
|
+
///
|
|
151
|
+
@mixin guide_baseline(
|
|
152
|
+
$column_width,
|
|
153
|
+
$baseline_height,
|
|
154
|
+
$column_color: rgba(200, 0, 0, 0.2),
|
|
155
|
+
$baseline_color: $guide_color,
|
|
156
|
+
) {
|
|
99
157
|
background-image: linear-gradient(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
background-size: $
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
html {
|
|
114
|
-
// @include guide_graph(calc(16*$q));
|
|
115
|
-
// @include guide_baseline($line_height_base);
|
|
158
|
+
to right,
|
|
159
|
+
$column_color 0 $column_width,
|
|
160
|
+
transparent $column_width transparent
|
|
161
|
+
),
|
|
162
|
+
linear-gradient(
|
|
163
|
+
to bottom,
|
|
164
|
+
transparent calc(100% - 1px),
|
|
165
|
+
$baseline_color 100%
|
|
166
|
+
);
|
|
167
|
+
background-size: $column_width 100%, 100% $baseline_height;
|
|
116
168
|
}
|
|
117
169
|
|
|
118
|
-
.guide_graph {
|
|
119
|
-
@include guide_graph($rhythm_base);
|
|
120
170
|
|
|
171
|
+
///
|
|
172
|
+
/// Centered Guide Mixin
|
|
173
|
+
/// ---------------------------------------------------------------------------
|
|
174
|
+
///
|
|
175
|
+
/// Creates a centered guide box useful for ensuring elements are
|
|
176
|
+
/// aligned to the center of the viewport.
|
|
177
|
+
///
|
|
178
|
+
/// @name guide_centered
|
|
179
|
+
/// @param {Length} $width - The width of the centered guide box.
|
|
180
|
+
/// @param {Length} $height - The height of the centered guide box.
|
|
181
|
+
/// @param {Color} $color - The color of the guide box border. Defaults to red.
|
|
182
|
+
///
|
|
183
|
+
/// @example scss - Usage
|
|
184
|
+
/// .guide_centered {
|
|
185
|
+
/// @include guide_centered(100px, 100px, red);
|
|
186
|
+
/// }
|
|
187
|
+
///
|
|
188
|
+
@mixin guide_centered(
|
|
189
|
+
$width,
|
|
190
|
+
$height,
|
|
191
|
+
$color: red
|
|
192
|
+
) {
|
|
193
|
+
@include guide;
|
|
194
|
+
width: $width;
|
|
195
|
+
height: $height;
|
|
196
|
+
top: 50%;
|
|
197
|
+
left: 50%;
|
|
198
|
+
transform: translate(-50%, -50%);
|
|
199
|
+
border: 2px solid $color;
|
|
121
200
|
}
|
|
122
201
|
|
|
123
202
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
203
|
+
///
|
|
204
|
+
/// Margin Guide Mixin
|
|
205
|
+
/// ---------------------------------------------------------------------------
|
|
206
|
+
///
|
|
207
|
+
/// Visualizes the margins around content, helping to ensure
|
|
208
|
+
/// consistent spacing.
|
|
209
|
+
///
|
|
210
|
+
/// @name guide_margin
|
|
211
|
+
/// @param {Length} $margin - The size of the margin to visualize.
|
|
212
|
+
/// @param {Color} $color - The color of the margin area. Defaults to rgba(0, 255, 0, 0.1).
|
|
213
|
+
///
|
|
214
|
+
/// @example scss - Usage
|
|
215
|
+
/// .guide_margin {
|
|
216
|
+
/// @include guide_margin(20px, rgba(0, 255, 0, 0.1));
|
|
217
|
+
/// }
|
|
218
|
+
///
|
|
219
|
+
@mixin guide_margin(
|
|
220
|
+
$margin,
|
|
221
|
+
$color: rgba(0, 255, 0, 0.1)
|
|
222
|
+
) {
|
|
223
|
+
@include guide;
|
|
224
|
+
top: $margin;
|
|
225
|
+
left: $margin;
|
|
226
|
+
right: $margin;
|
|
227
|
+
bottom: $margin;
|
|
228
|
+
background-color: $color;
|
|
127
229
|
}
|
|
128
|
-
|
|
129
|
-
// .guide_baseline { @include guide_baseline; }
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// .baseline-grid {
|
|
133
|
-
// @include guide;
|
|
134
|
-
|
|
135
|
-
// background-image:
|
|
136
|
-
// // -webkit-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
|
|
137
|
-
// -webkit-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// background-image:
|
|
141
|
-
// // -moz-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
|
|
142
|
-
// -moz-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
|
|
143
|
-
// background-image:
|
|
144
|
-
// // -o-linear-gradient(0deg, rgba(200,0,0,.2) 40px, transparent 40px),
|
|
145
|
-
// -o-linear-gradient(top, rgba(0,0,0,0) 95%, rgba(56,255,255,.8) 100%);
|
|
146
|
-
|
|
147
|
-
// background-size: 100% 100%, 100% 100%;
|
|
148
|
-
// // background-size: 60px 100%, 100% 22px;
|
|
149
|
-
// // background-position: 10px 0px;
|
|
150
|
-
// }
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// // .guide_graph {
|
|
155
|
-
// // @include guide;
|
|
156
|
-
// // background-image:
|
|
157
|
-
// // repeating-linear-gradient(#ccc 0 1px, transparent 1px 100%),
|
|
158
|
-
// // repeating-linear-gradient(90deg, #ccc 0 1px, transparent 1px 100%);
|
|
159
|
-
// // }
|
|
160
|
-
|
|
161
|
-
// // .guide_baseline {
|
|
162
|
-
// // @include guide;
|
|
163
|
-
// // background-image:
|
|
164
|
-
// // repeating-linear-gradient(cyan 0 2px, transparent 2px 100%);
|
|
165
|
-
// // }
|
|
166
|
-
|
|
167
|
-
// .page {
|
|
168
|
-
// border: $q*2 solid red;
|
|
169
|
-
// }
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// $body-width: 960px;
|
|
173
|
-
// $baseline: 22px;
|
|
174
|
-
// @mixin baseline-grid {
|
|
175
|
-
// $columns: 16;
|
|
176
|
-
// $column-color: rgba(200,0,0,.2);
|
|
177
|
-
// $baseline-color: rgba(56,255,255,.8);
|
|
178
|
-
|
|
179
|
-
// // These are all automatically calculated
|
|
180
|
-
// $gutter-width: 20px; // Change if you like
|
|
181
|
-
// $gutters: ($columns - 1);
|
|
182
|
-
// $column-width: calc($body-width / $columns);
|
|
183
|
-
|
|
184
|
-
// background-image: -webkit-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
|
|
185
|
-
// -webkit-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
|
|
186
|
-
// background-image: -moz-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
|
|
187
|
-
// -moz-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
|
|
188
|
-
// background-image: -o-linear-gradient(0deg, $column-color $column-width, transparent $gutter-width),
|
|
189
|
-
// -o-linear-gradient(top, rgba(0,0,0,0) 95%, $baseline-color 100%);
|
|
190
|
-
// background-size: ($column-width + $gutter-width) 100%, 100% $baseline;
|
|
191
|
-
// background-position: 10px 0px; // Use to offset and center your grid
|
|
192
|
-
// }
|
|
193
|
-
|
|
194
|
-
// // Example call
|
|
195
|
-
// .baseline-grid {
|
|
196
|
-
// }
|