Dawnline 0.15.0
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

- 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
This commit is contained in:
Aemeath committed 2026-10-22 04:02:54 +03:00
1 parent a1915f070b
commit ba231e7187
51 files changed
+1713 -1062

No files matched your search

+92 -101
View File
@@ -1,123 +1,114 @@
// The ⋯ menu: a small panel under (or over) its button, items with an icon,
// a highlight that glides after the pointer and takes the item's colour
// (orange for Reconnect, red for Remove). A choice among options (the
// language) marks the current one with a check instead of icons. One at a
// time; it closes on a press outside, on scroll, on Escape and when its button
// is pressed again.
// The ⋯ menu: an iOS 26-style menu under its button (over it where the screen
// ends): Liquid Glass (the page blurred behind), a soft even edge.
// Laid out as iOS 26's: rows (an icon, the label and a line under it where the
// item has one: the address it copies), a thin line between groups; Reconnect
// orange, Remove red. The dropdowns' highlight glides from row to row. It springs out from the
// button's side and drops back towards it. Shut by a
// press outside, Escape, its button again or a choice. One at a time.
import { h, ic } from '../dom';
import { EASE_IN, POP, play } from '../motion';
import { appear, closeDrop, EDGE, GAP, opened, vanish } from './drop';
import { glide } from './glide';
export interface MenuItem {
label: string;
/** An action's icon; an option (`checked` set) shows a check in its place, on the current one only. */
icon?: string;
checked?: boolean;
/** Its line icon. */
icon: string;
/** Under the label: what it acts on (the address it copies). */
sub?: string;
tone?: 'warn' | 'bad';
run: () => unknown;
}
let menuEl: HTMLElement | null = null;
/** The button the open menu belongs to: pressing it again closes the menu. */
let anchorEl: HTMLElement | null = null;
export const menuOpen = () => !!menuEl;
/** `now`: gone at once (Escape, or another menu opening). */
export function closeMenu(now = false) {
const m = menuEl;
if (!m) return;
menuEl = null;
anchorEl?.setAttribute('aria-expanded', 'false');
anchorEl = null;
if (now) {
m.remove();
return;
/** `all`: null between groups (kept only between items); `title`: what it acts on (the device), for a screen reader. */
export function openMenu(anchor: HTMLElement, all: (MenuItem | null)[], title: string) {
// Its button again: it shuts.
if (anchor.getAttribute('aria-expanded') === 'true') return closeDrop();
const groups: MenuItem[][] = [[]];
for (const it of all) {
if (it) groups[groups.length - 1].push(it);
else if (groups[groups.length - 1].length) groups.push([]);
}
// From where it stands: one closed while it still pops in (a scroll, a second press) goes from there.
const s = getComputedStyle(m);
const a = play(
m,
[
{ opacity: s.opacity, transform: s.transform, filter: s.filter },
{ opacity: 0, transform: 'scale(.96)', filter: 'blur(3px)' },
],
{
duration: 120,
easing: EASE_IN,
fill: 'forwards',
},
);
m.getAnimations().forEach((x) => x !== a && x.cancel());
a.onfinish = () => m.remove();
}
if (!groups[groups.length - 1].length) groups.pop();
/** `items`: null is a separator, kept only between items. */
export function openMenu(anchor: HTMLElement, all: (MenuItem | null)[]) {
if (anchorEl === anchor && menuEl) return closeMenu();
closeMenu(true);
const items = all.filter((it, i) => it || (i > 0 && all[i - 1] && all.slice(i + 1).some(Boolean)));
const hl = h('span', { class: 'menu-hl' });
const m = h('div', { class: 'menu', role: 'menu' }, hl);
for (const it of items) {
if (!it) {
m.appendChild(h('div', { class: 'menu-sep' }));
continue;
}
const rows: HTMLElement[] = [];
const item = (it: MenuItem, cls: string, ...kids: (Node | null)[]) => {
const b = h(
'button',
{
type: 'button',
role: it.checked === undefined ? 'menuitem' : 'menuitemradio',
'aria-checked': it.checked === undefined ? null : String(it.checked),
class: `mi ${it.tone ?? ''}`,
role: 'menuitem',
class: `${cls}${it.tone ? ` ${it.tone}` : ''}`,
onclick: () => {
closeMenu();
close();
it.run();
},
},
it.checked === undefined ? ic(it.icon ?? '') : ic('check', it.checked ? 'i' : 'i off'),
h('span', {}, it.label),
...kids,
);
// The highlight comes in where the pointer is, then glides from item to item. Whether it shows is read off the
// screen: one still fading out (the pointer left and came back) turns back and glides from where it stands;
// only one gone altogether is placed at once.
b.addEventListener('pointerenter', () => {
const seen = +getComputedStyle(hl).opacity > 0.01;
hl.className = `menu-hl${seen ? ' moving' : ''} ${it.tone ?? ''}`;
hl.style.transform = `translateY(${b.offsetTop - 6}px)`;
hl.style.opacity = '1';
});
m.appendChild(b);
}
m.addEventListener('pointerleave', () => (hl.style.opacity = '0'));
document.body.appendChild(m);
const r = anchor.getBoundingClientRect();
const w = m.offsetWidth;
const mh = m.offsetHeight;
// Under the button, or over it where the screen ends: it grows out of the button either way.
const below = r.bottom + 8 + mh < innerHeight - 8;
m.style.left = `${Math.max(12, Math.min(r.right - w, innerWidth - w - 12))}px`;
m.style.top = `${below ? r.bottom + 8 : r.top - 8 - mh}px`;
m.style.transformOrigin = `${below ? 'top' : 'bottom'} right`;
play(
m,
[
{ opacity: 0, transform: 'scale(.9)', filter: 'blur(4px)' },
{ opacity: 1, transform: 'none', filter: 'none' },
],
{
duration: POP.duration,
easing: POP.easing,
},
rows.push(b);
return b;
};
const sections: HTMLElement[] = [
...groups.map((g) =>
h(
'div',
{ class: 'pop-grp' },
...g.map((it) =>
item(
it,
'mi',
ic(it.icon),
h('span', { class: 'mi-b' }, h('span', { class: 'mi-l' }, it.label), it.sub ? h('span', { class: 'mi-s' }, it.sub) : null),
),
),
),
),
];
// A thin line between sections (iOS's, inset; the rows themselves sit in a 16 px inset).
const body = h(
'div',
{ class: 'pop-body' },
...sections.flatMap((sec, i) => (i ? [h('div', { class: 'pop-sep', 'aria-hidden': 'true' }, h('span')), sec] : [sec])),
);
menuEl = m;
anchorEl = anchor;
anchor.setAttribute('aria-expanded', 'true');
}
const pop = h('div', { class: 'pop drop', role: 'menu', 'aria-label': title }, body);
document.body.append(pop);
document.addEventListener('pointerdown', (e) => {
const t = e.target as Element;
if (menuEl && !menuEl.contains(t) && !anchorEl?.contains(t)) closeMenu();
});
addEventListener('scroll', () => closeMenu(), { passive: true });
// Under the button where it fits, else over it; centred on it, inside the screen's edge, growing from its side.
const k = anchor.getBoundingClientRect();
const w = Math.min(pop.offsetWidth, innerWidth - EDGE * 2);
pop.style.width = `${w}px`;
const ht = pop.offsetHeight;
const mid = k.left + k.width / 2;
const left = Math.max(EDGE, Math.min(mid - w / 2, innerWidth - EDGE - w));
const below = k.bottom + GAP + ht <= innerHeight - EDGE || k.top - GAP - ht < EDGE;
const top = below ? k.bottom + GAP : k.top - GAP - ht;
Object.assign(pop.style, {
left: `${left + scrollX}px`,
top: `${top + scrollY}px`,
transformOrigin: `${mid - left}px ${below ? 0 : ht}px`,
});
appear(pop);
const release = opened(pop, anchor, close);
// The dropdowns' one highlight for the rows (ui/glide.ts).
glide(body, rows);
// Arrows move through the rows (the rest of the keys and presses are the dropdown's: ui/drop.ts).
const keys = (e: KeyboardEvent) => {
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
e.preventDefault();
const i = rows.indexOf(document.activeElement as HTMLElement);
const j = i < 0 ? (e.key === 'ArrowDown' ? 0 : rows.length - 1) : i + (e.key === 'ArrowDown' ? 1 : -1);
rows[Math.max(0, Math.min(rows.length - 1, j))]?.focus({ preventScroll: true });
};
document.addEventListener('keydown', keys, true);
function close(instant = false) {
if (!release()) return;
document.removeEventListener('keydown', keys, true);
if (instant || !anchor.isConnected) pop.remove();
else vanish(pop);
}
}