Files
dawnline/web/src/portal/ui/press.ts
T
Aemeath ba231e7187
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Dawnline 0.15.0
- The device menu (⋯) is an iOS-style menu on frosted glass: the copy
  actions show the address they copy, Rename, Reconnect and Remove sit
  under them, and one highlight glides from row to row
- The language picker shows flags; pick a language with a click, or
  press the pill and slide onto one. The flag and the code change in
  place
- The page's QR code opens as a small card under its button, with Copy
  link and Share
- All dropdowns look and behave the same: frosted glass, one open at a
  time, and a press outside, Escape or the button again closes them
- Setting a device up: when it can't finish connecting or connects but
  passes no data, the sheet keeps just the status and what it means.
  No data now says the router drops its traffic because the address
  doesn't match, and the device's card says "Connected, but no data"
  right away instead of "Connected"
- Setting a phone up from another device: Download and Copy for the
  connection sit on its row, next to the arrow
- On iPhone and iPad the caret shows as soon as a field is focused, the
  page no longer zooms on a pinch or a double tap, and sheets and their
  animations run smoother
- A press near the edge of a button or a card always counts, even as it
  shrinks under the pointer
- Animations settle without a jump at the end
- New green, orange and red
- The focus ring shows only while moving around with the keyboard
2026-10-22 04:02:54 +03:00

47 lines
1.7 KiB
TypeScript

// A control pressed scales down (its :active look, in the stylesheets): let go near its edge after a moment and
// the pointer is outside it by then, so the browser gives the click to what holds both and nothing happens. Here
// what was pressed keeps the footprint it had when pressed: let go inside that and it gets the click, the
// browser's own (to the ancestor) dropped. A mouse or trackpad only: a touch stays with what it pressed.
const PRESSABLE = 'button, a[href], [role="button"], label';
let pressed: { el: HTMLElement; at: DOMRect } | null = null;
/** The browser's own click of this press, to the ancestor, is to be dropped. */
let swallow = false;
export function keepPressFootprint() {
document.addEventListener(
'pointerdown',
(e) => {
const el = e.pointerType === 'mouse' && e.button === 0 ? (e.target as Element).closest?.<HTMLElement>(PRESSABLE) : null;
pressed = el ? { el, at: el.getBoundingClientRect() } : null;
},
true,
);
document.addEventListener(
'pointerup',
(e) => {
const p = pressed;
pressed = null;
if (!p || p.el.contains(e.target as Node)) return;
const { at } = p;
if (e.clientX < at.left || e.clientX > at.right || e.clientY < at.top || e.clientY > at.bottom) return;
swallow = true;
// The click, if the browser sends one, comes right after this; anything later is another press.
setTimeout(() => (swallow = false));
p.el.click();
},
true,
);
document.addEventListener(
'click',
(e) => {
if (!swallow || !e.isTrusted) return;
swallow = false;
e.stopPropagation();
e.preventDefault();
},
true,
);
}