Dawnline 0.13.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

- "Internet like a home device" starts off on new servers: sending the
  tunnel through the home network costs speed. Both server wizards (the
  first one and "Add server") have the switch, and on it says what it
  costs. Servers that have it on keep it
- With it off, Server → Access says what that means: DNS still goes
  through the router, its proxies and filters see the tunnel only once its
  interface is added to their source interfaces, and sites the router's
  DNS answers with proxy addresses won't open
- With it on, established connections skip the second pass through
  netfilter in Dawnline's network namespace (a software flowtable): about
  12% less router CPU per packet, and about a quarter more speed through a
  proxy on the router. Without kmod-nft-offload the old rules load and the
  service log says so
- Its address at home stays the same when it is turned off and on again;
  it moved down by one each time (.254, .253, .252)
- Less CPU for the same work: the background agent's once-a-second look at
  the tunnels, Status, Health and the portal no longer compile the same
  patterns again for each line, address and device. At idle the agent uses
  about a quarter of the CPU it did; a portal request 5-10 ms less
- On LuCI's Bootstrap themes the admin looks as it does on Outline: cards
  and menus a step above the page, icon tiles that keep their colour,
  Outline's status colours in dark mode. The choices in Settings → Logs &
  history and Updates are LuCI's own controls in every theme
- "Add from devices at home" keeps a device's name readable in a narrow
  window: its ports go under the name
- DESIGN.md describes the portal's look, components and motion, and the
  rules send portal work there first. lint-ucode no longer ends a function
  at a brace inside a template literal
This commit is contained in:
Aemeath committed 2026-10-21 01:42:23 +03:00
1 parent db9657c01c
commit 58492be021
44 files changed
+2269 -235

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "dawnline-web",
"version": "0.12.1",
"version": "0.13.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dawnline-web",
"version": "0.12.1",
"version": "0.13.0",
"license": "MIT",
"dependencies": {
"qrcode-generator": "1.4.4"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dawnline-web",
"version": "0.12.1",
"version": "0.13.0",
"private": true,
"license": "MIT",
"type": "module",
+21 -15
View File
@@ -196,22 +196,28 @@ export function homeServices(initial: Status, serverId: string, reload: () => Pr
const wait = busy.has(h.address);
const chip = (label: string, on: boolean, click: () => void) =>
chipToggle(label, on, click, { disabled: wait ? 'disabled' : null, 'aria-busy': wait ? 'true' : null });
return E('div', { class: 'dl-row' }, [
// The name and the ports share a wrapping line: the ports go under the name before it is squeezed.
return E('div', { class: 'dl-row dl-host' }, [
icon(h.services.some((s) => s.type.startsWith('_ipp') || s.type.startsWith('_printer')) ? 'file' : 'computer'),
E('span', { class: 'dl-row-main dl-stack' }, [E('b', {}, h.name || h.address), E('span', { class: 'dl-mono dl-faint' }, h.address)]),
E('div', { class: 'dl-chips-row dl-host-ports' }, [
chip(_('All ports'), all, () => choose(h, all ? null : [])),
...portGroups(h).map(([label, ports]) => {
const on = !all && ports.every((p) => chosen.has(p));
return chip(`${label} ${ports.join(', ')}`, on, () => {
const next = new Set(all ? [] : chosen);
for (const p of ports) {
if (on) next.delete(p);
else next.add(p);
}
choose(h, next.size ? [...next] : null);
});
}),
E('div', { class: 'dl-host-body' }, [
E('span', { class: 'dl-row-main dl-stack' }, [
E('b', {}, h.name || h.address),
E('span', { class: 'dl-mono dl-faint' }, h.address),
]),
E('div', { class: 'dl-chips-row' }, [
chip(_('All ports'), all, () => choose(h, all ? null : [])),
...portGroups(h).map(([label, ports]) => {
const on = !all && ports.every((p) => chosen.has(p));
return chip(`${label} ${ports.join(', ')}`, on, () => {
const next = new Set(all ? [] : chosen);
for (const p of ports) {
if (on) next.delete(p);
else next.add(p);
}
choose(h, next.size ? [...next] : null);
});
}),
]),
]),
]);
}
+5 -10
View File
@@ -11,7 +11,7 @@ import { copyText, downloadFile } from './ui/files';
import { dropdown, type MenuItem } from './ui/menu';
import { drawer } from './ui/drawer';
import { attempt, notify } from './ui/toast';
import { liveField } from './ui/layout';
import { liveField, warnNote } from './ui/layout';
import { qrCode } from './ui/qr';
import { nameHelp } from './netcheck';
import { deviceStatus } from './ui/badges';
@@ -331,16 +331,11 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
// Whether it is connected (or still waiting) is in Status above.
E('div', { class: 'dl-dsec-head' }, [E('h4', {}, _('Connect', 'section'))]),
d.config_stale
? E('div', { class: 'dl-note warn' }, [
icon('alert'),
E(
'span',
{},
_(
'This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.',
),
? warnNote(
_(
'This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.',
),
])
)
: '',
connect,
]);
+2
View File
@@ -48,6 +48,7 @@ export const LOG_TEMPLATES: string[] = [
'The new version did not answer in LuCI or its agent did not start. Try again from Components, or install it with install.sh to see why.',
'Traffic',
'Watchdog',
'Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline.',
'a new build needs a manual switch in Components',
'answers again',
'are loaded again',
@@ -101,6 +102,7 @@ export const LOG_TEMPLATES: string[] = [
"rules for Dawnline aren't loaded",
'rules for Dawnline were changed or removed',
'runs again',
'runs without its fast path',
'setting it up again',
'started',
'started with the router · version %s',
+37 -1
View File
@@ -9,6 +9,7 @@ import { button } from './ui/button';
import { attempt, notify } from './ui/toast';
import { seg, sw } from './ui/controls';
import { attachTip } from './ui/tooltip';
import { warnNote } from './ui/layout';
import { installMissing } from './pkgs';
import { icon } from '../shared/icons';
import { fill, fmt, locale, plural } from '../shared/i18n';
@@ -31,6 +32,40 @@ const ICON: Record<NetDevice['kind'], string> = {
other: 'link',
};
/**
* "Internet like a home device" off: traffic leaves past the router's own
* proxies and filters, while DNS still goes through the router, which may
* answer with addresses only those proxies serve. Said wherever it is chosen.
*/
export function likeHomeOffText(ifname: string): (Node | string)[] {
// The step to take, in bold.
const add = E('b', {}, fill(_('add its interface %s to their source interfaces yourself'), E('span', { class: 'dl-mono' }, ifname)));
return [
...fill(
_(
'Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s.',
),
add,
),
' ',
// What breaks, not only what is missed: the one part to notice.
E('span', { class: 'dl-warn' }, _('If the router’s DNS hands out proxy addresses, those sites won’t open without it.')),
];
}
/**
* What "like a home device" costs: every packet crosses the router twice
* (through the netns and back over the LAN bridge). Measured on a dual-core
* MT7981: about 225 Mbit/s down without it, 160 with it, the CPU full either way.
*/
export function likeHomeCost(): HTMLElement {
return warnNote(
_(
'Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load.',
),
);
}
/** Server → Access cards; `update` takes a new status without touching the draft. */
export interface AccessCards {
el: HTMLElement;
@@ -170,7 +205,7 @@ export function accessCards(srv: Server, first: Status, refresh: () => Promise<u
function likeHomeText(): (Node | string)[] {
const lh = d.like_home;
if (!lanLike) return [_('Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router.')];
if (!lanLike) return likeHomeOffText(srv.ifname);
if (d.needs?.length)
return [
E('span', { class: 'dl-warn' }, fmt(_('Needs %s.'), new Intl.ListFormat(locale(), { type: 'conjunction' }).format(d.needs))),
@@ -301,6 +336,7 @@ export function accessCards(srv: Server, first: Status, refresh: () => Promise<u
}),
],
likeHomeTone(),
lanLike ? likeHomeCost() : undefined,
),
setrow(
'globe',
+2
View File
@@ -37,6 +37,8 @@ interface WidgetOptions {
sort?: boolean | string[];
create?: boolean;
multiple?: boolean;
/** Dropdown: what it shows with nothing chosen. */
select_placeholder?: string;
size?: number;
rows?: number;
cols?: number;
+37 -21
View File
@@ -12,12 +12,12 @@ import { cancelButton, closeModal, confirmDialog, modal } from '../ui/modal';
import { copyText } from '../ui/files';
import { attempt, errorText, notify } from '../ui/toast';
import { input, seg, sw } from '../ui/controls';
import { card, firstBad, group, liveRow, needRow, row } from '../ui/layout';
import { card, firstBad, group, liveRow, needRow, row, warnNote } from '../ui/layout';
import { dnsHelp, endpointProbe, hostHelp, nameHelp, portalPortHelp, portHelp, rangeHelp, rangeOf, subnetOf } from '../netcheck';
import { icon } from '../../shared/icons';
import { ago, duration } from '../../shared/format';
import { fmt, locale, plural } from '../../shared/i18n';
import { accessCards } from '../interfaces';
import { accessCards, likeHomeCost, likeHomeOffText } from '../interfaces';
import { checkAccess, whoReaches } from '../access';
import { defaultMethod, methodPicker } from '../disguise';
import { coreOf } from '../cores';
@@ -301,7 +301,7 @@ export class ServerPage {
srv.up ? part('clock', [fmt(_('up %s'), duration(srv.uptime))]) : '',
]),
// The reason the tunnel can't run at all ("can't use the network interface awg0: it exists and isn't Dawnline's").
srv.blocked ? E('div', { class: 'dl-note warn' }, [icon('alert'), E('span', {}, srv.blocked)]) : '',
srv.blocked ? warnNote(srv.blocked) : '',
]);
}
@@ -591,7 +591,8 @@ export class ServerPage {
// Off by default: the portal opens a port on WAN, so it is a choice.
portal: false,
portal_port: d.portal_port || 8443,
lan_like: true,
// Off by default: the loop through the LAN costs up to a third of the speed (likeHomeCost).
lan_like: false,
lan_zone: d.lan_zone,
wan_zone: d.wan_zone,
};
@@ -639,14 +640,7 @@ export class ServerPage {
: '';
const restartNote =
d.awg_state?.tools && d.awg_state.handler === false
? E('div', { class: 'dl-note warn' }, [
icon('alert'),
E(
'span',
{},
_('Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.'),
),
])
? warnNote(_('Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.'))
: '';
const rangeHelpNow = () => rangeHelp(state.range, d.networks ?? [], rangeOf(d.subnet));
const portalHelpNow = () => portalPortHelp(state.portal_port, d.tcp_taken ?? [], ipLinks());
@@ -662,6 +656,34 @@ export class ServerPage {
return el;
};
/** "Internet like a home device": the help follows the switch; on, the cost shows under it. */
const likeHomeGroup = (): HTMLElement => {
const cost = likeHomeCost();
const likeRow = row(
_('Through the home network'),
sw(state.lan_like, _('Internet like a home device'), (v) => {
state.lan_like = v;
paintLike();
}),
' ',
);
const paintLike = () => {
dom.content(
likeRow.querySelector('.dl-sub') as HTMLElement,
state.lan_like
? _(
'Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.',
)
: likeHomeOffText(d.ifname),
);
if (state.lan_like) likeRow.after(cost);
else cost.remove();
};
const g = group('home', _('Internet like a home device'), _('How devices reach the internet'), [likeRow]);
paintLike();
return g;
};
type Page = { id: string; title: string; render: () => Node; check?: () => string | null };
const serverPage: Page = {
id: 'server',
@@ -733,6 +755,8 @@ export class ServerPage {
group('shield', _('Disguise'), _('So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard'), [
methodPicker(d.awg, state.preset, (m) => (state.preset = m), undefined, d.awg_state?.tools !== false),
]),
// One more server has no portal step: the choice comes last here, as it does there.
extra ? likeHomeGroup() : '',
]),
check: () => {
const p = portHelpNow();
@@ -764,15 +788,7 @@ export class ServerPage {
},
);
return E('div', { class: 'dl-wizard-groups' }, [
group('home', _('Internet like a home device'), _('How devices reach the internet'), [
row(
_('Through the home network'),
sw(state.lan_like, _('Internet like a home device'), (v) => (state.lan_like = v)),
_(
'Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.',
),
),
]),
likeHomeGroup(),
group('link', _('Personal portal'), _('A page where each person adds their own devices with their personal link'), [
row(_('Portal'), onOff, _('Off: only you add devices, from LuCI. On: people manage their devices within the limits you set.')),
portRow,
+29 -34
View File
@@ -4,7 +4,7 @@ import { E } from '../../e';
import { api } from '../../api';
import { button } from '../../ui/button';
import { attempt } from '../../ui/toast';
import { chipToggle, seg, setChip } from '../../ui/controls';
import { multiSelect, select } from '../../ui/controls';
import { row } from '../../ui/layout';
import { icon } from '../../../shared/icons';
import { fmtDay, kb } from '../../../shared/format';
@@ -16,7 +16,7 @@ import { section, type SettingsHost } from './common';
export function logsCard(host: SettingsHost): HTMLElement {
const L = host.d.logs;
const p = L.policy;
const keep = seg(
const keep = select(
[
['7', plural(7, '%s day', '%s days')],
['30', plural(30, '%s day', '%s days')],
@@ -25,9 +25,9 @@ export function logsCard(host: SettingsHost): HTMLElement {
['0', _('No limit', 'retention')],
],
String(p.keep_days),
{ label: _('Keep activity'), cls: 'sm' },
_('Keep activity'),
);
const size = seg(
const size = select(
[
['500', num(500)],
['2000', num(2000)],
@@ -35,18 +35,18 @@ export function logsCard(host: SettingsHost): HTMLElement {
['20000', num(20000)],
],
String(p.max),
{ label: _('Maximum events'), cls: 'sm' },
_('Maximum events'),
);
const persist = seg(
const persist = select(
[
['10min', _('Every 10 min')],
['hourly', _('Hourly')],
['off', _('Memory only')],
],
p.persist,
{ label: _('Save to flash'), cls: 'sm' },
_('Save to flash'),
);
const days = seg(
const days = select(
[
['31', plural(1, '%s month', '%s months')],
['62', plural(2, '%s month', '%s months')],
@@ -55,9 +55,9 @@ export function logsCard(host: SettingsHost): HTMLElement {
['730', plural(2, '%s year', '%s years')],
],
String(p.usage_days),
{ label: _('Daily traffic'), cls: 'sm' },
_('Daily traffic'),
);
const months = seg(
const months = select(
[
['12', plural(1, '%s year', '%s years')],
['24', plural(2, '%s year', '%s years')],
@@ -65,24 +65,19 @@ export function logsCard(host: SettingsHost): HTMLElement {
['120', plural(10, '%s year', '%s years')],
],
String(p.usage_months),
{ label: _('Monthly traffic'), cls: 'sm' },
_('Monthly traffic'),
);
const chosen = new Set(p.categories);
const cats = E(
'div',
{ class: 'dl-chips-row' },
CATEGORIES.map((c) => {
const b = chipToggle(
[categoryLabel(c), E('b', {}, num(L.by_category[c] ?? 0))],
chosen.has(c),
() => {
if (!chosen.delete(c)) chosen.add(c);
setChip(b, chosen.has(c));
},
{ title: categoryHelp(c) },
);
return b;
}),
const cats = multiSelect(
CATEGORIES.map((c): [string, Node] => [
c,
E('span', { title: categoryHelp(c) }, [
categoryLabel(c),
' ',
E('span', { class: 'dl-faint dl-opt-note' }, num(L.by_category[c] ?? 0)),
]),
]),
p.categories,
_('Record'),
);
const since = L.oldest ? fmtDay(new Date(L.oldest * 1000)) : '';
@@ -110,7 +105,7 @@ export function logsCard(host: SettingsHost): HTMLElement {
E('p', { class: 'dl-muted' }, retentionText(p)),
row(_('Keep activity'), keep, _('Older events are removed automatically.')),
row(_('Maximum size'), size, _('Newest events are kept when the log is full.')),
row(_('Record'), cats, _('Switched-off categories are not logged from now on.')),
row(_('Record'), cats.node, _('Switched-off categories are not logged from now on.')),
row(
_('Save to flash'),
persist,
@@ -172,12 +167,12 @@ export function logsCard(host: SettingsHost): HTMLElement {
() =>
host.save(
{
log_keep_days: keep.dataset.value!,
log_max: size.dataset.value!,
log_persist: persist.dataset.value!,
usage_keep_days: days.dataset.value!,
usage_keep_months: months.dataset.value!,
log_category: [...chosen],
log_keep_days: keep.value,
log_max: size.value,
log_persist: persist.value,
usage_keep_days: days.value,
usage_keep_months: months.value,
log_category: cats.value(),
},
_('Saved'),
'logs',
+13 -23
View File
@@ -4,14 +4,14 @@
import type { UpdatePolicy } from '../../api';
import { E } from '../../e';
import { button } from '../../ui/button';
import { chipToggle, input, isOn, seg, setChip, sw } from '../../ui/controls';
import { input, isOn, multiSelect, select, sw } from '../../ui/controls';
import { row } from '../../ui/layout';
import { notify } from '../../ui/toast';
import { timeHelp } from '../../netcheck';
import { fmt } from '../../../shared/i18n';
import { section, type SettingsHost } from './common';
/** The components automatic updates may install: id and chip label. */
/** The components automatic updates may install: id and label. */
const targetChoices = (): [string, string][] => [
['app', 'Dawnline'],
['amneziawg', 'AmneziaWG'],
@@ -21,7 +21,7 @@ const targetChoices = (): [string, string][] => [
export function updatesCard(host: SettingsHost): HTMLElement {
const u = (host.d.effective as Record<string, any>).updates as UpdatePolicy;
const check = sw(u.check, _('Check automatically'), (v) => show(v, isOn(auto)));
const every = seg(
const every = select(
[
['6h', _('Every 6 h')],
['12h', _('Every 12 h')],
@@ -29,7 +29,7 @@ export function updatesCard(host: SettingsHost): HTMLElement {
['7d', _('Weekly')],
],
u.interval,
{ label: _('How often'), cls: 'sm' },
_('How often'),
);
const auto = sw(u.auto, _('Install automatically'), (v) => show(isOn(check), v));
const at = input(u.time, {
@@ -38,27 +38,17 @@ export function updatesCard(host: SettingsHost): HTMLElement {
class: 'cbi-input-text dl-w-port dl-mono',
'aria-label': _('Time'),
});
const mode = seg(
const mode = select(
[
['scheduled', _('At a set time')],
['immediate', _('As soon as found')],
],
u.mode,
{ label: _('When'), cls: 'sm', onChange: (v) => (at.hidden = v !== 'scheduled') },
_('When'),
(v) => (at.hidden = v !== 'scheduled'),
);
at.hidden = u.mode !== 'scheduled';
const chosen = new Set<string>(u.targets);
const targets = E(
'div',
{ class: 'dl-chips-row' },
targetChoices().map(([k, t]) => {
const b = chipToggle(t, chosen.has(k), () => {
if (!chosen.delete(k)) chosen.add(k);
setChip(b, chosen.has(k));
});
return b;
}),
);
const targets = multiSelect(targetChoices(), u.targets, _('Components'));
const keep = sw(u.keep, _('Keep the previous version'));
const mirrors = sw(u.mirrors, _('GitHub mirrors'));
const everyRow = row(_('How often'), every);
@@ -68,7 +58,7 @@ export function updatesCard(host: SettingsHost): HTMLElement {
E('div', { class: 'dl-hostport' }, [mode, at]),
_('A set time keeps tunnel restarts out of the evening; the run happens within an hour of it.'),
),
row(_('Components'), targets, _('AmneziaWG is off by default: a new kernel module restarts every tunnel.')),
row(_('Components'), targets.node, _('AmneziaWG is off by default: a new kernel module restarts every tunnel.')),
];
const show = (c: boolean, a: boolean) => {
everyRow.hidden = !c;
@@ -104,7 +94,7 @@ export function updatesCard(host: SettingsHost): HTMLElement {
button(
_('Save'),
() => {
if (mode.dataset.value === 'scheduled') {
if (mode.value === 'scheduled') {
const h = timeHelp(at.value);
if (h.bad) {
notify(fmt(_('Time: %s'), h.text), 'warning');
@@ -114,11 +104,11 @@ export function updatesCard(host: SettingsHost): HTMLElement {
return host.save(
{
update_check: isOn(check) ? '1' : '0',
update_interval: every.dataset.value!,
update_interval: every.value,
update_auto: isOn(auto) ? '1' : '0',
update_mode: mode.dataset.value!,
update_mode: mode.value,
update_time: at.value.trim(),
update_targets: [...chosen],
update_targets: targets.value(),
update_keep: isOn(keep) ? '1' : '0',
update_mirrors: isOn(mirrors) ? '1' : '0',
},
+8 -3
View File
@@ -2,7 +2,8 @@
/* Server → Access: networks as chips, circles, services from home, who reaches what, check access. */
.dl-chip.static { cursor: default; } .dl-chip.static:hover { background: var(--dl-soft); }
.dl-chip.static .dl-chip-name { font-weight: 500; }
.dl-setrow.head .dl-chips-row { margin-top: 8px; }
.dl-setrow.head .dl-chips-row, .dl-setrow.head .dl-note { margin-top: 8px; }
.dl-setrow.head .dl-note { margin-bottom: 0; }
.dl-setrow.head > .dl-lh-main, .dl-setrow.head > .dl-lh-main > .dl-stack { flex: 1 1 auto; min-width: 0; }
.dl-setrow.head > .dl-setrow-ctl:empty { display: none; }
.dl-setrow.head:has(> .dl-lh-main) { align-items: flex-start; }
@@ -12,8 +13,12 @@
.dl-boxrow > .dl-switch { flex: none; }
.dl-ifpick { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--dl-line); border-radius: 14px; }
.dl-iflead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dl-host-ports { justify-content: flex-end; }
@media (max-width: 760px) { .dl-host-ports { justify-content: flex-start; } }
/* A device at home: the name keeps at least 160px; past that the ports wrap under it, lined up with it,
and on one line the name's growth pushes them to the right. The icon sits centred on name and address (20 + 2 + 20px). */
.dl-host { align-items: flex-start; }
.dl-host > .dl-icon-wrap { margin-top: 13px; }
.dl-host-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dl-host-body > .dl-row-main { flex: 1 1 160px; }
.dl-circle-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dl-circles .dl-chip b { font-weight: 500; }
.dl-circle-name { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
+24 -12
View File
@@ -1,33 +1,45 @@
/* Tokens (Outline first, LuCI Bootstrap next, a fallback that works anywhere), pills, cards, activity rows. */
:root {
/* Outline's tokens first, then LuCI Bootstrap's, then something that works anywhere. */
/* Outline's tokens first, then LuCI Bootstrap's, then Outline's own values (light here, dark below).
Washes mix the theme's text colour, not currentColor: on muted text (icon tiles) currentColor fades them out. */
--dl-card: var(--panel-bg, var(--background-color-high, transparent));
--dl-elevated: var(--elevated, var(--background-color-high, Canvas));
--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));
--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));
--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));
--dl-fg: var(--foreground, var(--text-color-highest, inherit));
--dl-fg: var(--foreground, var(--text-color-highest, currentColor));
--dl-soft: var(--muted, color-mix(in srgb, var(--dl-fg) 5%, transparent));
--dl-soft-hover: var(--soft-hover, color-mix(in srgb, var(--dl-fg) 10%, transparent));
--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));
--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));
--dl-accent: var(--accent, #3a83f7);
--dl-ok: var(--success, #00a240);
--dl-warn: var(--warning, #e25507);
--dl-bad: var(--danger, #e02e2a);
--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));
--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));
--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));
--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));
--dl-info: var(--info, #2c67c5);
--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));
--dl-ok-wash: var(--success-a15, color-mix(in srgb, var(--dl-ok) 15%, transparent));
--dl-warn-wash: var(--warning-a15, color-mix(in srgb, var(--dl-warn) 15%, transparent));
--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, var(--dl-bad) 15%, transparent));
--dl-info-wash: var(--info-a15, color-mix(in srgb, var(--dl-info) 15%, transparent));
--dl-track: var(--foreground-a10, color-mix(in srgb, var(--dl-fg) 10%, transparent));
--dl-chart-1: var(--chart-blue, #3a83f7);
--dl-chart-2: var(--chart-green, #00a240);
--dl-chart-2: var(--chart-green, var(--dl-ok));
--dl-ring: var(--ring, #3a83f7);
--dl-primary: var(--primary, #0d0d0d);
--dl-primary-fg: var(--primary-foreground, #fff);
--dl-primary: var(--primary, var(--dl-fg));
--dl-primary-fg: var(--primary-foreground, var(--dl-elevated));
--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
--dl-shadow: var(--shadow-sm, none);
--dl-radius: 16px;
}
/* Bootstrap's page is its --background-color-high: in dark mode cards and popovers sit one step lighter, as on Outline. */
:root[data-darkmode="true"] {
--dl-card: var(--panel-bg, var(--background-color-low, transparent));
--dl-elevated: var(--elevated, var(--background-color-low, Canvas));
--dl-accent: var(--accent, #006efe);
--dl-ok: var(--success, #40c977);
--dl-warn: var(--warning, #ff8549);
--dl-bad: var(--danger, #ff6764);
--dl-info: var(--info, #5ba2fe);
--dl-ring: var(--ring, #5ba2febc);
}
/* Text is read, not edited: the arrow over it, the I-beam only where you type. */
.dl-root, .dl-modal { cursor: default; }
+2
View File
@@ -59,6 +59,8 @@
.dl-w-ip { width: 160px; }
.dl-dnspick { padding-top: 8px; border-top: 1px solid var(--dl-line); }
.dl-dnspick .dl-row-actions { gap: 10px; }
/* A note on a LuCI dropdown's option (a count): in the open list only, not in the closed box. */
.cbi-dropdown > ul:not(.dropdown) .dl-opt-note { display: none; }
.dl-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 18px; margin: 0 0 10px; background: var(--dl-soft); }
.dl-note.warn { background: var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent)); }
.dl-note .dl-icon { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--dl-warn); }
+2 -1
View File
@@ -2,7 +2,8 @@
// (luci-theme-outline: --panel-bg, --border, --muted, --accent, --success-a15,
// …). Every token has a fallback so other themes still get a sane look.
// Outline switches dark mode with html[data-darkmode], and its tokens follow
// it automatically, so nothing here needs a dark variant.
// it automatically; only the fallbacks in base.css have a dark variant (LuCI
// Bootstrap sets the same attribute).
//
// One file per feature, imported as text (tsup minifies them, see
// tsup.config.ts) and joined in cascade order: later files override earlier ones.
+4 -2
View File
@@ -13,12 +13,14 @@
.dl-group-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--dl-soft); color: var(--dl-fg-muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.dl-group-ic .dl-icon-wrap { display: inline-flex; } .dl-group-ic .dl-icon { width: 16px; height: 16px; }
.dl-group-body > * { padding: 12px 0; margin: 0 !important; }
.dl-group-body > * + *:not(.alert-message):not(.dl-params) { border-top: 1px solid var(--dl-line); }
.dl-group-body > * + *:not(.alert-message):not(.dl-params):not(.dl-note) { border-top: 1px solid var(--dl-line); }
/* Boxed pieces (a notice, a parameters panel) keep their own padding and frame: spaced, not ruled. */
.dl-group-body > .alert-message, .dl-group-body > .dl-params { margin: 12px 0 !important; }
.dl-group-body > .alert-message { padding: 10px 14px; }
.dl-group-body > .dl-params { padding: 0; }
.dl-group-body > .alert-message + *, .dl-group-body > .dl-params + * { border-top: 0; }
/* A warning note belongs to the row above it: no gap before, room to the group's edge after. */
.dl-group-body > .dl-note { margin: 0 0 14px !important; padding: 10px 12px; }
.dl-group-body > .alert-message + *, .dl-group-body > .dl-params + *, .dl-group-body > .dl-note + * { border-top: 0; }
.dl-group-body > .dl-row { border-left: 0; border-right: 0; border-bottom: 0; padding-left: 0; padding-right: 0; background: none; }
.dl-group-body > .dl-row:first-child { border-top: 0; }
.dl-setsec-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 20px; border-top: 1px solid var(--dl-line); background: var(--dl-soft); }
+30 -1
View File
@@ -1,5 +1,5 @@
// Form controls in the house style: a switch, a segmented control, a chip
// toggle and a text input.
// toggle and a text input; LuCI's own select and multi-select for settings.
import { E } from '../e';
@@ -113,6 +113,35 @@ export function setChip(b: HTMLElement, on: boolean) {
b.setAttribute('aria-pressed', on ? 'true' : 'false');
}
/**
* Single choice as LuCI's select (a ListValue's widget); the choice is `.value`.
* Unknown values get an option of their own, so nothing is lost on save.
*/
export function select<T extends string>(options: [T, string][], value: T, label: string, onChange?: (v: T) => void): HTMLSelectElement {
if (!options.some(([v]) => v === value)) options = [...options, [value, value]];
return E(
'select',
{ class: 'cbi-input-select', 'aria-label': label, change: (ev: Event) => onChange?.((ev.target as HTMLSelectElement).value as T) },
options.map(([v, t]) => E('option', { value: v, selected: v === value ? 'selected' : null }, t)),
) as HTMLSelectElement;
}
/** Several choices as LuCI's multi-select dropdown (a MultiValue's widget): `node` to show, `value()` to save. */
export function multiSelect(
options: [string, Node | string][],
values: string[],
label: string,
): { node: HTMLElement; value: () => string[] } {
const w = new ui.Dropdown(values, Object.fromEntries(options), {
multiple: true,
sort: options.map(([v]) => v),
select_placeholder: _('None'),
});
const node = w.render() as HTMLElement;
node.setAttribute('aria-label', label);
return { node, value: () => w.getValue() as string[] };
}
export function input(value: string, attrs: Record<string, unknown> = {}): HTMLInputElement {
return E('input', { type: 'text', class: 'cbi-input-text', value, ...attrs }) as HTMLInputElement;
}
+7 -2
View File
@@ -1,12 +1,12 @@
// Layout pieces: a labelled setting row, a settings card, a titled group, a
// "missing package" row, LuCI's callout and an SVG holder.
// "missing package" row, a warning note, LuCI's callout and an SVG holder.
import type { Child } from '../luci.d';
import { E } from '../e';
import { icon } from '../../shared/icons';
/** Label and help on the left, the control on the right. */
export function row(label: string, control: Node, help?: string): HTMLElement {
export function row(label: string, control: Node, help?: Child): HTMLElement {
return E('div', { class: 'dl-setrow' }, [
E('div', { class: 'dl-stack' }, [E('span', { class: 'dl-setrow-label' }, label), help ? E('span', { class: 'dl-sub' }, help) : '']),
E('div', { class: 'dl-setrow-ctl' }, control),
@@ -117,6 +117,11 @@ export function needRow(ic: string, tone: '' | 'bad' | 'warn', title: string, su
]);
}
/** A warning beside the choice it is about: alert icon and text on an orange wash. */
export function warnNote(text: Child): HTMLElement {
return E('div', { class: 'dl-note warn' }, [icon('alert'), E('span', {}, text)]);
}
export function callout(tone: 'ok' | 'warn' | 'error' | 'info', children: Child): HTMLElement {
const cls = { ok: 'success', warn: 'warning', error: 'error', info: 'notice' }[tone];
return E('div', { class: `alert-message ${cls}` }, children);