unit.gl 0.1.13 → 0.3.1

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 (51) hide show
  1. package/README.md +329 -1
  2. package/css/unit.gl.css +35819 -6
  3. package/css/unit.gl.docs.css +4156 -0
  4. package/css/unit.gl.docs.min.css +2 -0
  5. package/css/unit.gl.min.css +1 -1
  6. package/js/unit.gl.demo.js +708 -0
  7. package/js/unit.gl.demo.js.map +1 -0
  8. package/js/unit.gl.js +25 -0
  9. package/js/unit.gl.js.map +1 -1
  10. package/package.json +16 -3
  11. package/scss/classes/_docs.scss +4690 -0
  12. package/scss/classes/_index.scss +1 -0
  13. package/scss/classes/_utilities.scss +1488 -0
  14. package/scss/docs.scss +11 -0
  15. package/scss/formats.scss +27 -0
  16. package/scss/functions/_density.scss +311 -0
  17. package/scss/functions/_index.scss +3 -0
  18. package/scss/functions/_layer.scss +14 -1
  19. package/scss/functions/_ratio.scss +3 -2
  20. package/scss/functions/_scale.scss +220 -3
  21. package/scss/functions/_sequence.scss +6 -5
  22. package/scss/functions/math/_arithmetic.scss +15 -12
  23. package/scss/functions/unit/_unit_conversion.scss +59 -7
  24. package/scss/functions/unit/_unit_functions.scss +3 -3
  25. package/scss/guide.scss +22 -0
  26. package/scss/maps/_density.scss +141 -0
  27. package/scss/maps/_device.scss +13 -20
  28. package/scss/maps/_index.scss +6 -0
  29. package/scss/maps/_scale.scss +47 -4
  30. package/scss/mixins/_device.scss +1 -3
  31. package/scss/mixins/_display.scss +265 -2
  32. package/scss/mixins/_format.scss +75 -0
  33. package/scss/mixins/_guide.scss +73 -11
  34. package/scss/mixins/_index.scss +2 -1
  35. package/scss/mixins/_unit.scss +115 -6
  36. package/scss/mixins/_utilities.scss +303 -0
  37. package/scss/mixins/_view.scss +43 -12
  38. package/scss/tags/_global.scss +18 -3
  39. package/scss/tags/_unit.scss +1 -3
  40. package/scss/test.scss +17 -0
  41. package/scss/utilities.scss +20 -0
  42. package/scss/variables/_color.scss +9 -9
  43. package/scss/variables/_format.scss +80 -0
  44. package/scss/variables/_guide.scss +17 -0
  45. package/scss/variables/_index.scss +4 -0
  46. package/scss/variables/_scale.scss +434 -63
  47. package/scss/variables/_view.scss +222 -64
  48. package/ts/demo.ts +889 -0
  49. package/ts/index.d.ts +72 -0
  50. package/ts/index.ts +45 -0
  51. package/scss/mixins/_paper.scss +0 -51
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <img src="https://raw.githubusercontent.com/stylescape/brand/master/src/logo/logo-transparant.png" width="20%" alt="Stylescape Logo">
3
3
  </p>
4
- <h1 align="center" style='border-bottom: none;'>unit.gl</h1>
4
+ <h1 align="center" style='border-bottom: none;'>qp</h1>
5
5
  <h3 align="center">Dynamic Layout Engine</h3>
6
6
 
7
7
  <br/>
@@ -33,6 +33,40 @@
33
33
 
34
34
  `unit.gl` is a comprehensive design toolkit focused on fluid typography, responsive design, and advanced SCSS functions. It's crafted to empower designers and developers to create harmonious, scalable, and accessible web experiences efficiently.
35
35
 
36
+ ---
37
+
38
+ ## Features
39
+
40
+ `unit.gl` provides a robust set of features for building dynamic, responsive layouts with precision and flexibility:
41
+
42
+ ### Core Layout System
43
+
44
+ - **Kyū Unit System** – A base-16 measurement system (`1q = 1/16rem = 1px`) for precise, consistent spacing and sizing across all screen sizes
45
+ - **Fluid Typography** – Dynamic font scaling with `fluid_type()` mixin that smoothly interpolates between min/max sizes across viewport breakpoints
46
+ - **Modular Scale** – Musical interval-based typographic scales (minor second, golden ratio, perfect fifth, etc.) for harmonious type hierarchies
47
+ - **Baseline Grid** – Visual rhythm system with configurable baseline increments for vertical alignment
48
+
49
+ ### Responsive Design Tools
50
+
51
+ - **Viewport Breakpoints** – Q format-derived breakpoint system (us, ss, xs, sm, md, lg, xl, ul) with `view()` mixin for mobile-first media queries
52
+ - **Device Profiles** – Pre-configured device-specific media queries for iPhone, iPad, Samsung Galaxy, and more
53
+ - **Aspect Ratio Utilities** – Maintain proportions with `display_ratio()` mixin supporting common ratios (16:9, 4:3, golden ratio)
54
+ - **Orientation Helpers** – Landscape/portrait-specific styling with `display_orientation_*` mixins
55
+
56
+ ### Advanced SCSS Functions
57
+
58
+ - **Unit Conversion** – Seamless conversion between px, rem, em with `px_to_rem()`, `rem_to_px()`, `em_to_px()` functions
59
+ - **Math Operations** – `add()`, `subtract()` with intelligent unit handling; `modular_scale()` for ratio-based scaling
60
+ - **Layer Management** – z-index token system via `$layers` map and `z()` function for consistent stacking order
61
+ - **Paper Sizes** – ISO (A-series, B-series), ANSI, and custom Q-series paper dimensions for print layouts
62
+
63
+ ### Developer Experience
64
+
65
+ - **Modern Sass** – Uses `sass:math`, `sass:map`, `sass:color` modules; no deprecated syntax
66
+ - **TypeScript Support** – Grid utilities and layout helpers with full type definitions
67
+ - **Visual Guides** – Built-in overlay system for baseline grids, margins, and alignment verification during development
68
+ - **Customizable Variables** – Override defaults for base units, breakpoints, scales, and colors via Sass variables
69
+
36
70
  ## Installation
37
71
 
38
72
  ### HTML Script Tag
@@ -49,6 +83,300 @@ npm i unit.gl
49
83
 
50
84
  ---
51
85
 
86
+ ## Quick Start
87
+
88
+ ### Basic Usage (SCSS)
89
+
90
+ Import `unit.gl` into your Sass/SCSS files:
91
+
92
+ ```scss
93
+ @use "unit.gl" as *;
94
+
95
+ // Use the Kyū unit system
96
+ .container {
97
+ padding: q(4); // 4q = 4 × (1/16rem) = 0.25rem = 4px
98
+ margin-bottom: q(8); // 8q = 0.5rem = 8px
99
+ }
100
+
101
+ // Apply fluid typography
102
+ .heading {
103
+ @include fluid_type(
104
+ $min-size: 16px,
105
+ $max-size: 48px,
106
+ $min-vw: 320px,
107
+ $max-vw: 1280px
108
+ );
109
+ }
110
+
111
+ // Responsive breakpoints
112
+ .grid {
113
+ display: grid;
114
+ grid-template-columns: 1fr;
115
+ gap: q(4);
116
+
117
+ @include view(md) {
118
+ grid-template-columns: repeat(2, 1fr);
119
+ }
120
+
121
+ @include view(lg) {
122
+ grid-template-columns: repeat(3, 1fr);
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### Common Layout Patterns
128
+
129
+ #### Fluid Card Grid with Consistent Spacing
130
+
131
+ ```scss
132
+ @use "unit.gl" as *;
133
+
134
+ .card-grid {
135
+ display: grid;
136
+ gap: q(8); // 0.5rem spacing
137
+ padding: q(8);
138
+
139
+ // Mobile: 1 column
140
+ grid-template-columns: 1fr;
141
+
142
+ // Tablet: 2 columns
143
+ @include view(sm) {
144
+ grid-template-columns: repeat(2, 1fr);
145
+ gap: q(12); // 0.75rem
146
+ }
147
+
148
+ // Desktop: 3 columns
149
+ @include view(md) {
150
+ grid-template-columns: repeat(3, 1fr);
151
+ gap: q(16); // 1rem
152
+ }
153
+ }
154
+
155
+ .card {
156
+ padding: q(12);
157
+ border-radius: q(2);
158
+ background: #fff;
159
+ box-shadow: 0 q(1) q(4) rgba(0, 0, 0, 0.1);
160
+ }
161
+ ```
162
+
163
+ #### Typography Scale with Modular Rhythm
164
+
165
+ ```scss
166
+ @use "unit.gl" as *;
167
+
168
+ // Use golden ratio (1.618) for harmonious type scale
169
+ $scale-ratio: map.get($ratio_map, golden);
170
+
171
+ h1 {
172
+ font-size: modular_scale(4, 1rem, $scale-ratio); // ~6.85rem
173
+ line-height: baseline(6); // 6 baseline units
174
+ margin-bottom: baseline(2);
175
+ }
176
+
177
+ h2 {
178
+ font-size: modular_scale(3, 1rem, $scale-ratio); // ~4.236rem
179
+ line-height: baseline(5);
180
+ margin-bottom: baseline(2);
181
+ }
182
+
183
+ h3 {
184
+ font-size: modular_scale(2, 1rem, $scale-ratio); // ~2.618rem
185
+ line-height: baseline(4);
186
+ margin-bottom: baseline(1);
187
+ }
188
+
189
+ p {
190
+ font-size: modular_scale(0, 1rem, $scale-ratio); // 1rem
191
+ line-height: baseline(3); // Vertical rhythm
192
+ margin-bottom: baseline(2);
193
+ }
194
+ ```
195
+
196
+ #### Aspect Ratio Container (e.g., Video Embed)
197
+
198
+ ```scss
199
+ @use "unit.gl" as *;
200
+
201
+ .video-wrapper {
202
+ width: 100%;
203
+ max-width: 800px;
204
+ margin: 0 auto;
205
+
206
+ // Maintain 16:9 aspect ratio
207
+ @include display_ratio(16, 9);
208
+
209
+ iframe {
210
+ position: absolute;
211
+ top: 0;
212
+ left: 0;
213
+ width: 100%;
214
+ height: 100%;
215
+ }
216
+ }
217
+ ```
218
+
219
+ #### Device-Specific Styling
220
+
221
+ ```scss
222
+ @use "unit.gl" as *;
223
+
224
+ .app-header {
225
+ height: q(80); // 5rem = 80px
226
+
227
+ // iPhone-specific adjustments
228
+ @include device-media-query('iphone_x') {
229
+ padding-top: env(safe-area-inset-top); // Notch support
230
+ }
231
+
232
+ // Tablet landscape
233
+ @include display_orientation_landscape {
234
+ @include view(sm) {
235
+ height: q(64); // Shorter header in landscape
236
+ }
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### TypeScript Integration
242
+
243
+ ```typescript
244
+ import { GridManager } from 'unit.gl';
245
+
246
+ // Initialize grid overlay for development
247
+ const grid = new GridManager({
248
+ columns: 12,
249
+ gutter: 16, // 16px gutter
250
+ baseline: 8, // 8px baseline grid
251
+ color: 'rgba(255, 0, 0, 0.1)'
252
+ });
253
+
254
+ // Toggle grid visibility
255
+ grid.toggle();
256
+
257
+ // Update grid configuration
258
+ grid.updateConfig({ columns: 16 });
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Usage Guidelines & Best Practices
264
+
265
+ ### Performance Optimization
266
+
267
+ 1. **Minimize Media Query Complexity**
268
+ - Use the `view()` mixin for standard breakpoints instead of custom media queries
269
+ - Consolidate similar breakpoint rules to reduce CSS output
270
+
271
+ 2. **Leverage Sass Variables**
272
+ - Override defaults at the top of your main stylesheet:
273
+ ```scss
274
+ @use "unit.gl" with (
275
+ $q: 0.0625rem, // Customize base unit if needed
276
+ $base_screen_unit: 16px // Adjust breakpoint base
277
+ );
278
+ ```
279
+
280
+ 3. **Selective Imports**
281
+ - Import only the modules you need to reduce compilation time:
282
+ ```scss
283
+ @use "unit.gl/scss/functions" as fn;
284
+ @use "unit.gl/scss/mixins/view" as view;
285
+ ```
286
+
287
+ ### Design System Integration
288
+
289
+ - **Consistent Spacing**: Use Kyū multiples (4q, 8q, 12q, 16q) as your spacing scale
290
+ - **Type Hierarchy**: Choose one modular scale ratio and stick with it across all typographic elements
291
+ - **Z-Index Management**: Define your layer stack in `$layers` map at project start
292
+ - **Breakpoint Strategy**: Use mobile-first approach with `view()` mixins; avoid `max-width` queries
293
+
294
+ ### Accessibility Considerations
295
+
296
+ - **Relative Units**: `unit.gl` uses `rem` internally, respecting user font-size preferences
297
+ - **Viewport Scaling**: `fluid_type()` ensures readable text across all devices
298
+ - **Visual Guides**: Enable baseline grid during development to verify vertical rhythm alignment
299
+
300
+ ### Common Pitfalls to Avoid
301
+
302
+ ❌ **Don't mix unit systems**
303
+ ```scss
304
+ .bad {
305
+ padding: 10px; // Hardcoded px
306
+ margin: q(8); // Kyū unit
307
+ }
308
+ ```
309
+
310
+ ✅ **Use consistent units**
311
+ ```scss
312
+ .good {
313
+ padding: q(10); // All Kyū
314
+ margin: q(8);
315
+ }
316
+ ```
317
+
318
+ ❌ **Don't nest too many breakpoints**
319
+ ```scss
320
+ .bad {
321
+ @include view(md) {
322
+ @include view(lg) { // Nested breakpoint = bad specificity
323
+ // ...
324
+ }
325
+ }
326
+ }
327
+ ```
328
+
329
+ ✅ **Keep breakpoints flat**
330
+ ```scss
331
+ .good {
332
+ @include view(md) { /* md styles */ }
333
+ @include view(lg) { /* lg styles */ }
334
+ }
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Visual Reference
340
+
341
+ ### Kyū Unit System Diagram
342
+
343
+ ```
344
+ ┌─────────────────────────────────────────────────────────┐
345
+ │ 1rem = 16q = 16px (default browser font size) │
346
+ ├─────────────────────────────────────────────────────────┤
347
+ │ 1q = 0.0625rem = 1px │ Base unit │
348
+ │ 4q = 0.25rem = 4px │ Small spacing │
349
+ │ 8q = 0.5rem = 8px │ Medium spacing │
350
+ │ 16q = 1rem = 16px │ Large spacing │
351
+ │ 32q = 2rem = 32px │ Extra-large spacing │
352
+ └─────────────────────────────────────────────────────────┘
353
+ ```
354
+
355
+ ### Modular Scale Visualization (Golden Ratio 1.618)
356
+
357
+ ```
358
+ h1 ████████████████ (6.854rem) ← modular_scale(4)
359
+ h2 ██████████ (4.236rem) ← modular_scale(3)
360
+ h3 ██████ (2.618rem) ← modular_scale(2)
361
+ h4 ████ (1.618rem) ← modular_scale(1)
362
+ p ██ (1.000rem) ← modular_scale(0)
363
+ ```
364
+
365
+ ### Breakpoint Reference
366
+
367
+ | Name | Min Width | Q Format | Device Target |
368
+ |------|-----------|-----------------|------------------------|
369
+ | us | 240px | Q07 Portrait | Compact / Fold |
370
+ | ss | 360px | Q06 Portrait | Phones |
371
+ | xs | 540px | Q05 Portrait | Large phones |
372
+ | sm | 720px | Q04 Portrait | Tablets |
373
+ | md | 1440px | Q03 Landscape | Laptops |
374
+ | lg | 2160px | Q02 Landscape | QHD Desktops |
375
+ | xl | 2880px | Q01 Landscape | 4K Displays |
376
+ | ul | 4320px | Q00 Landscape | 5K+ Displays |
377
+
378
+ ---
379
+
52
380
  ## Colophon
53
381
 
54
382
  ### Authors