@guildofgleks/ui 21.9.1 → 21.11.0

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/README.md CHANGED
@@ -257,6 +257,71 @@ detail and the full token list.
257
257
  Fonts are left alone on purpose (system stacks, no webfont download). Add
258
258
  `@guildofgleks/ui/styles/fonts.css` for the showcase's typography.
259
259
 
260
+ ### Making it fluid — one `clamp()`, not thirty
261
+
262
+ **Component sizing ships no `clamp()`, no `vw` and no breakpoints, and that is a decision rather
263
+ than an omission.** A component does not know how wide the screen is; it knows how wide its
264
+ container is, and `size` is your input, not something a stylesheet should override at 400px. So
265
+ fluid sizing is the app's to declare — and because everything here derives from a few foundation
266
+ tokens, it is one declaration rather than one per component.
267
+
268
+ **Chrome that floats over the viewport is the deliberate exception, and it is a narrower thing than
269
+ fluid sizing.** `--gog-tooltip-max-width`, `--gog-menu-max-width` and `--gog-toast-max-width` each
270
+ read `min(<cap>, calc(100vw - <margin> * 2))` — an overlay positioned against the screen rather
271
+ than a container, where "no wider than the screen" is what the component is for, not a style choice
272
+ a consumer makes. It does not grow anything: it only ever narrows a cap that would otherwise
273
+ overflow a small screen. It is not the recipe below, and reading one as an example of the other is
274
+ the mistake to avoid.
275
+
276
+ Viewport units appear in four other places, all older than that rule and all the same shape — a
277
+ ceiling rather than a curve: a dialog panel defaults to `90vw` and `--gog-dialog-max-height` to
278
+ `90vh`, `gog-menu` falls back to `100vh` when it cannot measure the room below its trigger, and
279
+ `gog-table`'s `maxHeight` takes any CSS length you give it, `'60vh'` included. `gog-confirmation-dialog`
280
+ has **no** viewport clamp of its own precisely because the panel it renders inside already carries
281
+ one.
282
+
283
+ Interpolate as a straight line between two viewports. Between `(W_min, V_min)` and
284
+ `(W_max, V_max)`:
285
+
286
+ ```
287
+ slope m = (V_max − V_min) / (W_max − W_min) × 100 → the vw coefficient
288
+ intercept b = (W_min·V_max − W_max·V_min) / (W_min − W_max) → the constant
289
+ size = clamp(V_min, b + m·vw, V_max)
290
+ ```
291
+
292
+ **The type scale is in `rem`, so the root font size is the one knob that moves all of it.** For 15px
293
+ at a 360px viewport growing to 17px at 1440px — `m = 0.185`, `b = 14.33px` — write the constant in
294
+ `rem` rather than `px`:
295
+
296
+ ```css
297
+ html {
298
+ /* 15px at 360px wide, 17px at 1440px. 0.8958rem is the 14.33px intercept. */
299
+ font-size: clamp(0.9375rem, 0.8958rem + 0.185vw, 1.0625rem);
300
+ }
301
+ ```
302
+
303
+ **Keep the intercept in `rem`, not `px`.** A viewport-only font size ignores the reader's own
304
+ browser text-size setting, which fails WCAG 1.4.4; with a `rem` term in the expression, their
305
+ preference still scales the result. Every `--gog-text-*` follows, and so does `--gog-icon-size`,
306
+ which is `1.2em`.
307
+
308
+ Spacing does not follow, deliberately: `--gog-space-*` is authored in `px` times `--gog-density` so
309
+ that one number is the whole spacing system, and a unitless multiplier cannot carry a `vw` term
310
+ (`calc()` will not add a number to a length). If you want gaps to grow with the type too, restate
311
+ the ten steps against the root font size once — the derived layer re-resolves and every component
312
+ follows:
313
+
314
+ ```css
315
+ :root {
316
+ --gog-space-4: calc(0.25rem * var(--gog-density));
317
+ --gog-space-8: calc(0.5rem * var(--gog-density));
318
+ /* …12, 16, 20, 24, 28, 32, 40, 48, each Npx as N/16 rem */
319
+ }
320
+ ```
321
+
322
+ `--gog-density` on its own remains the simpler answer for "roomier" versus "compact", and it needs
323
+ no arithmetic at all.
324
+
260
325
  ## App-wide configuration
261
326
 
262
327
  Anything visual is a token. Everything else — the settings you would otherwise repeat on every