Dawnline 0.12.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 portal's traffic charts show what came down and what went up apart.
  A device's last 7 days and "Data this month" draw each day both ways:
  downloads rise above a thin line, uploads hang below it, on one scale.
  Beside them "↓ 3.2 GB ↑ 557 MB" instead of one total; hover a day for
  its own, its date where "left" stands
- Charts answer the pointer between their bars too, in the portal and in
  the admin's daily charts (a device's week, a device card's 30 days, the
  last 30 days): the figures no longer blink back to the total
- The calendar under "Access until" plays its days in only when the row is
  opened, not again each time the page refreshes with it open
- On a phone the page comes in from the top down: "Your access" first,
  then the devices
- "Show key" on a router's set-up morphs to "Hide key" with its icon, and
  brings the keys themselves into focus (it blurred the field names)
This commit is contained in:
Aemeath committed 2026-10-20 20:58:36 +03:00
1 parent 2f2aaf6c34
commit fb73ac3a9f
33 files changed
+396 -199

No files matched your search

+5 -2
View File
@@ -2,7 +2,9 @@
// closed and share their rounded ends; an open row lifts out with 10 px gaps
// and its own corners. One row open at a time. A row with nothing to open is a
// plain head: no chevron, no click. Inside the sheet it tells the sheet first,
// so a code that comes into view gets its width.
// so a code that comes into view gets its width. A row the person opens is
// `.opened` until it closes: what enters inside it (the calendar's days) keys on
// that, so a repaint that rebuilds the row open doesn't play it again.
import { h, ic } from '../dom';
import { EASE_IN, SOFT, play } from '../motion';
@@ -98,9 +100,10 @@ export function accordion(
const closing = rows.filter((x) => x.classList.contains('open') && (x === r || willOpen));
rows.forEach((x) => {
x.classList.remove('closing');
if (x !== r) x.classList.remove('open');
if (x !== r) x.classList.remove('open', 'opened');
});
r.classList.toggle('open', willOpen);
r.classList.toggle('opened', willOpen);
corners();
const plan = planWidth();
rows.forEach((x, i) => {
+79
View File
@@ -0,0 +1,79 @@
// Traffic by day, both ways: what a device received rises above a hairline and
// what it sent hangs below, on one scale, so a day of uploads shows as itself
// rather than as a cap on the downloads. The hairline sits where the two
// directions' peaks share the height. Beside the bars, "↓ 3.9 GB ↑ 819 MB".
// A day is the router's [rx, tx]: rx came from the device (its upload), tx went
// to it (its download).
import type { Pair } from '../../shared/types';
import { bytes } from '../../shared/format';
import { h, ic } from '../dom';
import { setText } from './morph';
/** Between the halves, the hairline in the middle of it. */
const GAP = 3;
/** Days added up: what came and what went over all of them. */
export const sumDays = (days: Pair[]): Pair => days.reduce<Pair>((a, [rx, tx]) => [a[0] + rx, a[1] + tx], [0, 0]);
/**
* Where the hairline sits and how many px a byte is: each direction's peak gets
* its share of the height, the downloads keeping 55–80% of it, so a quiet
* upload still shows and a busy one does not flatten the rest.
*/
export function mirror(days: Pair[], height: number): { top: number; bottom: number; scale: number } {
const down = Math.max(1, ...days.map((d) => d[1]));
const up = Math.max(1, ...days.map((d) => d[0]));
const top = Math.round((height - GAP) * Math.min(0.8, Math.max(0.55, down / (down + up))));
const bottom = height - GAP - top;
return { top, bottom, scale: Math.min(top / down, bottom / up) };
}
export interface Bars {
el: HTMLElement;
/** A column a day, for what the pointer reads off them. */
cols: HTMLElement[];
}
/** A column a day, today last (in accent); `future`: the days still to come, flat on the hairline. */
export function bars(days: Pair[], cls: string, height: number, future = 0): Bars {
const { top, bottom, scale } = mirror(days, height);
const half = (side: string, px: number, v: number, what: string) => {
const bar = h('i', { class: what });
bar.style.height = `${Math.max(2, Math.round(v * scale))}px`;
const el = h('div', { class: `half ${side}` }, bar);
el.style.height = `${px}px`;
return el;
};
const el = h('div', { class: `bars ${cls}`, 'aria-hidden': 'true' });
el.style.height = `${height}px`;
const cols = days.map(([rx, tx], i) =>
el.appendChild(
h('div', { class: `col${i === days.length - 1 ? ' today' : ''}` }, half('top', top, tx, 'dn'), half('bottom', bottom, rx, 'up')),
),
);
for (let i = 0; i < future; i++) el.appendChild(h('div', { class: 'col future' }, h('i'))).style.paddingTop = `${top - 2}px`;
el.appendChild(h('span', { class: 'axis' })).style.top = `${top + 1}px`;
return { el, cols };
}
export interface UpDown {
el: HTMLElement;
/** Show these, at once (a repaint morphs them by their keys). */
set(day: Pair): void;
}
/** "↓ 3.9 GB ↑ 819 MB"; `key` names the two numbers for the repaint's morph. */
export function upDown(key: string): UpDown {
const side = (cls: string, name: string, num: HTMLElement) =>
h('span', { class: cls, title: name }, ic('arrow'), h('span', { class: 'offscreen' }, name), num);
const dn = h('span', { class: 'num', 'data-t': `${key}:dn` });
const up = h('span', { class: 'num', 'data-t': `${key}:up` });
return {
el: h('span', { class: 'ud' }, side('ud-dn', _('Downloaded'), dn), side('ud-up', _('Uploaded'), up)),
set([rx, tx]) {
setText(dn, bytes(tx));
setText(up, bytes(rx));
},
};
}
+19 -16
View File
@@ -41,6 +41,24 @@ export function toast(msg: string, bad = false) {
}, 2400);
}
/** An icon that changes in place: the new one pops in where the old one stood. */
export function swapIcon(icon: Element, name: string): Element {
const next = ic(name, icon.getAttribute('class') ?? 'i');
icon.replaceWith(next);
play(
next,
[
{ opacity: 0, transform: 'scale(.6)', filter: 'blur(3px)' },
{ opacity: 1, transform: 'none', filter: 'none' },
],
{
duration: POP.duration,
easing: POP.easing,
},
);
return next;
}
/**
* The control that copied says so for a moment: its icon turns into a check
* and its "Copy…" label (`.lbl`, a badge's main line) into "Copied". Every
@@ -53,22 +71,7 @@ function copied(from: Element) {
const label = from.querySelector<HTMLElement>('.lbl, .b-main');
const was = label ? textOf(label) : '';
from.classList.add('copied');
let check: Element | null = null;
if (icon) {
check = ic('check', icon.getAttribute('class') ?? 'i');
icon.replaceWith(check);
play(
check,
[
{ opacity: 0, transform: 'scale(.6)', filter: 'blur(3px)' },
{ opacity: 1, transform: 'none', filter: 'none' },
],
{
duration: POP.duration,
easing: POP.easing,
},
);
}
const check = icon ? swapIcon(icon, 'check') : null;
if (label) morphText(label, _('Copied'));
setTimeout(() => {
if (check && icon) check.replaceWith(icon);