Dawnline 0.16.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
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 personal page loads faster and costs the router less: its script and styles come compressed, stay in the browser until the next update, and the icon comes with the page instead of a request of its own - The page uses the system's own font (SF Pro on Apple devices, Segoe UI on Windows, Roboto on Android) instead of downloading one - The top of the page shows the server's name alone, so it fits on a phone - Text can be selected only where it is there to be copied (addresses, file names, the configuration), with the name field's own selection: a soft highlight with handles that glides after the pointer - Sheets scroll without a scrollbar - Red buttons (Remove) light up under the pointer, as the others do - Demo: "Demo" and GitHub are one button; on a phone it floats at the bottom of the screen, and switching scenarios no longer makes the edge fades jump
This commit is contained in:
1 parent
750564ab7e
commit
2388603322
91 files changed
+2564
-1027
No files matched your search
@@ -1,40 +1,71 @@
|
||||
// What the demo adds to the breadcrumb: the scenario chip right after the path,
|
||||
// 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 says when (onCrumbs), so both go back in
|
||||
// place after each redraw; a language change makes both again in it.
|
||||
// What the demo adds to the page: "Demo" (it opens the scenarios) and a link to
|
||||
// GitHub, one split pill. Wide, the pill stands in the breadcrumb just before the
|
||||
// page's language. On a phone the breadcrumb has no room for it, so it is a dock
|
||||
// of its own at the bottom right, in <body>, outside the page: the page's
|
||||
// entrance and a scenario's swap move the page with a transform and a filter,
|
||||
// which would carry a fixed child along and leave its glass undrawn until they
|
||||
// end. Over a card alone (no language) only the chip, right after the place, and
|
||||
// no dock. The portal redraws the breadcrumb with the page and says when
|
||||
// (onCrumbs), so the pill goes back in place after each redraw; a language
|
||||
// change makes all of it again in it.
|
||||
|
||||
import { h, ic } from '../dom';
|
||||
import { onLang } from '../i18n';
|
||||
import { EASE_OUT, play } from '../motion';
|
||||
import { onCrumbs } from '../page/frame';
|
||||
import { REPO } from './data';
|
||||
import { scenarioChip } from './picker';
|
||||
import { scenarioPicker } from './picker';
|
||||
import type { DemoRouter } from './router';
|
||||
|
||||
export function mountCrumbs(router: DemoRouter) {
|
||||
const app = document.getElementById('app')!;
|
||||
const open = scenarioPicker(router);
|
||||
const demo = (cls: string) =>
|
||||
h('button', { type: 'button', class: cls, 'aria-haspopup': 'dialog', onclick: open }, h('span', {}, _('Demo')), ic('chevron', 'i'));
|
||||
const github = (cls: string) =>
|
||||
h('a', { class: cls, href: REPO, target: '_blank', rel: 'noopener', 'aria-label': _('Dawnline on GitHub') }, ic('github'));
|
||||
const make = () => ({
|
||||
chip: scenarioChip(router),
|
||||
gh: h('a', { class: 'dm-gh', href: REPO, target: '_blank', rel: 'noopener', 'aria-label': _('Dawnline on GitHub') }, ic('github')),
|
||||
chip: demo('dm-chip'),
|
||||
gh: github('dm-gh'),
|
||||
dock: h('div', { class: 'dm-dock' }, demo('dm-dock-demo'), github('dm-dock-gh')),
|
||||
});
|
||||
let { chip, gh } = make();
|
||||
let { chip, gh, dock } = make();
|
||||
let first = true;
|
||||
const keep = () => {
|
||||
const crumbs = app.querySelector('.crumbs');
|
||||
const path = crumbs?.querySelector('.cr-path');
|
||||
if (!crumbs || !path) return;
|
||||
if (path.nextElementSibling !== chip) path.after(chip);
|
||||
const lang = crumbs.querySelector('.cr-lang');
|
||||
if (lang && lang.previousElementSibling !== gh) lang.before(gh);
|
||||
chip.classList.toggle('split', !!lang);
|
||||
if (!lang) {
|
||||
gh.remove();
|
||||
dock.remove();
|
||||
if (path.nextElementSibling !== chip) path.after(chip);
|
||||
return;
|
||||
}
|
||||
if (lang.previousElementSibling !== gh || gh.previousElementSibling !== chip) lang.before(chip, gh);
|
||||
if (dock.isConnected) return;
|
||||
document.body.append(dock);
|
||||
// It rises from under the screen's edge (with the page's first wave, the first time), on a transform alone:
|
||||
// Safari leaves a backdrop blur undrawn while the element's opacity is animating, and it would pop in at the end.
|
||||
play(dock, [{ transform: 'translateY(calc(100% + 64px))' }, { transform: 'none' }], {
|
||||
duration: 620,
|
||||
delay: first ? 260 : 0,
|
||||
easing: EASE_OUT,
|
||||
fill: 'backwards',
|
||||
});
|
||||
first = false;
|
||||
};
|
||||
// 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(() => {
|
||||
const was = dock;
|
||||
chip.remove();
|
||||
gh.remove();
|
||||
({ chip, gh } = make());
|
||||
({ chip, gh, dock } = make());
|
||||
if (was.isConnected) was.replaceWith(dock);
|
||||
keep();
|
||||
});
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
import type { State } from '../state';
|
||||
import type { Device, Kind, Pair, Person } from '../../shared/types';
|
||||
|
||||
export const GB = 2 ** 30;
|
||||
const GB = 2 ** 30;
|
||||
const HOUR = 3600;
|
||||
const DAY = 86400;
|
||||
|
||||
@@ -94,14 +94,14 @@ export function seedDevices(s: ScenarioId, t: number, id: () => string): DemoDev
|
||||
}
|
||||
|
||||
/** The person's state in the scenario: the four the admin's limits stop them in, else active. */
|
||||
export function personState(s: ScenarioId): Person['state'] {
|
||||
function personState(s: ScenarioId): Person['state'] {
|
||||
return s === 'quota' || s === 'hours' || s === 'paused' || s === 'expired' ? s : 'active';
|
||||
}
|
||||
export const locked = (s: ScenarioId) => s === 'paused' || s === 'expired';
|
||||
const locked = (s: ScenarioId) => s === 'paused' || s === 'expired';
|
||||
export const deviceLimit = (s: ScenarioId) => (s === 'full' ? 3 : 4);
|
||||
|
||||
/** The local day (YYYY-MM-DD) of a time: in the demo, the visitor's clock is the router's. */
|
||||
export function isoDay(t: number): string {
|
||||
function isoDay(t: number): string {
|
||||
const d = new Date(t * 1000);
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
/* 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 knob before the page's language, the scenario
|
||||
rows in the drawer, and the set-up state switch beside the set-up sheet's ×. */
|
||||
/* The portal demo's stylesheet: the portal's own, then the demo's pieces in its tokens — "Demo" and GitHub as
|
||||
one split pill before the page's language (on a phone a dock at the bottom), the scenario rows in the drawer,
|
||||
and the set-up state switch beside the set-up sheet's ×. */
|
||||
@import '../styles/index.css';
|
||||
|
||||
/* The path keeps its width so the chip sits right after it; the page's QR stays at the end. */
|
||||
.cr-path {
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
/* "Demo" and GitHub, one split pill just before the page's language: as high as the knobs beside it, the halves
|
||||
2px apart, their inner corners 4px (the outer ones half the height: 999px would scale every radius of a half
|
||||
down to nothing). Over a card alone the chip stands by itself after the place, 26px and round. */
|
||||
.dm-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 26px;
|
||||
padding: 0 8px 0 10px;
|
||||
margin-right: auto;
|
||||
border-radius: 999px;
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
@@ -24,53 +22,117 @@
|
||||
transform 150ms var(--ease-out),
|
||||
background-color 150ms;
|
||||
}
|
||||
.dm-chip:hover {
|
||||
background: color-mix(in srgb, var(--accent) 20%, transparent);
|
||||
}
|
||||
.dm-chip:active {
|
||||
transform: scale(0.94);
|
||||
.dm-chip.split {
|
||||
height: 32px;
|
||||
padding: 0 10px 0 14px;
|
||||
border-radius: 16px 4px 4px 16px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.dm-chip .i {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
/* A card alone (paused): the breadcrumb is centred, the chip with it. */
|
||||
.page.single .dm-chip {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* 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-grid;
|
||||
place-items: center;
|
||||
width: 32px;
|
||||
width: 38px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background: var(--knob);
|
||||
color: var(--text);
|
||||
margin-left: -8px;
|
||||
padding-right: 2px;
|
||||
border-radius: 4px 16px 16px 4px;
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
flex: none;
|
||||
transition:
|
||||
transform 150ms var(--ease-out),
|
||||
background-color 150ms;
|
||||
}
|
||||
.dm-gh:hover {
|
||||
background: color-mix(in srgb, var(--knob), var(--text) 6%);
|
||||
}
|
||||
.dm-gh:active {
|
||||
transform: scale(0.94);
|
||||
}
|
||||
.dm-gh .i {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
@media (max-width: 479px) {
|
||||
/* Pointed at with a mouse only: a tap would leave it lit. */
|
||||
@media (hover: hover) {
|
||||
.dm-chip:hover,
|
||||
.dm-gh:hover {
|
||||
background: color-mix(in srgb, var(--accent) 20%, transparent);
|
||||
}
|
||||
}
|
||||
.dm-chip:active,
|
||||
.dm-gh:active {
|
||||
transform: scale(0.94);
|
||||
}
|
||||
|
||||
/* On a phone the breadcrumb has no room for the pill: it is the dock instead (crumbs.ts), in <body> at the bottom
|
||||
right, over the bottom fade and under the sheets; glass, 36px, the halves as in the breadcrumb. */
|
||||
@media (max-width: 559px) {
|
||||
.dm-chip.split,
|
||||
.dm-gh {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.dm-dock {
|
||||
position: fixed;
|
||||
z-index: 40;
|
||||
right: max(16px, env(safe-area-inset-right, 0px));
|
||||
bottom: calc(20px + env(safe-area-inset-bottom, 0px));
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
}
|
||||
@media (min-width: 560px) {
|
||||
.dm-dock {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.dm-dock > * {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 36px;
|
||||
color: var(--accent);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
text-decoration: none;
|
||||
background: var(--glass-bg);
|
||||
-webkit-backdrop-filter: blur(28px) saturate(1.8);
|
||||
backdrop-filter: blur(28px) saturate(1.8);
|
||||
box-shadow:
|
||||
inset 0 0 0 1px var(--glass-edge),
|
||||
var(--glass-shadow);
|
||||
transition: transform 150ms var(--ease-out);
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.dm-dock-demo {
|
||||
gap: 4px;
|
||||
padding: 0 10px 0 14px;
|
||||
border-radius: 18px 5px 5px 18px;
|
||||
}
|
||||
.dm-dock-demo .i {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
.dm-dock-gh {
|
||||
width: 40px;
|
||||
border-radius: 5px 18px 18px 5px;
|
||||
}
|
||||
.dm-dock-gh .i {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
/* A film over the glass, never in place of it. */
|
||||
@media (hover: hover) {
|
||||
.dm-dock > *:hover {
|
||||
background:
|
||||
linear-gradient(color-mix(in srgb, var(--text) 7%, transparent), color-mix(in srgb, var(--text) 7%, transparent)), var(--glass-bg);
|
||||
}
|
||||
}
|
||||
.dm-dock > *:active {
|
||||
transform: scale(0.94);
|
||||
}
|
||||
|
||||
/* The drawer: groups of rows that touch, one step lighter than the sheet, the current one in the accent. */
|
||||
.dm-group {
|
||||
@@ -132,7 +194,7 @@
|
||||
flex: none;
|
||||
}
|
||||
|
||||
/* The drawer's foot: Start over, and on a phone GitHub beside it. */
|
||||
/* The drawer's foot: Start over. */
|
||||
.dm-foot {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
@@ -140,12 +202,6 @@
|
||||
.dm-foot .btn {
|
||||
flex: 1;
|
||||
}
|
||||
@media (min-width: 480px) {
|
||||
.dm-gh-alt {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* The set-up state switch: a pill beside ×, gliding into its place when the device arrives. */
|
||||
.dm-way {
|
||||
position: absolute;
|
||||
|
||||
@@ -26,7 +26,7 @@ msgstr ""
|
||||
msgid "Dawnline on GitHub"
|
||||
msgstr ""
|
||||
|
||||
#: web/src/portal/demo/picker.ts
|
||||
#: web/src/portal/demo/crumbs.ts
|
||||
msgid "Demo"
|
||||
msgstr ""
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ msgstr "Авто"
|
||||
msgid "Dawnline on GitHub"
|
||||
msgstr "Dawnline на GitHub"
|
||||
|
||||
#: web/src/portal/demo/picker.ts
|
||||
#: web/src/portal/demo/crumbs.ts
|
||||
msgid "Demo"
|
||||
msgstr "Демо"
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// The demo's scenario picker: the "Demo" chip, opening a drawer with the
|
||||
// scenarios in groups (glass icon, name, what the page shows) and "Start over".
|
||||
// Picking one swaps the page in place. Built only from the portal's own parts
|
||||
// (sheet, glass icons, toast, motion); where the chip sits is crumbs.ts. On a
|
||||
// phone the drawer's foot also links to GitHub, the breadcrumb having no room.
|
||||
// The demo's scenario picker: a drawer with the scenarios in groups (glass
|
||||
// icon, name, what the page shows) and "Start over". Picking one swaps the page
|
||||
// in place. Built only from the portal's own parts (sheet, glass icons, toast,
|
||||
// motion); the "Demo" buttons that open it, and where they sit, are crumbs.ts.
|
||||
|
||||
import { h, ic } from '../dom';
|
||||
import { call } from '../api';
|
||||
@@ -11,7 +10,7 @@ import { closeSheet, head, onSheetEntry, openSheet, sub, type View } from '../ui
|
||||
import { glass, type Tone } from '../ui/glass';
|
||||
import { toast } from '../ui/feedback';
|
||||
import { EASE_OUT, play } from '../motion';
|
||||
import { REPO, groups, type Scenario, type ScenarioId } from './data';
|
||||
import { groups, type Scenario, type ScenarioId } from './data';
|
||||
import type { DemoRouter } from './router';
|
||||
|
||||
/** Each scenario's glass icon and tone (the glass set is smaller than the line icons). */
|
||||
@@ -28,8 +27,8 @@ const LOOK: Record<ScenarioId, [string, Tone]> = {
|
||||
full: ['phone', 'grey'],
|
||||
};
|
||||
|
||||
/** The chip that opens the scenarios. */
|
||||
export function scenarioChip(router: DemoRouter): HTMLElement {
|
||||
/** What opens the scenarios' drawer. */
|
||||
export function scenarioPicker(router: DemoRouter): () => void {
|
||||
const app = document.getElementById('app')!;
|
||||
|
||||
/** Swap the page in place: it dims away and comes back drawn from the scenario, the link saying which. */
|
||||
@@ -44,14 +43,16 @@ export function scenarioChip(router: DemoRouter): HTMLElement {
|
||||
else mark();
|
||||
closeSheet();
|
||||
router.use(s);
|
||||
const out = play(app, [{ opacity: 1 }, { opacity: 0, filter: 'blur(4px)' }], { duration: 160, easing: EASE_OUT, fill: 'forwards' });
|
||||
// The page, not #app: a filter or a transform on #app would carry its fixed edge fades along until it ends.
|
||||
const page = app.querySelector<HTMLElement>('.page') ?? app;
|
||||
const out = play(page, [{ opacity: 1 }, { opacity: 0, filter: 'blur(4px)' }], { duration: 160, easing: EASE_OUT, fill: 'forwards' });
|
||||
const st = await call<State>('state');
|
||||
await out.finished;
|
||||
setState(st);
|
||||
repaint();
|
||||
out.cancel();
|
||||
play(
|
||||
app,
|
||||
page,
|
||||
[
|
||||
{ opacity: 0, filter: 'blur(4px)', transform: 'translateY(6px)' },
|
||||
{ opacity: 1, filter: 'none', transform: 'none' },
|
||||
@@ -94,16 +95,10 @@ export function scenarioChip(router: DemoRouter): HTMLElement {
|
||||
ic('reset'),
|
||||
h('span', {}, _('Start over')),
|
||||
),
|
||||
h('a', { class: 'btn soft dm-gh-alt', href: REPO, target: '_blank', rel: 'noopener' }, ic('github'), h('span', {}, 'GitHub')),
|
||||
),
|
||||
);
|
||||
return { el, label: _('Try a scenario') };
|
||||
}
|
||||
|
||||
return h(
|
||||
'button',
|
||||
{ type: 'button', class: 'dm-chip', 'aria-haspopup': 'dialog', onclick: () => openSheet(scenarios) },
|
||||
h('span', {}, _('Demo')),
|
||||
ic('chevron', 'i'),
|
||||
);
|
||||
return () => openSheet(scenarios);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export interface RouterOpts {
|
||||
}
|
||||
|
||||
/** A settings sheet waits for the first connection: it comes this long after the settings are shown. */
|
||||
export const CONNECT_AFTER = [6, 9];
|
||||
const CONNECT_AFTER = [6, 9];
|
||||
|
||||
class Refusal {
|
||||
constructor(
|
||||
|
||||
Reference in new issue
Block a user