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

+6 -10
View File
@@ -1,12 +1,13 @@
// What the demo adds to the breadcrumb: the scenario chip right after the path,
// and a GitHub pill just before the page's language picker (none over a card
// and a GitHub knob (its mark only) just before the page's language picker (none over a card
// alone, which has no picker either). On a phone the pill would crowd out the names, so it
// gives way to a button in the scenario drawer (demo.css). The portal redraws
// the breadcrumb with the page and knows nothing of either, so both go back in
// the breadcrumb with the page and says when (onCrumbs), so both go back in
// place after each redraw; a language change makes both again in it.
import { h, ic } from '../dom';
import { onLang } from '../i18n';
import { onCrumbs } from '../page/frame';
import { REPO } from './data';
import { scenarioChip } from './picker';
import type { DemoRouter } from './router';
@@ -15,15 +16,9 @@ export function mountCrumbs(router: DemoRouter) {
const app = document.getElementById('app')!;
const make = () => ({
chip: scenarioChip(router),
gh: h(
'a',
{ class: 'dm-gh', href: REPO, target: '_blank', rel: 'noopener', 'aria-label': _('Dawnline on GitHub') },
ic('github'),
h('span', {}, 'GitHub'),
),
gh: h('a', { class: 'dm-gh', href: REPO, target: '_blank', rel: 'noopener', 'aria-label': _('Dawnline on GitHub') }, ic('github')),
});
let { chip, gh } = make();
// Our own insertions call this again: by then both are in place and nothing moves.
const keep = () => {
const crumbs = app.querySelector('.crumbs');
const path = crumbs?.querySelector('.cr-path');
@@ -32,7 +27,8 @@ export function mountCrumbs(router: DemoRouter) {
const lang = crumbs.querySelector('.cr-lang');
if (lang && lang.previousElementSibling !== gh) lang.before(gh);
};
new MutationObserver(keep).observe(app, { childList: true, subtree: true });
// Each time the page draws its breadcrumb again (a repaint, the language changed).
onCrumbs(keep);
keep();
// The page has redrawn its breadcrumb in the new language by now (main.ts listens first).
onLang(() => {
+15 -111
View File
@@ -1,5 +1,5 @@
/* The portal demo's stylesheet: the portal's own, then the demo's pieces in its tokens — the "Demo"
chip after the breadcrumb's path, the GitHub pill beside the page's QR knob, the scenario
chip after the breadcrumb's path, the GitHub knob before the page's language, the scenario
rows in the drawer, and the set-up state switch beside the set-up sheet's ×. */
@import '../styles/index.css';
@@ -40,20 +40,16 @@
margin-right: 0;
}
/* GitHub: a pill of the QR knob's height and fill, just before it. On a phone it would crowd out the
names (the server's and the person's): there it is a button in the drawer instead. */
/* GitHub: a knob with its mark only, as the QR knob, just before the language. On a phone it would crowd out
the names (the server's and the person's): there it is a button in the drawer instead. */
.dm-gh {
display: inline-flex;
align-items: center;
gap: 6px;
display: inline-grid;
place-items: center;
width: 32px;
height: 32px;
padding: 0 12px 0 10px;
border-radius: 999px;
border-radius: 50%;
background: var(--knob);
color: var(--text);
font-size: 14px;
font-weight: 500;
letter-spacing: -0.01em;
text-decoration: none;
flex: none;
transition:
@@ -179,18 +175,8 @@
.dm-way[aria-expanded='true'] {
background: color-mix(in srgb, var(--knob), var(--text) 10%);
}
.dm-way .i {
width: 14px;
height: 14px;
color: var(--text-2);
transform: rotate(90deg);
transition: transform 240ms var(--ease-out);
}
.dm-way[aria-expanded='true'] .i {
transform: rotate(-90deg);
}
.dm-way .dot,
.dm-way-pop .dot {
.pp-pop .dot {
width: 7px;
height: 7px;
border-radius: 50%;
@@ -200,103 +186,21 @@
opacity 150ms;
}
.dm-way .dot.warn,
.dm-way-pop .dot.warn {
.pp-pop .dot.warn {
background: var(--warn);
}
.dm-way .dot.ok,
.dm-way-pop .dot.ok {
.pp-pop .dot.ok {
background: var(--ok);
}
/* Its popup: segments in one pill frame, a step above the sheet each (white on grey in light), a tail down
to the pill, and a dark, softly blurred halo behind that fades out around it. */
.dm-way-pop {
--frame: color-mix(in srgb, var(--field), var(--knob) 55%);
--seg: color-mix(in srgb, var(--knob), var(--text) 2%);
--seg-hover: color-mix(in srgb, var(--knob), var(--text) 6%);
position: fixed;
z-index: 60;
display: flex;
gap: 3px;
padding: 3px;
border-radius: 999px;
background: var(--frame);
box-shadow: var(--pop-shadow);
}
.dm-way-pop::before {
content: '';
position: absolute;
bottom: -5px;
left: var(--tail, 50%);
width: 12px;
height: 12px;
margin-left: -6px;
border-radius: 0 0 3px 0;
background: var(--frame);
transform: rotate(45deg);
}
.dm-way-pop button {
position: relative;
display: inline-flex;
align-items: center;
gap: 6px;
height: 34px;
padding: 0 10px;
border-radius: 10px;
background: var(--seg);
color: color-mix(in srgb, var(--text-2), var(--text-3) 35%);
font-size: 12.5px;
font-weight: 500;
white-space: nowrap;
transition:
color 150ms,
background-color 150ms,
transform 150ms var(--ease-out);
}
/* The ends follow the frame: half the segment's height (a larger radius would shrink every corner). */
.dm-way-pop button:first-of-type {
border-radius: 17px 10px 10px 17px;
padding-left: 13px;
}
.dm-way-pop button:last-of-type {
border-radius: 10px 17px 17px 10px;
padding-right: 13px;
}
.dm-way-pop button:hover {
color: color-mix(in srgb, var(--text-2), var(--text) 45%);
background: var(--seg-hover);
}
.dm-way-pop button:active {
transform: scale(0.96);
}
.dm-way-pop button[aria-checked='true'] {
color: var(--text);
}
.dm-way-pop .dot {
/* The set-up state's dots in the shared popup (styles/pick.css): faint, full on the one picked or pointed at. */
.pp-pop .dot {
background: currentColor;
opacity: 0.5;
}
.dm-way-pop button[aria-checked='true'] .dot,
.dm-way-pop button:hover .dot {
.pp-pop button[aria-checked='true'] .dot,
.pp-pop button:hover .dot,
.pp-pop button.hot .dot {
opacity: 1;
}
.dm-way-halo {
position: fixed;
z-index: 59;
pointer-events: none;
background: radial-gradient(closest-side, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.35) 55%, transparent);
-webkit-backdrop-filter: blur(3px);
backdrop-filter: blur(3px);
-webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent 92%);
mask-image: radial-gradient(closest-side, #000 60%, transparent 92%);
}
@media (prefers-color-scheme: light) {
.dm-way-pop {
--frame: var(--knob);
--seg: var(--raised);
--seg-hover: color-mix(in srgb, var(--raised), var(--text) 4%);
}
.dm-way-halo {
background: radial-gradient(closest-side, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.07) 55%, transparent);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" />
<meta name="color-scheme" content="light dark" />
<meta
name="description"
+32 -121
View File
@@ -1,13 +1,14 @@
// The demo's set-up state switch: a pill beside the set-up sheet's ×, so a visitor can see each state the way
// shows (waiting, knocks that never finish, no data, connected) without a device. Its popup is a row of segments
// in one pill frame, above the pill with a tail pointing at it and a dark halo behind. Only on the set-up view:
// shows (waiting, knocks that never finish, no data, connected) without a device: a pick pill (ui/pick.ts), its
// popup above it. Only on the set-up view:
// another view in the same sheet (a question, a device's page) fades it out. Picking holds the device in that
// state on the demo's router and polls at once; Auto is the demo's own timing.
// state on the demo's router and polls at once; Auto is the demo's own timing, and where each opening starts.
import { h, ic } from '../dom';
import { EASE_IN, EASE_OUT, POP, play } from '../motion';
import { morphText, setText } from '../ui/morph';
import { h } from '../dom';
import { EASE_IN, SMOOTH, play } from '../motion';
import { pollNow } from '../flows/wait';
import { pickPill, type PickPill } from '../ui/pick';
import { onSheetChange } from '../ui/sheet';
import type { DemoWay } from './data';
import type { DemoRouter } from './router';
@@ -21,11 +22,6 @@ const PICKS: [Pick, () => string, Tone][] = [
['nodata', () => _('No data'), 'warn'],
['connected', () => _('Online'), 'ok'],
];
const pick = (p: Pick) => PICKS.find((x) => x[0] === p)!;
/** The gap between the pill and the popup above it, and how far the halo reaches out (up, sideways, down). */
const GAP = 18;
const HALO = { x: 64, up: 48, down: 14 };
/** Gone from where it stands, so one leaving while it still comes in turns back from there. */
function leave(el: Element, frames: Keyframe, ms: number) {
@@ -49,102 +45,27 @@ function leave(el: Element, frames: Keyframe, ms: number) {
export function mountWayPick(router: DemoRouter) {
/** What each device's pill says: what was picked here, else what the router holds it in. */
const shown = new Map<string, Pick>();
let pop: HTMLElement | null = null;
let halo: HTMLElement | null = null;
let anchor: HTMLElement | null = null;
function closePop() {
if (!pop) return;
leave(pop, { transform: 'scale(.96)', filter: 'blur(3px)' }, 120);
if (halo) leave(halo, {}, 160);
anchor?.setAttribute('aria-expanded', 'false');
pop = halo = anchor = null;
}
function openPop(pill: HTMLElement, id: string, paint: () => void) {
const now = shown.get(id) ?? router.wayOf(id);
const m = h(
'div',
{ class: 'dm-way-pop', role: 'menu' },
...PICKS.map(([p, label, tone]) =>
h(
'button',
{
type: 'button',
role: 'menuitemradio',
'aria-checked': String(p === now),
onclick: () => {
closePop();
shown.set(id, p);
router.holdWay(id, p);
paint();
pollNow();
},
},
h('span', { class: `dot ${tone}` }),
label(),
),
),
);
document.body.append(m);
// Centred over the pill, inside the sheet where it fits (else the screen), the tail on the pill's middle.
const r = pill.getBoundingClientRect();
const box = pill.closest('.sheet')?.getBoundingClientRect() ?? { left: 0, right: innerWidth };
const w = m.offsetWidth;
const mid = r.left + r.width / 2;
const lo = Math.max(12, box.left + 10);
const hi = Math.min(innerWidth - 12, box.right - 10);
const left = Math.max(lo, Math.min(mid - w / 2, hi - w));
const top = r.top - GAP - m.offsetHeight;
Object.assign(m.style, { left: `${left}px`, top: `${top}px`, transformOrigin: `${mid - left}px bottom` });
m.style.setProperty('--tail', `${mid - left}px`);
// The halo reaches up and out but stops short of the pill, which stays sharp.
const sc = h('div', { class: 'dm-way-halo' });
Object.assign(sc.style, {
left: `${left - HALO.x}px`,
top: `${top - HALO.up}px`,
width: `${w + HALO.x * 2}px`,
height: `${m.offsetHeight + HALO.up + HALO.down}px`,
});
m.before(sc);
play(sc, [{ opacity: 0 }, { opacity: 1 }], { duration: 220, easing: EASE_OUT });
play(
m,
[
{ opacity: 0, transform: 'scale(.9)', filter: 'blur(4px)' },
{ opacity: 1, transform: 'none', filter: 'none' },
],
{ duration: POP.duration, easing: POP.easing },
);
pop = m;
halo = sc;
anchor = pill;
pill.setAttribute('aria-expanded', 'true');
}
/** The pill on the sheet now. */
let live: PickPill<Pick> | null = null;
function makePill(id: string): HTMLElement {
const dot = h('span', { class: 'dot' });
const lbl = h('span', {});
const pill = h(
'button',
{ type: 'button', class: 'dm-way', 'aria-haspopup': 'menu', 'aria-expanded': 'false', 'aria-label': _('Set-up state') },
dot,
lbl,
ic('chevron', 'i'),
);
const paint = (morph = true) => {
const [, label, tone] = pick(shown.get(id) ?? router.wayOf(id));
dot.className = `dot ${tone}`;
if (morph) morphText(lbl, label());
else setText(lbl, label());
};
paint(false);
pill.addEventListener('click', () => (anchor === pill ? closePop() : (closePop(), openPop(pill, id, () => paint()))));
return pill;
live = pickPill<Pick>({
cls: 'dm-way',
label: () => _('Set-up state'),
options: PICKS.map(([value, label, tone]) => ({ value, label, lead: () => h('span', { class: `dot ${tone}` }) })),
value: shown.get(id) ?? router.wayOf(id),
pick: (p) => {
shown.set(id, p);
router.holdWay(id, p);
pollNow();
// Its width glides with its words (SMOOTH): the title makes room for where it ends.
setTimeout(place, SMOOTH.duration + 40);
},
});
return live.el;
}
function place() {
if (anchor && !anchor.isConnected) closePop();
const sheet = document.querySelector<HTMLElement>('.sheet-root.open .sheet');
const id = router.settingUp();
const setup = !!sheet && !!id && !!sheet.querySelector('.way') && !sheet.classList.contains('asks');
@@ -152,12 +73,18 @@ export function mountWayPick(router: DemoRouter) {
if (setup && el.parentElement === sheet && el.dataset.id === id) return;
el.classList.add('gone');
el.parentElement?.querySelectorAll<HTMLElement>('.vhead').forEach((hd) => (hd.style.paddingRight = ''));
if (anchor === el) closePop();
if (live?.el === el) {
live.close();
live = null;
}
leave(el, { transform: 'scale(.9)', filter: 'blur(3px)' }, 160);
});
if (!sheet || !setup || !id) return;
let pill = sheet.querySelector<HTMLElement>('.dm-way:not(.gone)');
if (!pill) {
// A set-up opened anew starts from the default: the demo's own timing, nothing held from the last time.
shown.delete(id);
if (router.wayOf(id) !== 'auto') router.holdWay(id, 'auto');
pill = makePill(id);
pill.dataset.id = id;
sheet.append(pill);
@@ -179,22 +106,6 @@ export function mountWayPick(router: DemoRouter) {
}
}
new MutationObserver(place).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });
document.addEventListener('pointerdown', (e) => {
const t = e.target as Element;
if (pop && !pop.contains(t) && !anchor?.contains(t)) closePop();
});
// Escape takes the popup only, not the sheet under it.
document.addEventListener(
'keydown',
(e) => {
if (!pop || e.key !== 'Escape') return;
e.stopPropagation();
closePop();
},
true,
);
// A wheel or a swipe closes it; the sheet's own scroll as it settles does not.
for (const ev of ['wheel', 'touchmove'])
addEventListener(ev, (e) => pop && !pop.contains(e.target as Node) && closePop(), { passive: true, capture: true });
// The sheet says when it changes (a view shown, the device arrived, the sheet gone): nothing to watch.
onSheetChange(place);
}