aerolith 1.1.0 → 1.2.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/LICENSE CHANGED
@@ -22,7 +22,8 @@ SOFTWARE.
22
22
 
23
23
  The rendered sprite images in library/dist/ are covered by the same license.
24
24
  The fonts in library/dist/fonts/ are not: they are under the SIL Open Font
25
- License 1.1 (Istok Web, Selawik, and Aerolith Display, which is derived from
26
- Istok Web). Their license files are in that folder.
25
+ License 1.1 (Istok Web, Aerolith Text, which is derived from Selawik, and
26
+ Aerolith Display, which is derived from Istok Web). Their license files are in
27
+ that folder.
27
28
  Bryce is a trademark of its respective owner. This project is not affiliated
28
29
  with or endorsed by it, and contains no part of the Bryce software.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Aerolith
2
2
 
3
- Frutiger Aero for the web. Every button, field, pane, icon and title letter is a Bryce 2 render
3
+ Tactile UI for the web. Every button, field, pane, icon and title letter is a Bryce 2 render
4
4
  (1996), laid over plain HTML elements.
5
5
 
6
6
  **[Live showcase](https://immineal.github.io/aerolith/)** · [npm](https://www.npmjs.com/package/aerolith) · [Changelog](CHANGELOG.md)
@@ -39,7 +39,7 @@ example of every component. Self-hosting: keep `sprites/` and `fonts/` next to `
39
39
  | GitHub Packages | `npm i @immineal/aerolith --registry=https://npm.pkg.github.com` | same |
40
40
  | Composer | `composer require immineal/aerolith` | serve `vendor/immineal/aerolith/library/dist/` |
41
41
  | PyPI | `pip install aerolith` | `aerolith.static_dir()`; Django: add `"aerolith"` to `INSTALLED_APPS` |
42
- | CDN | jsDelivr, unpkg, esm.sh | or `cdn.jsdelivr.net/gh/immineal/aerolith@v1.1.0/library/dist/aerolith.css` |
42
+ | CDN | jsDelivr, unpkg, esm.sh | or `cdn.jsdelivr.net/gh/immineal/aerolith@v1.2.0/library/dist/aerolith.css` |
43
43
 
44
44
  React, Vue, Svelte, Astro: import the CSS once in your entry file and use the classes
45
45
  (`className` in JSX). Content added after load needs `window.Aerolith.init(container)`.
@@ -55,7 +55,7 @@ React, Vue, Svelte, Astro: import the CSS once in your entry file and use the cl
55
55
  | `.aer-check`, `.aer-radio` | checkbox, radio | checked, mixed, disabled |
56
56
  | `.aer-field` | `<input>`, `<textarea>`, `<select>` | focus, disabled |
57
57
  | `.aer-select` | wrapper around `select.aer-field` | |
58
- | `.aer-segmented` | radios in labels, or links with `aria-current` | hover, selected |
58
+ | `.aer-segmented` | radios in labels, or links with `aria-current` | hover, selected (slides with the JS) |
59
59
  | `.aer-choice` | `<label>` with a radio or checkbox | hover, checked, focus |
60
60
  | `.aer-drop` | `<label>` with `<input type="file">` | drag-over, focus |
61
61
  | `.aer-progress` | `<progress>` | value |
@@ -67,7 +67,7 @@ React, Vue, Svelte, Astro: import the CSS once in your entry file and use the cl
67
67
  | `.aer-dialog`, `.aer-close` | `<dialog>`, `<button>` | open, backdrop |
68
68
  | `.aer-popover`, `.aer-menu` | `[popover]` | item hover/focus |
69
69
  | `.aer-bar` | `<header>`, `<nav>` | |
70
- | `.aer-lens` | any block | rim refraction in Chromium |
70
+ | `.aer-lens` | any block | rim refraction; `data-aer-drag` makes it movable |
71
71
  | `.aer-compare` | two `<img>` and an `<input type="range">` | |
72
72
  | `.aer-display` (+ `.aer-aqua`, `.aer-glass`, `.aer-pearl`) | any heading | 116 characters |
73
73
 
@@ -83,8 +83,8 @@ Aerolith Display is a colour font of rendered gel letters, so titles stay real,
83
83
  Use it from 32 px up. Each material is about 0.6 MB, loaded only where used. Browsers without
84
84
  colour fonts show heavy Istok.
85
85
 
86
- Body text is **Selawik**, an open Segoe UI stand-in. `data-aer-type="istok"` switches to
87
- **Istok Web**. Dark mode follows the system; `data-theme="dark"` or `"light"` on `<html>` forces it,
86
+ Body text is **Aerolith Text**, Selawik (an open Segoe UI stand-in) with a kern table, because Selawik
87
+ ships without kerning. `data-aer-type="istok"` switches to **Istok Web**. Dark mode follows the system; `data-theme="dark"` or `"light"` on `<html>` forces it,
88
88
  and the sun/moon switch (`input[data-aer-theme]`) sets that for you.
89
89
 
90
90
  ## Accessibility
@@ -130,7 +130,8 @@ Setup: [harness/README.md](harness/README.md). Design rules:
130
130
 
131
131
  - **No colour picker.** Colours are baked into the renders.
132
132
  - **Three heights.** 32, 44 or 56 px; buttons stretch sideways only.
133
- - **The lens bends light only in Chromium.** Firefox and Safari show plain glass.
133
+ - **The lens bends light in Chromium, and in Firefox with `data-aer-lens-backdrop="#el"`** (the
134
+ element behind it). Safari shows plain glass.
134
135
  - **No framework components.** Put the classes on your own elements.
135
136
  - **Bitmap icons and titles.** Icons are 16 and 24 px. Titles are sharp up to about 120 px and
136
137
  cover Latin with German and French accents.
@@ -138,6 +139,7 @@ Setup: [harness/README.md](harness/README.md). Design rules:
138
139
  ## License
139
140
 
140
141
  MIT for code and sprites ([LICENSE](LICENSE)). Fonts in `library/dist/fonts/` are SIL OFL 1.1:
141
- Istok Web (Andrey V. Panov) and Selawik (Microsoft) unmodified, Aerolith Display derived from
142
+ Istok Web (Andrey V. Panov) unmodified; Aerolith Text, derived from Selawik (Microsoft) with a kern
143
+ table added and renamed because the OFL reserves "Selawik"; Aerolith Display, derived from
142
144
  Istok Web Bold. Bryce is a trademark of its owner; Aerolith is not affiliated and contains no
143
145
  Bryce code.
@@ -21,7 +21,7 @@
21
21
  --aer-target-gap: var(--aer-space-2);
22
22
 
23
23
  /* type: modular scale 1.2 */
24
- --aer-font-ui: "Selawik", "Segoe UI", "Istok Web", "Frutiger", "Myriad Pro", Tahoma, system-ui, sans-serif; /* bundled: type.css */
24
+ --aer-font-ui: "Aerolith Text", "Selawik", "Segoe UI", "Istok Web", "Myriad Pro", Tahoma, system-ui, sans-serif; /* bundled: type.css */
25
25
  --aer-font-text: var(--aer-font-ui);
26
26
  --aer-font-mono: "Consolas", "Lucida Console", ui-monospace, monospace;
27
27
  --aer-text-xs: 0.833rem;
@@ -68,6 +68,13 @@
68
68
  /* 10-foot / distance media: scale everything so the visual angle stays comfortable at ~3 m */
69
69
  .aer-distance { font-size: 150%; --aer-control: var(--aer-control-l); }
70
70
 
71
+ /* Chromium on Linux and Windows rounds every glyph advance to whole pixels unless asked for precise
72
+ geometry: a 16 px label came out 1.6 px wider with an open gap after the f in "verfügbar".
73
+ Scoped to our own controls; a host page keeps its own text-rendering. */
74
+ :is(.aer-button, .aer-field, .aer-select, .aer-badge, .aer-segmented, .aer-menu, .aer-label, .aer-option,
75
+ .aer-choice, .aer-check, .aer-radio, .aer-toggle, .aer-panel, .aer-card, .aer-callout, .aer-dialog,
76
+ .aer-popover, .aer-toast) { text-rendering: geometricPrecision; }
77
+
71
78
  /* label text on glossy sprites: white + halo (WCAG measures text against its halo) */
72
79
  .aer-on-gloss {
73
80
  color: var(--aer-on-gloss);
@@ -89,7 +96,7 @@
89
96
  @media (forced-colors: active) {
90
97
  .aer [class*="aer-"] { border-color: ButtonText; }
91
98
  .aer-button, .aer-field, .aer-panel { border: 1px solid ButtonText !important; }
92
- .aer-button:focus-visible { outline: 2px solid Highlight; }
99
+ .aer-button:focus-visible, .aer .aer-field:focus-visible, .aer-field:focus-visible { outline: 2px solid Highlight; }
93
100
  }
94
101
 
95
102
  /* utilities */
@@ -100,7 +107,8 @@
100
107
 
101
108
  /* ---- type.css ---- */
102
109
  /* Aerolith type.
103
- Text: Selawik (default) or Istok Web (data-aer-type="istok"), both bundled, both SIL OFL 1.1.
110
+ Text: Aerolith Text (default; Selawik with a kern table, renamed because the OFL reserves "Selawik")
111
+ or Istok Web (data-aer-type="istok"), both bundled, both SIL OFL 1.1.
104
112
  Titles: Aerolith Display, gel letters rendered in Bryce and packed into colour fonts. Each
105
113
  material comes as OpenType-SVG (Firefox, Safari) and sbix (Chromium); tech() makes a browser
106
114
  download only the file it can draw. The fonts keep outlines, so a browser without colour-font
@@ -115,13 +123,13 @@
115
123
  @font-face { font-family: "Istok Web"; src: url(fonts/istok-web-bold-italic.woff2) format("woff2");
116
124
  font-weight: 700; font-style: italic; font-display: swap; }
117
125
 
118
- @font-face { font-family: "Selawik"; src: url(fonts/selawik-light.woff2) format("woff2");
126
+ @font-face { font-family: "Aerolith Text"; src: url(fonts/aerolith-text-light.woff2) format("woff2");
119
127
  font-weight: 300; font-display: swap; }
120
- @font-face { font-family: "Selawik"; src: url(fonts/selawik-regular.woff2) format("woff2");
128
+ @font-face { font-family: "Aerolith Text"; src: url(fonts/aerolith-text-regular.woff2) format("woff2");
121
129
  font-weight: 400; font-display: swap; }
122
- @font-face { font-family: "Selawik"; src: url(fonts/selawik-semibold.woff2) format("woff2");
130
+ @font-face { font-family: "Aerolith Text"; src: url(fonts/aerolith-text-semibold.woff2) format("woff2");
123
131
  font-weight: 600; font-display: swap; }
124
- @font-face { font-family: "Selawik"; src: url(fonts/selawik-bold.woff2) format("woff2");
132
+ @font-face { font-family: "Aerolith Text"; src: url(fonts/aerolith-text-bold.woff2) format("woff2");
125
133
  font-weight: 700; font-display: swap; }
126
134
 
127
135
  @font-face { font-family: "Aerolith Display Aqua"; font-display: swap;
@@ -138,7 +146,7 @@
138
146
  url(fonts/aerolith-display-pearl.bmp.woff2) format("woff2") tech(color-sbix); }
139
147
 
140
148
  [data-aer-type="istok"], .aer-type-istok {
141
- --aer-font-ui: "Istok Web", "Selawik", "Segoe UI", Tahoma, system-ui, sans-serif;
149
+ --aer-font-ui: "Istok Web", "Aerolith Text", "Segoe UI", Tahoma, system-ui, sans-serif;
142
150
  }
143
151
 
144
152
  /* Big titles only: the letters are rendered at about 80 px per em and read best from 32 px up.
@@ -1454,6 +1462,8 @@
1454
1462
  .aer-field:focus {
1455
1463
  border-image: var(--aer-field-focus) var(--aer-field-focus-slice) / var(--aer-field-focus-border) / var(--aer-field-focus-outset) stretch;
1456
1464
  }
1465
+ /* the rendered aqua rim is the focus indicator: the square outline would cut across the rounded well */
1466
+ .aer .aer-field:focus-visible, .aer-field:focus-visible { outline: none; }
1457
1467
  textarea.aer-field { block-size: auto; min-block-size: calc(var(--aer-control) * 2); padding-block: var(--aer-space-3); resize: vertical; line-height: var(--aer-leading); }
1458
1468
  .aer-field:disabled, .aer-field[readonly] { color: var(--aer-ink-muted); }
1459
1469
  .aer-label { display: grid; gap: var(--aer-space-1); font: 600 var(--aer-text-s) / 1.3 var(--aer-font-ui); color: var(--aer-ink); }
@@ -1629,6 +1639,20 @@ a.aer-card:hover, button.aer-card:hover, .aer-card[data-interactive]:hover {
1629
1639
  }
1630
1640
  .aer-segmented > :has(:focus-visible) { outline: 2px solid var(--aer-focus); outline-offset: 2px; }
1631
1641
  .aer-segmented > :has(:disabled) { opacity: 0.5; cursor: not-allowed; }
1642
+ /* with aerolith.js: one pill carries the chip and slides; the items' own chips give way */
1643
+ .aer-segmented[data-aer-slide] { position: relative; isolation: isolate; }
1644
+ .aer-seg-pill {
1645
+ position: absolute; left: 0; top: 0; z-index: -1; box-sizing: border-box; pointer-events: none;
1646
+ border-style: solid; border-color: transparent; border-width: 0;
1647
+ border-image: var(--aer-seg-chip) var(--aer-seg-chip-slice) / var(--aer-seg-chip-border) / var(--aer-seg-chip-outset) stretch;
1648
+ }
1649
+ .aer-segmented[data-aer-ready] > .aer-seg-pill {
1650
+ transition: transform 300ms cubic-bezier(.3, 1.2, .5, 1), width 300ms cubic-bezier(.3, 1.2, .5, 1);
1651
+ }
1652
+ .aer-segmented[data-aer-slide] > :is(:has(:checked), [aria-current]:not([aria-current="false"]), [aria-selected="true"], [aria-pressed="true"]) {
1653
+ border-image: none;
1654
+ }
1655
+ .aer-segmented[data-aer-ready] > :not(.aer-seg-pill) { transition: color 200ms, text-shadow 200ms; }
1632
1656
 
1633
1657
  /* ------------------------------------------------------------------ choice card: a whole tile is the radio/checkbox
1634
1658
  <label class="aer-choice"><input type="radio" class="aer-radio" name="f"> <b>PDF</b> <small>…</small></label> */
@@ -1826,14 +1850,27 @@ a.aer-card:hover, button.aer-card:hover, .aer-card[data-interactive]:hover {
1826
1850
  }
1827
1851
  .aer-bar > .aer-spacer { flex: 1; }
1828
1852
 
1829
- /* ------------------------------------------------------------------ lens: clear thick glass; in Chromium aerolith.js
1830
- adds the refraction of its rim (an SVG displacement map computed from the same bevel profile) */
1853
+ /* ------------------------------------------------------------------ lens: clear thick glass. aerolith.js adds the
1854
+ refraction of its rim (an SVG displacement map computed from the same bevel profile): in Chromium, and in
1855
+ Firefox when data-aer-lens-backdrop names the element behind it. Safari shows plain glass. */
1831
1856
  .aer-lens {
1832
1857
  position: relative; box-sizing: border-box; padding: var(--aer-space-5);
1833
1858
  border-style: solid; border-color: transparent; border-width: 0;
1834
1859
  border-image: var(--aer-lens) var(--aer-lens-slice) / var(--aer-lens-border) / var(--aer-lens-outset) stretch;
1835
1860
  color: var(--aer-ink);
1836
1861
  }
1862
+ /* with a backdrop copy: copy at the bottom, glass sprite over it, content on top */
1863
+ .aer-lens[data-aer-lens-view] { isolation: isolate; border-image: none; }
1864
+ .aer-lens[data-aer-lens-view]::before {
1865
+ content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
1866
+ border-style: solid; border-color: transparent; border-width: 0;
1867
+ border-image: var(--aer-lens) var(--aer-lens-slice) / var(--aer-lens-border) / var(--aer-lens-outset) stretch;
1868
+ }
1869
+ .aer-lens-view { position: absolute; z-index: -2; overflow: hidden; pointer-events: none; } /* placed by aerolith.js */
1870
+ /* the focus ring follows the glass, not a square box */
1871
+ .aer-lens[data-aer-drag] { border-radius: 24px; }
1872
+ .aer-lens[data-aer-drag] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
1873
+ .aer-lens[data-aer-dragging] { cursor: grabbing; }
1837
1874
 
1838
1875
  /* ------------------------------------------------------------------ preferences */
1839
1876
  /* ------------------------------------------------------------------ state sprites, fetched up front
@@ -1865,6 +1902,7 @@ a.aer-card, button.aer-card, .aer-card[data-interactive], .aer-close {
1865
1902
  .aer-spinner::before { animation: none; }
1866
1903
  .aer-toggle::before, .aer-progress::-webkit-progress-value { transition: none; }
1867
1904
  .aer-toast, .aer-dialog[open] { animation: none; }
1905
+ .aer-segmented[data-aer-ready] > .aer-seg-pill, .aer-segmented[data-aer-ready] > :not(.aer-seg-pill) { transition: none; }
1868
1906
  }
1869
1907
  /* forced colours: sprites are dropped, native rendering and system colours take over */
1870
1908
  @media (forced-colors: active) {
@@ -1877,6 +1915,7 @@ a.aer-card, button.aer-card, .aer-card[data-interactive], .aer-close {
1877
1915
  background: Highlight; color: HighlightText; forced-color-adjust: none;
1878
1916
  }
1879
1917
  .aer-toggle, .aer-check, .aer-radio { appearance: auto; border-image: none; }
1880
- .aer-toggle::before, .aer-spinner::before, .aer-callout::before { display: none; }
1918
+ .aer-toggle::before, .aer-spinner::before, .aer-callout::before, .aer-seg-pill,
1919
+ .aer-lens::before, .aer-lens-view { display: none; }
1881
1920
  .aer-spinner { border: 3px dotted CanvasText; border-radius: 50%; }
1882
1921
  }
@@ -3,8 +3,10 @@
3
3
  // - slider / compare: keeps --aer-fill in sync with the native range value
4
4
  // - drop zone: [data-aer-over] while files are dragged over an .aer-drop
5
5
  // - theme switch: input[data-aer-theme] toggles <html data-theme> and remembers the choice
6
- // - lens: the rim refraction of .aer-lens (Chromium only: backdrop-filter with an SVG filter)
6
+ // - lens: the rim refraction of .aer-lens (Chromium; Firefox too with data-aer-lens-backdrop);
7
+ // data-aer-drag makes it movable
7
8
  // - menus: popovers drop down from their button; [data-aer-menu] opens one at the pointer
9
+ // - segmented: the selected chip slides between items
8
10
  // - preload: sprites of closed dialogs and popovers load with the page
9
11
  (function () {
10
12
  "use strict";
@@ -36,33 +38,64 @@
36
38
  }
37
39
 
38
40
  // ---------------------------------------------------------------- lens: displacement map from the bevel profile
39
- var lensId = 0, svgRoot = null;
41
+ // Two ways to bend what is behind the rim:
42
+ // - data-aer-lens-backdrop="<selector>": the lens carries a copy of that element, lined up with the
43
+ // original, and bends the copy with filter: url(). Chromium and Firefox.
44
+ // - otherwise, Chromium only: backdrop-filter: url(). Safari shows plain glass either way.
45
+ // data-aer-drag makes the lens movable (pointer, touch, arrow keys) inside its parent.
46
+ var lensId = 0, svgRoot = null, PAD = 2;
47
+ // Lens geometry, same as the rendered sprite (catalog.py): superellipse corners (n = 4) of radius
48
+ // LENS_R, a convex edge 1-(1-t)^4 over LENS_BEVEL px. Light comes straight down, refracts at the
49
+ // curved top and the flat bottom (IOR 1.5), then travels LIFT px to the page under the glass.
50
+ var LENS_R = 32, LENS_BEVEL = 30, GLASS = 20, BASE = 4, LIFT = 24, IOR = 1.5;
51
+ var DISPERSION = [0.9, 1, 1.16]; // red, green, blue: blue bends most
40
52
  function chromium() { return !!(navigator.userAgentData && navigator.userAgentData.brands &&
41
53
  navigator.userAgentData.brands.some(function (b) { return /Chromium/.test(b.brand); })); }
42
- function lensMap(w, h, radius, bevel) {
43
- // height h(d) = smoothstep(d / bevel) of the distance d to the rounded-rect outline; the
44
- // gradient of h, scaled to 0..255 around 128, tells feDisplacementMap how far to bend light
45
- var c = document.createElement("canvas"); c.width = w; c.height = h;
46
- var g = c.getContext("2d"), img = g.createImageData(w, h), px = img.data;
47
- var hx = w / 2, hy = h / 2, r = Math.min(radius, hx, hy);
48
- function height(x, y) {
49
- var qx = Math.abs(x - hx) - (hx - r), qy = Math.abs(y - hy) - (hy - r);
50
- var out = Math.hypot(Math.max(qx, 0), Math.max(qy, 0)) + Math.min(Math.max(qx, qy), 0) - r;
51
- var t = Math.min(Math.max(-out / bevel, 0), 1);
52
- return t * t * (3 - 2 * t);
53
- }
54
- for (var y = 0; y < h; y++) for (var x = 0; x < w; x++) {
55
- var dx = height(x + 1, y + 0.5) - height(x, y + 0.5), dy = height(x + 0.5, y + 1) - height(x + 0.5, y);
56
- var k = bevel * 0.75, i = (y * w + x) * 4;
57
- px[i] = 128 + Math.max(-127, Math.min(127, dx * k * 127));
58
- px[i + 1] = 128 + Math.max(-127, Math.min(127, dy * k * 127));
59
- px[i + 2] = 128; px[i + 3] = 255;
54
+ function bend(d, bevel) { // px of sideways shift at depth d (px in from the outline)
55
+ var t = Math.min(Math.max(d / bevel, 0), 1), u = 1 - t;
56
+ var z = GLASS * (1 - u * u * u * u), slope = GLASS * 4 * u * u * u / bevel;
57
+ var ti = Math.atan(slope), dl = ti - Math.asin(Math.sin(ti) / IOR);
58
+ return (z + BASE) * Math.tan(dl) + LIFT * Math.tan(Math.asin(Math.min(1, IOR * Math.sin(dl))));
59
+ }
60
+ function lensMap(w, h, W, H, q) {
61
+ // W x H map (lens centred) at q px per CSS px. R and G hold the inward shift as a fraction of the
62
+ // largest one (128 = none); returns the map and that largest shift in px. One lookup table, then
63
+ // a few multiplications per pixel: cheap enough to redo on every resize.
64
+ var R = Math.min(LENS_R, w / 2, h / 2), bevel = Math.min(LENS_BEVEL, R);
65
+ var STEP = 16, lut = new Float32Array(Math.ceil(bevel * STEP) + 2), max = bend(0, bevel);
66
+ for (var k = 0; k < lut.length; k++) lut[k] = bend(k / STEP, bevel) / max;
67
+ var cw = Math.round(W * q), ch = Math.round(H * q);
68
+ var c = document.createElement("canvas"); c.width = cw; c.height = ch;
69
+ var g = c.getContext("2d"), img = g.createImageData(cw, ch), px = img.data;
70
+ var hx = w / 2, hy = h / 2, ex = hx - R, ey = hy - R;
71
+ for (var Y = 0; Y < ch; Y++) {
72
+ var y = (Y + 0.5) / q - H / 2, ay = Math.abs(y), qy = ay - ey;
73
+ for (var X = 0; X < cw; X++) {
74
+ var x = (X + 0.5) / q - W / 2, ax = Math.abs(x), qx = ax - ex, d, ux = 0, uy = 0;
75
+ if (qx > 0 && qy > 0) { // corner: superellipse, n = 4
76
+ var x3 = qx * qx * qx, y3 = qy * qy * qy, L = Math.sqrt(Math.sqrt(x3 * qx + y3 * qy));
77
+ d = R - L;
78
+ var gl = Math.hypot(x3, y3); ux = -x3 / gl; uy = -y3 / gl;
79
+ } else if (qx > qy) { d = R - qx; ux = -1; }
80
+ else { d = R - qy; uy = -1; }
81
+ if (x < 0) ux = -ux;
82
+ if (y < 0) uy = -uy;
83
+ var m = 0;
84
+ if (d > 0 && d < bevel) { var f = d * STEP, k0 = f | 0; m = lut[k0] + (lut[k0 + 1] - lut[k0]) * (f - k0); }
85
+ var i = (Y * cw + X) * 4;
86
+ px[i] = 128 + Math.round(127 * m * ux); px[i + 1] = 128 + Math.round(127 * m * uy);
87
+ px[i + 2] = 128; px[i + 3] = 255;
88
+ }
60
89
  }
61
90
  g.putImageData(img, 0, 0);
62
- return c.toDataURL();
91
+ return { url: c.toDataURL(), max: max };
63
92
  }
64
93
  function lens(el) {
65
- if (!chromium()) return;
94
+ if (el.hasAttribute("data-aer-drag")) drag(el);
95
+ // WebKit (Safari, every iOS browser) misplaces SVG filters on HTML: plain glass there
96
+ var sel = el.getAttribute("data-aer-lens-backdrop"), gecko = CSS.supports("-moz-appearance", "none");
97
+ var src = sel && (chromium() || gecko) ? document.querySelector(sel) : null;
98
+ if (!src && !chromium()) return;
66
99
  var NS = "http://www.w3.org/2000/svg";
67
100
  if (!svgRoot) {
68
101
  svgRoot = document.createElementNS(NS, "svg");
@@ -70,34 +103,102 @@
70
103
  svgRoot.style.cssText = "position:absolute;width:0;height:0;overflow:hidden";
71
104
  document.body.appendChild(svgRoot);
72
105
  }
73
- var id = "aer-lens-" + (++lensId), filter = null;
106
+ var id = "aer-lens-" + (++lensId), filter = null, view = null, copy = null, ox = 0, oy = 0;
107
+ if (src) {
108
+ // the copy: same element, same classes, no ids, no lens inside, lined up with the original
109
+ view = document.createElement("div");
110
+ view.className = "aer-lens-view"; view.setAttribute("aria-hidden", "true"); view.inert = true;
111
+ copy = src.cloneNode(true);
112
+ copy.removeAttribute("id");
113
+ copy.querySelectorAll("[id]").forEach(function (n) { n.removeAttribute("id"); });
114
+ copy.querySelectorAll(".aer-lens").forEach(function (n) { n.remove(); });
115
+ view.appendChild(copy);
116
+ el.insertBefore(view, el.firstChild);
117
+ el.setAttribute("data-aer-lens-view", "");
118
+ }
119
+ function sync() { // line the copy up with the original
120
+ if (!copy) return;
121
+ var cs = getComputedStyle(src), a = src.getBoundingClientRect(), b = el.getBoundingClientRect();
122
+ var st = copy.style;
123
+ st.position = "absolute"; st.margin = "0"; st.boxSizing = "border-box"; st.transform = "none"; st.translate = "none";
124
+ st.width = src.offsetWidth + "px"; st.height = src.offsetHeight + "px";
125
+ st.left = (a.left - b.left + ox) + "px"; st.top = (a.top - b.top + oy) + "px";
126
+ ["color", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing"].forEach(function (p) { st[p] = cs[p]; });
127
+ }
74
128
  function build() {
75
129
  var w = Math.round(el.offsetWidth), h = Math.round(el.offsetHeight);
76
130
  if (!w || !h) return;
77
131
  if (filter) filter.remove();
132
+ var pad = view ? PAD : 0, W = w + 2 * pad, H = h + 2 * pad;
133
+ var map = lensMap(w, h, W, H, Math.min(2, window.devicePixelRatio || 1));
134
+ if (view) {
135
+ ox = pad; oy = pad;
136
+ var vs = view.style;
137
+ vs.left = -pad + "px"; vs.top = -pad + "px"; vs.width = W + "px"; vs.height = H + "px";
138
+ }
139
+ // map -> three displacements (red, green, blue bend by different amounts) -> recombined
78
140
  filter = document.createElementNS(NS, "filter");
79
141
  filter.id = id;
80
- ["x", "y"].forEach(function (a) { filter.setAttribute(a, "0"); });
81
- filter.setAttribute("width", w); filter.setAttribute("height", h);
82
- filter.setAttribute("filterUnits", "userSpaceOnUse");
83
- filter.setAttribute("color-interpolation-filters", "sRGB");
84
- var fi = document.createElementNS(NS, "feImage");
85
- fi.setAttribute("href", lensMap(w, h, 24, Math.min(28, w / 4, h / 4)));
86
- fi.setAttribute("x", 0); fi.setAttribute("y", 0); fi.setAttribute("width", w); fi.setAttribute("height", h);
87
- fi.setAttribute("preserveAspectRatio", "none"); fi.setAttribute("result", "map");
88
- var dm = document.createElementNS(NS, "feDisplacementMap");
89
- dm.setAttribute("in", "SourceGraphic"); dm.setAttribute("in2", "map"); dm.setAttribute("scale", "36");
90
- dm.setAttribute("xChannelSelector", "R"); dm.setAttribute("yChannelSelector", "G");
91
- filter.appendChild(fi); filter.appendChild(dm);
142
+ var attrs = { x: 0, y: 0, width: W, height: H, filterUnits: "userSpaceOnUse", primitiveUnits: "userSpaceOnUse",
143
+ "color-interpolation-filters": "sRGB" };
144
+ for (var a in attrs) filter.setAttribute(a, attrs[a]);
145
+ function prim(tag, at) {
146
+ var n = document.createElementNS(NS, tag);
147
+ for (var a in at) n.setAttribute(a, at[a]);
148
+ filter.appendChild(n);
149
+ }
150
+ prim("feImage", { href: map.url, x: 0, y: 0, width: W, height: H, preserveAspectRatio: "none", result: "map" });
151
+ ["r", "g", "b"].forEach(function (ch, k) {
152
+ prim("feDisplacementMap", { in: "SourceGraphic", in2: "map", scale: (2 * map.max * DISPERSION[k]).toFixed(2),
153
+ xChannelSelector: "R", yChannelSelector: "G", result: "d" + ch });
154
+ var m = ["0 0 0 0 0", "0 0 0 0 0", "0 0 0 0 0"]; m[k] = ["1 0 0 0 0", "0 1 0 0 0", "0 0 1 0 0"][k];
155
+ prim("feColorMatrix", { in: "d" + ch, type: "matrix", values: m.join(" ") + " 0 0 0 1 0", result: ch });
156
+ });
157
+ prim("feComposite", { in: "r", in2: "g", operator: "arithmetic", k2: 1, k3: 1, result: "rg" });
158
+ prim("feComposite", { in: "rg", in2: "b", operator: "arithmetic", k2: 1, k3: 1 });
92
159
  svgRoot.appendChild(filter);
93
- el.style.backdropFilter = "url(#" + id + ")";
160
+ if (view) { sync(); view.style.filter = "url(#" + id + ")"; }
161
+ else el.style.backdropFilter = "url(#" + id + ")";
94
162
  el.setAttribute("data-aer-lens", "");
95
163
  }
164
+ el._aerLensSync = sync;
96
165
  build();
97
166
  if (window.ResizeObserver) {
98
167
  var t;
99
168
  new ResizeObserver(function () { clearTimeout(t); t = setTimeout(build, 120); }).observe(el);
169
+ if (src) new ResizeObserver(sync).observe(src);
100
170
  }
171
+ addEventListener("resize", sync);
172
+ }
173
+ function drag(el) {
174
+ var x = 0, y = 0, start = null;
175
+ if (!el.hasAttribute("tabindex")) el.tabIndex = 0;
176
+ function moveTo(nx, ny) {
177
+ var box = el.parentElement.getBoundingClientRect(), r = el.getBoundingClientRect();
178
+ var bx = r.left - x, by = r.top - y; // where it sits without the shift
179
+ x = Math.round(clamp(nx, box.left - bx, box.right - r.width - bx));
180
+ y = Math.round(clamp(ny, box.top - by, box.bottom - r.height - by));
181
+ el.style.translate = x + "px " + y + "px";
182
+ if (el._aerLensSync) el._aerLensSync();
183
+ }
184
+ el.addEventListener("pointerdown", function (e) {
185
+ if (e.button !== 0 || e.target.closest("a, button, input, select, textarea")) return;
186
+ start = { px: e.clientX, py: e.clientY, x: x, y: y };
187
+ el.setPointerCapture(e.pointerId); el.setAttribute("data-aer-dragging", "");
188
+ e.preventDefault();
189
+ });
190
+ el.addEventListener("pointermove", function (e) {
191
+ if (start) moveTo(start.x + e.clientX - start.px, start.y + e.clientY - start.py);
192
+ });
193
+ ["pointerup", "pointercancel", "lostpointercapture"].forEach(function (t) {
194
+ el.addEventListener(t, function () { start = null; el.removeAttribute("data-aer-dragging"); });
195
+ });
196
+ el.addEventListener("keydown", function (e) {
197
+ var d = e.shiftKey ? 40 : 10, k = { ArrowLeft: [-d, 0], ArrowRight: [d, 0], ArrowUp: [0, -d], ArrowDown: [0, d] }[e.key];
198
+ if (!k) return;
199
+ e.preventDefault(); moveTo(x + k[0], y + k[1]);
200
+ });
201
+ if (window.ResizeObserver) new ResizeObserver(function () { moveTo(x, y); }).observe(el.parentElement);
101
202
  }
102
203
 
103
204
  // ---------------------------------------------------------------- menus: placed like a context menu
@@ -198,10 +299,59 @@
198
299
  document.body.appendChild(i);
199
300
  }
200
301
 
302
+ // ---------------------------------------------------------------- segmented: one pill that slides
303
+ // Without this every selected item draws its own chip. With it, one .aer-seg-pill under the items
304
+ // carries the chip and CSS moves it. It follows radio changes, aria-current / -selected / -pressed
305
+ // (MutationObserver), form resets and size changes; a size change snaps instead of sliding.
306
+ function selected(c) {
307
+ var i = c.querySelector("input");
308
+ if (i) return i.checked;
309
+ var a = c.getAttribute("aria-current");
310
+ return (a !== null && a !== "false") || c.getAttribute("aria-selected") === "true" ||
311
+ c.getAttribute("aria-pressed") === "true";
312
+ }
313
+ function slide(seg) {
314
+ var pill = document.createElement("span"), shown = false;
315
+ pill.className = "aer-seg-pill"; pill.setAttribute("aria-hidden", "true");
316
+ seg.appendChild(pill); // last, so a fieldset's legend stays first
317
+ seg.setAttribute("data-aer-slide", "");
318
+ function place(snap) {
319
+ var c = null;
320
+ for (var k = 0; k < seg.children.length; k++) {
321
+ var e = seg.children[k];
322
+ if (e !== pill && selected(e)) { c = e; break; }
323
+ }
324
+ if (!c || !c.offsetWidth) { pill.style.opacity = "0"; shown = false; return; }
325
+ if (snap || !shown) seg.removeAttribute("data-aer-ready");
326
+ pill.style.opacity = "";
327
+ pill.style.transform = "translate(" + c.offsetLeft + "px, " + c.offsetTop + "px)";
328
+ pill.style.width = c.offsetWidth + "px"; pill.style.height = c.offsetHeight + "px";
329
+ if (snap || !shown) { void pill.offsetWidth; seg.setAttribute("data-aer-ready", ""); } // reflow, then animate again
330
+ shown = true;
331
+ }
332
+ seg._aerPlace = place;
333
+ seg.addEventListener("change", function () { place(); });
334
+ if (window.MutationObserver)
335
+ new MutationObserver(function () { place(); }).observe(seg, { subtree: true, attributes: true,
336
+ attributeFilter: ["aria-current", "aria-selected", "aria-pressed"] });
337
+ var form = seg.closest && seg.closest("form");
338
+ if (form) form.addEventListener("reset", function () { setTimeout(place, 0); });
339
+ if (window.ResizeObserver) {
340
+ var ro = new ResizeObserver(function () { place(true); });
341
+ ro.observe(seg);
342
+ for (var k = 0; k < seg.children.length; k++) if (seg.children[k] !== pill) ro.observe(seg.children[k]);
343
+ }
344
+ place(true);
345
+ }
346
+
201
347
  // ---------------------------------------------------------------- init
348
+ // Calling init again re-places the segmented pills, e.g. after setting input.checked from script.
202
349
  function init(root) {
203
350
  root = root || document;
204
351
  preload(root);
352
+ root.querySelectorAll(".aer-segmented").forEach(function (s) {
353
+ if (once(s, "aerSlide")) slide(s); else if (s._aerPlace) s._aerPlace();
354
+ });
205
355
  root.querySelectorAll(".aer-popover[popover]").forEach(function (p) { if (once(p, "aerBound")) bindPopover(p); });
206
356
  root.querySelectorAll("[data-aer-menu]").forEach(function (el) { if (once(el, "aerCtxBound")) bindContext(el); });
207
357
  root.querySelectorAll(".aer-slider > input[type=range], .aer-compare > input[type=range]").forEach(function (input) {
@@ -1,3 +1,9 @@
1
+ Aerolith Text is derived from Selawik by Microsoft Corporation. A kern table was added and the
2
+ font was renamed; it is a Modified Version under the SIL Open Font License 1.1 below and does not
3
+ use the Reserved Font Name "Selawik".
4
+
5
+ Copyright (c) 2026, Immineal (kern table).
6
+
1
7
  Copyright 2015, Microsoft Corporation (www.microsoft.com), with Reserved Font Name Selawik. All Rights Reserved. Selawik is a trademark of Microsoft Corporation in the United States and/or other countries.
2
8
 
3
9
  This Font Software is licensed under the SIL Open Font License, Version 1.1.
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "aerolith",
3
- "version": "1.1.0",
4
- "description": "Glossy buttons and real glass for the web, in the Frutiger Aero style. Every sprite rendered in Bryce 2 (1996) and laid over plain HTML.",
3
+ "version": "1.2.0",
4
+ "description": "Tactile UI for the web, rendered in Bryce 2 and laid over plain HTML.",
5
5
  "keywords": [
6
- "frutiger-aero", "css", "ui", "ui-library", "design-system", "skeuomorphism", "glassmorphism",
7
- "retro", "y2k", "aero", "bryce", "sprites", "dark-mode", "accessibility", "vanilla-css"
6
+ "tactile", "css", "ui", "ui-library", "design-system", "skeuomorphism", "glassmorphism",
7
+ "retro", "bryce", "sprites", "dark-mode", "accessibility", "vanilla-css"
8
8
  ],
9
9
  "homepage": "https://immineal.github.io/aerolith/",
10
10
  "bugs": "https://github.com/immineal/aerolith/issues",