Compare commits

...
Author SHA1 Message Date
kristianwindandClaude Opus 4.8 8a2c46f5ea fix(notes): show the note on a phone — one pane at a time
On a phone the note list and the editor stacked in one column, so a tapped
note opened below a full-height list, out of sight — "kan vælge en note men
kan ikke se indholdet". Now it is master-detail: the list fills the screen
until a note is opened, the editor takes over once one is, and an iOS-style
"‹ Noter" at the top of the editor goes back. The cards drop their border
and corners on one column, where there is nothing beside them.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-03 19:07:02 +02:00
Kristian Wind 8d42f34065 Merge pull request #50 from kristianwind/charcoal-apple-colors
CI / OpenAPI is valid (push) Successful in 9s
CI / End-to-end (push) Successful in 8m47s
CI / Docker image builds (push) Successful in 1m48s
Release / Build and publish image (push) Failing after 6s
CI / Go (push) Failing after 14m30s
Match Charcoal theme to Apple Notes' exact colours
2026-09-03 17:51:16 +02:00
kristianwindandClaude Opus 4.8 905ceebc06 fix(theme): match Charcoal to Apple Notes' sampled colours
Kristian sent the exact values; the first Charcoal was a neutral grey guess
and missed them. Now: three panel greys, lightest sidebar (#2d3133) to
darkest editor (#1e1e1e) with the list (#242b2e) between — the reverse of
the usual sunken-is-darkest order, so the editor takes its own --editor-bg
rather than sharing the list's surface. The accent is amber: the selected
menu item is solid #ffce35 with dark text, a selected note is gold #a78c26
with dark text, and the section headings drop to a quiet grey (#8a8e90).

Each per-element colour is a fallback token only Charcoal sets, so every
other theme reads through to the shared token unchanged. Verified the
computed values land on Kristian's samples exactly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-03 17:42:55 +02:00
Kristian Wind 87c557941a Merge pull request #49 from kristianwind/theme-charcoal-polish
CI / OpenAPI is valid (push) Successful in 9s
CI / End-to-end (push) Successful in 8m47s
CI / Docker image builds (push) Successful in 1m47s
Release / Build and publish image (push) Failing after 5s
CI / Go (push) Failing after 14m25s
Charcoal theme, elegant selection, rounded note list, confirm sign-out
2026-09-03 16:37:44 +02:00
Kristian Wind 0e1e803486 Merge pull request #48 from kristianwind/totp-qr
2FA: show a scannable QR code when enabling two-factor auth
2026-09-03 16:37:36 +02:00
kristianwindandClaude Opus 4.8 1dc9751a33 test(e2e): sign out with the two-step confirm
Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-03 16:29:18 +02:00
kristianwindandClaude Opus 4.8 b81f8f67cc feat(ui): Charcoal theme, elegant selection, rounded note list, confirm sign-out
- A new Charcoal theme — neutral dark greys on the menu, note list and
  editor instead of the default's faint green cast, with matching inks;
  the green accent stays. It joins the theme picker on its own (the picker
  is data-driven from THEMES).
- The text selection is a translucent wash of the accent, not the old
  near-invisible tint and not a solid slab — visible on white and on the
  dark surfaces, keeping the text's own colour.
- The note list is a rounded card now, the same corner and border as the
  editor beside it, with a few pixels more air around the menu and the list.
- Signing out asks first: a second click within a few seconds confirms, so
  a button the pointer passes over does not drop you at the login screen.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-03 16:27:55 +02:00
kristianwindandClaude Opus 4.8 f62ffc8d92 feat(2fa): show a scannable QR code when enabling two-factor auth
The setup screen showed the secret and the otpauth URI as text and asked
you to scan — with nothing to scan. It renders the URI as a QR now, an SVG
(one dark path on a white card, so it reads in either theme) generated from
the barcode encoder already in the module graph via pquerna/otp. The secret
stays below it for a device that cannot scan.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-03 16:27:11 +02:00
Kristian Wind 73ee93deab Merge pull request #47 from kristianwind/offline-blip-resilience
CI / OpenAPI is valid (push) Successful in 11s
CI / End-to-end (push) Successful in 9m0s
CI / Docker image builds (push) Successful in 1m56s
Release / Build and publish image (push) Failing after 6s
CI / Go (push) Failing after 14m34s
Offline: ride out short connection drops instead of losing the save
2026-09-03 15:35:03 +02:00
kristianwindandClaude Opus 4.8 b2fcc0b104 feat(offline): ride out short connection drops instead of losing the save
A save made while the connection blips for a few seconds is retried rather
than reverted: the request layer keeps trying a network failure for a
fifteen-second window, waking the instant the OS reports a link again, and
only falls back to the existing error path if the drop outlasts it. A quiet
"reconnecting" pill appears if the wait passes about a second, and leaves
the moment it heals — so a two-second blip is felt as nothing at all.

This is deliberately not offline mode: the app is a live view of a shared
list, so there is no cache to work in with no server and no write log to
reconcile. It is only the blip, ridden out. A server error (4xx/5xx) is the
server answering and is not retried; an aborted request (a superseded
search) is left to propagate.

Kristian: an offline function for when the net drops for short periods,
seconds. Shared items stay server-authoritative — nothing is edited against
a stale copy for longer than the blip.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-03 15:26:46 +02:00
14 changed files with 531 additions and 48 deletions
+2 -2
View File
@@ -3,8 +3,10 @@ module github.com/kristianwind/verdande
go 1.26.3
require (
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc
github.com/coder/websocket v1.8.15
github.com/emersion/go-imap/v2 v2.0.0-beta.8
github.com/emersion/go-message v0.18.2
github.com/go-chi/chi/v5 v5.3.1
github.com/go-webauthn/webauthn v0.17.4
github.com/pquerna/otp v1.5.0
@@ -14,9 +16,7 @@ require (
)
require (
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emersion/go-message v0.18.2 // indirect
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 // indirect
github.com/fxamacker/cbor/v2 v2.9.2 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
+36
View File
@@ -10,6 +10,7 @@ import (
"strings"
"time"
"github.com/boombuler/barcode/qr"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
)
@@ -50,6 +51,41 @@ func NewTOTPSecret(issuer, account string) (secret, uri string, err error) {
return key.Secret(), key.URL(), nil
}
// TOTPQRSVG renders the otpauth:// URI as a QR code, as an SVG a phone camera can
// read. SVG rather than a PNG data URI so it stays crisp at any size and adds no
// base64 blob to the page — one dark path on a white square, which is what a scanner
// needs whatever theme the page is in.
//
// The barcode encoder is already in the module graph (pquerna/otp draws on it), so
// this borrows a dependency rather than adding one.
func TOTPQRSVG(uri string) (string, error) {
code, err := qr.Encode(uri, qr.M, qr.Auto)
if err != nil {
return "", fmt.Errorf("auth: encode totp qr: %w", err)
}
b := code.Bounds()
n := b.Dx()
// A four-module quiet zone all round, which the spec requires and scanners rely
// on — without it the code runs to the edge and a reader cannot find its border.
const quiet = 4
size := n + quiet*2
var sb strings.Builder
fmt.Fprintf(&sb, `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 %d %d" shape-rendering="crispEdges">`, size, size)
sb.WriteString(`<rect width="100%" height="100%" fill="#ffffff"/><path fill="#111312" d="`)
for y := 0; y < n; y++ {
for x := 0; x < n; x++ {
// Dark modules are black; the red channel is 0 for those and full for the
// light ones. One 1×1 rect per dark module, merged into a single path.
if r, _, _, _ := code.At(b.Min.X+x, b.Min.Y+y).RGBA(); r == 0 {
fmt.Fprintf(&sb, "M%d %dh1v1h-1z", x+quiet, y+quiet)
}
}
}
sb.WriteString(`"/></svg>`)
return sb.String(), nil
}
// TOTPURI rebuilds the otpauth:// URI for an existing secret, for showing the QR
// code again before enrolment is confirmed.
func TOTPURI(secret, issuer, account string) string {
+9 -1
View File
@@ -17,6 +17,9 @@ import (
type totpSetupResponse struct {
Secret string `json:"secret"`
URI string `json:"uri"`
// The URI as a scannable QR code (SVG). The secret and URI stay for typing in by
// hand on a device that cannot scan.
QR string `json:"qr"`
}
func (s *Server) handleTOTPSetup(w http.ResponseWriter, r *http.Request) {
@@ -54,7 +57,12 @@ func (s *Server) handleTOTPSetup(w http.ResponseWriter, r *http.Request) {
s.internal(w, r, "store totp secret", err)
return
}
writeJSON(w, http.StatusOK, totpSetupResponse{Secret: secret, URI: uri})
qrSVG, err := auth.TOTPQRSVG(uri)
if err != nil {
s.internal(w, r, "render totp qr", err)
return
}
writeJSON(w, http.StatusOK, totpSetupResponse{Secret: secret, URI: uri, QR: qrSVG})
}
type totpConfirmResponse struct {
+59 -3
View File
@@ -565,8 +565,13 @@ test('en opgave kan trækkes ned i en tom sektion, og en fejlet indlæsning sige
await expect(section.getByText('brænde kaffe')).toBeVisible();
await expect(page.locator('.toast')).toHaveCount(0);
// A load that fails says so, and offers to try again.
await page.route('**/api/v1/projects/*', (r) => r.abort());
// A load that fails with a server error says so at once and offers to try again.
// A 500 is the server answering, not a dropped connection, so it is not a blip to
// wait out — it is not retried, and the message is immediate. (A dropped
// connection now retries for a few seconds first; that is the self-heal test.)
await page.route('**/api/v1/projects/*', (r) =>
r.fulfill({ status: 500, contentType: 'application/json', body: '{"code":"internal_error"}' })
);
await page.reload();
await expect(page.getByText('Serveren svarede ikke')).toBeVisible();
await expect(page.getByRole('button', { name: 'Prøv igen' })).toBeVisible();
@@ -577,6 +582,52 @@ test('en opgave kan trækkes ned i en tom sektion, og en fejlet indlæsning sige
expect(trouble.filter((t) => !t.includes('projects'))).toEqual([]);
});
/**
* A save made during a short drop is not lost to it.
*
* This is the whole of what "offline" means here: not a cache to work in with no
* server, but a save that rides out a few seconds of no connection and goes through
* when it comes back — with a quiet "reconnecting" while it waits, and no error and
* no reverted change once it heals. A drop that outlasts the retry window is a real
* outage and takes the normal error path; that is not this test.
*/
test('en kort netaudsætning under en handling genoprettes af sig selv', async ({ page }) => {
const trouble = watchForTrouble(page);
await page.goto('/');
// Wait for the app to finish loading before cutting the line — `goto` resolves at
// the load event, but the data load runs after hydration, and aborting that would
// test a cold start, not a blip mid-use.
const box = page.getByLabel('Ny opgave');
await expect(box).toBeVisible();
// The app is loaded and online. Now the connection drops — every call fails, the
// way it does in a tunnel, rather than one endpoint erroring.
let down = true;
await page.route('**/api/v1/**', (route) => (down ? route.abort() : route.continue()));
// A task captured during the drop. Its save fails on the network and starts
// retrying rather than giving up.
await box.fill('under et udfald');
await box.press('Enter');
// The quiet pill, once the retry has lasted long enough to be worth showing.
await expect(page.locator('.netstatus')).toBeVisible();
// The drop ends. The retry goes through on its own and the pill leaves — no
// error, nothing toasted as failed.
down = false;
await expect(page.locator('.netstatus')).toHaveCount(0, { timeout: 10000 });
await expect(page.locator('.toast')).toHaveCount(0);
// And the save landed: an undated quick capture goes to the Inbox, and there it
// is, saved across the drop rather than lost to it.
await page.getByRole('link', { name: /Indbakke/ }).click();
await expect(page.getByText('under et udfald')).toBeVisible({ timeout: 10000 });
expect(trouble).toEqual([]);
});
/**
* A task can be dragged onto another day, and onto another project.
*
@@ -1979,7 +2030,12 @@ test('en passkey kan registreres og logges ind med', async ({ browser, browserNa
// Now sign out and back in with it. No email typed: the device knows which
// account its key belongs to, which is also why this page cannot be used to
// find out who has an account here.
await page.getByRole('navigation', { name: 'Hovedmenu' }).getByText('Log ud').click();
// Signing out asks first now: one click arms it, a second within a few seconds
// does it. The whole account row is the button; its label changes to the prompt.
const signOut = page.getByRole('navigation', { name: 'Hovedmenu' }).locator('.user');
await signOut.click();
await expect(signOut).toContainText('Tryk igen for at logge ud');
await signOut.click();
// `exact`, because "Log ind" is a substring of "Log ind med en passkey" and
// Playwright matches an accessible name loosely unless told otherwise.
await expect(page.getByRole('button', { name: 'Log ind', exact: true })).toBeVisible();
+51 -2
View File
@@ -210,6 +210,51 @@
--shadow-lg: 0 8px 32px rgb(0 0 0 / 0.4);
}
/* Kul — the greys of Apple Notes' dark mode, to Kristian's own sampled values.
Three panel greys, lightest sidebar to darkest editor — the reverse of the usual
sunken-is-darkest order, which is why the editor gets its own --editor-bg rather
than sharing --surface-raised with the list. The accent turns amber, and the
selected menu item, selected note and section headings each get a fallback token
so this theme can hit its colours without touching any other. */
[data-theme='charcoal'] {
--ground: #1e1e1e;
--surface: #2a3033;
--surface-raised: #242b2e; /* the note list */
--surface-sunken: #2d3133; /* the menu / sidebar — lightest here */
--line: #34393b;
--line-strong: #414749;
--ink: #ffffff;
--ink-muted: #dcdcdc;
--ink-faint: #9ba0a2;
/* Amber, Apple's Notes accent. The bright value is the selected menu item; the
dark text rides on top of it. */
--accent: #ffce35;
--accent-hover: #ffd75a;
--accent-sunken: #ffce35;
--accent-ink: #1e1e1e;
/* Per-element, and only here — every other theme falls back to the shared token
in the var() calls that read these. */
--editor-bg: #1e1e1e; /* the text field, a shade below the list */
--note-on-bg: #a78c26; /* a selected note in the list — gold */
--note-on-ink: #1e1e1e; /* dark text on the gold */
--nav-active-ink: #1e1e1e; /* dark text on the amber menu item */
--heading-ink: #8a8e90; /* PROJEKTER and the group names — quiet grey */
--p1: #cf6b6b;
--p2: #d69f5c;
--p3: #6b9ecf;
--p4: var(--ink-faint);
--danger: #cf6b6b;
--danger-sunken: #33201f;
--shadow: 0 1px 2px rgb(0 0 0 / 0.25);
--shadow-lg: 0 8px 32px rgb(0 0 0 / 0.4);
}
/* Papir — warm light, closer to paper than to a screen. */
[data-theme='paper'] {
--ground: #f6f1e7;
@@ -375,9 +420,13 @@ button {
søgefelt. */
}
/* A translucent wash of the accent, not a solid block and not the old near-invisible
tint. --accent-sunken sat a hair off the editor's own surface in dark, so a
selection could not be seen; a solid accent could, but read as a heavy slab. Mixing
the accent part-way into transparent lays a clear green film over the text while it
keeps its own colour — visible on white and on the dark surfaces alike. */
::selection {
background: var(--accent-sunken);
color: var(--ink);
background: color-mix(in oklab, var(--accent) 42%, transparent);
}
/* Scrollbars, made quiet. The default on Windows is a wide grey slab that
+58 -14
View File
@@ -23,6 +23,57 @@ export class ApiError extends Error {
}
import { t } from './i18n.svelte.js';
import { connectivity, sleepOrOnline } from './connectivity.svelte.js';
/**
* How long a request keeps retrying a network failure before giving up.
*
* This is the whole of the "offline" feature and its whole limit: it rides out a
* blip of a few seconds so a save is not lost to it, and then — because the app is
* a live view of a shared list, not a local database — it stops and says so rather
* than holding an edit for a network that is not coming back. Fifteen seconds is
* long enough for a handover or a tunnel and short enough that a real outage fails
* while the user is still looking at what they did.
*/
const RETRY_WINDOW_MS = 15000;
/** Backoff between attempts: 0.5s, 1s, 2s, then 3s, capped. A waiting sleep also
* wakes the instant the OS reports a link again, so most blips end on the first. */
const backoff = (attempt) => Math.min(500 * 2 ** attempt, 3000);
/**
* Runs `send` (a fetch), retrying only network failures for a short window.
*
* A network failure is fetch rejecting — no HTTP status ever arrived. An HTTP
* error (4xx/5xx) is the server answering, so it is returned, not retried: retrying
* a 400 just asks the same wrong question again. An abort is the caller changing
* its mind (a superseded search), so it is left to propagate.
*
* Retrying is not free of risk: a create whose request reached the server but whose
* response was lost would be made twice. For a drop of seconds that is rare, and the
* alternative — losing the save every time the network hiccups — is the thing this
* exists to stop. A server-side idempotency key would remove even that; it is a
* larger change noted for later.
*/
async function withRetry(send, noRetry = false) {
const deadline = Date.now() + (noRetry ? 0 : RETRY_WINDOW_MS);
let attempt = 0;
for (;;) {
try {
const res = await send();
connectivity.reachable();
return res;
} catch (e) {
if (e?.name === 'AbortError') throw e;
if (Date.now() >= deadline) {
connectivity.lost();
throw new ApiError(0, 'offline', 'ingen forbindelse');
}
connectivity.retrying();
await sleepOrOnline(backoff(attempt++));
}
}
}
/**
* The key for each code the API can return.
@@ -110,14 +161,10 @@ async function request(method, path, body, options = {}) {
init.body = JSON.stringify(body);
}
let res;
try {
res = await fetch(`/api/v1${path}`, init);
} catch (e) {
// A network failure is not an HTTP status; give it one the app can handle
// the same way as everything else.
throw new ApiError(0, 'offline', 'ingen forbindelse');
}
// Retries a network failure for a few seconds so a short drop does not lose the
// call; `withRetry` turns an exhausted window into the same `offline` error the
// app already handles. `options.noRetry` opts a call out — used by nothing yet.
const res = await withRetry(() => fetch(`/api/v1${path}`, init), options.noRetry);
if (res.status === 204) return null;
@@ -157,12 +204,9 @@ async function upload(path, file, field = 'file') {
const form = new FormData();
form.append(field, file);
let res;
try {
res = await fetch(`/api/v1${path}`, { method: 'POST', body: form, credentials: 'same-origin' });
} catch {
throw new ApiError(0, 'offline', 'ingen forbindelse');
}
const res = await withRetry(() =>
fetch(`/api/v1${path}`, { method: 'POST', body: form, credentials: 'same-origin' })
);
const text = await res.text();
let payload = null;
+41 -7
View File
@@ -34,6 +34,23 @@
location.href = '/';
}
// Signing out is one click from a button the pointer passes over on its way to
// everything below it, and it drops you at the login screen — so it asks first.
// A second click within a few seconds confirms; anything else lets it lapse. Not
// a dialog: a two-step button is lighter and stays where the eye already is.
let confirmSignOut = $state(false);
let signOutTimer;
function onSignOutClick() {
if (confirmSignOut) {
clearTimeout(signOutTimer);
signOut();
return;
}
confirmSignOut = true;
clearTimeout(signOutTimer);
signOutTimer = setTimeout(() => (confirmSignOut = false), 3500);
}
let filters = $state([]);
let labels = $state([]);
@@ -1050,12 +1067,12 @@
{#if !app.connected}
<span class="offline" title={t('nav.offlineHint')}>{t('nav.offline')}</span>
{/if}
<button class="user" onclick={signOut}>
<button class="user" class:confirming={confirmSignOut} onclick={onSignOutClick}>
<span class="avatar" style="background: {app.user?.avatar_color}">
{app.user?.name?.[0]?.toUpperCase() ?? '?'}
</span>
<span class="user-name">{app.user?.name}</span>
<span class="signout">{t('nav.signOut')}</span>
<span class="user-name">{confirmSignOut ? t('nav.signOutConfirm') : app.user?.name}</span>
<span class="signout">{confirmSignOut ? '' : t('nav.signOut')}</span>
</button>
</div>
</div>
@@ -1091,14 +1108,16 @@
display: flex;
flex-direction: column;
gap: var(--s5);
padding: var(--s4) var(--s3);
/* A few pixels more air down each side than the rows strictly need, so the
menu breathes rather than sitting flush against its own edges. */
padding: var(--s4) calc(var(--s3) + 3px);
background: var(--surface-sunken);
border-right: 1px solid var(--line);
/* Selve bjælken ruller ikke længere — .scroller gør. `hidden` frem for
ingenting, fordi den stadig er den yderste kant: løber en række over,
skal den klippes her og ikke skubbe kolonnen bredere. */
overflow: hidden;
padding-left: max(var(--s3), env(safe-area-inset-left));
padding-left: max(calc(var(--s3) + 3px), env(safe-area-inset-left));
position: relative;
}
@@ -1317,7 +1336,9 @@
h2 {
font-size: var(--menu-size);
font-weight: 600;
color: var(--ink);
/* Kul sets these headings to a quiet grey (--heading-ink); every other theme
falls back to the reading ink and keeps them bold and bright. */
color: var(--heading-ink, var(--ink));
}
/* The heading's mark, in the muted ink so the bold name still leads. Sized and
@@ -1572,7 +1593,10 @@
in both themes. */
a.active {
background: var(--accent-sunken);
color: var(--ink);
/* On a solid accent (Kul's amber menu item) the label goes dark via
--nav-active-ink; on the tinted accent-sunken every other theme uses, it
falls back to the reading ink. */
color: var(--nav-active-ink, var(--ink));
font-weight: 600;
}
@@ -1695,6 +1719,16 @@
background: var(--surface);
}
/* Asking to confirm: the row goes to the danger tint and the name is replaced by
"click again", so the second click is plainly the one that signs out. */
.user.confirming {
background: var(--danger-sunken);
}
.user.confirming .user-name {
color: var(--danger);
}
.avatar {
width: 22px;
height: 22px;
+70
View File
@@ -0,0 +1,70 @@
/**
* Connectivity, as the app experiences it — not as the browser reports it.
*
* This is for short drops: a few seconds of lost Wi-Fi, a tunnel, a base station
* handing over. It is deliberately NOT offline support. The app is already loaded
* and its data is already in memory, so there is nothing to cache and nothing to
* open from cold; what a blip needs is for the save you just made to survive it,
* not for the whole app to run without a server.
*
* The request layer drives this: it retries a failed request for a short window
* (see api.js) and tells this store while it is trying, so the interface can say
* "reconnecting" rather than reverting the change under the user's hands. If the
* window runs out it is a real outage, and then the normal error path takes over.
*
* `navigator.onLine` is only a hint — it goes false when the machine has no route,
* but it stays true for a dead gateway or a server that is down, so it cannot be
* the source of truth. It is used here only to wake a waiting retry the moment the
* OS sees a link again, which is the one thing it is reliable for.
*/
import { browser } from '$app/environment';
class Connectivity {
/** 'online' — every recent request reached the server.
* 'retrying' — a request failed on the network and is being retried.
* 'lost' — a request gave up after the retry window; a real outage. */
status = $state('online');
/** A request reached the server. The network is up, whatever it was doing. */
reachable() {
this.status = 'online';
}
/** A request failed on the network and is about to be tried again. */
retrying() {
if (this.status !== 'lost') this.status = 'retrying';
}
/** A request used up its retry window without reaching the server. */
lost() {
this.status = 'lost';
}
}
export const connectivity = new Connectivity();
if (browser) {
// The OS lost its link: say so at once rather than waiting for the next request
// to fail. It does not, on its own, mean the server is unreachable — but with no
// route there is nothing a save can do but wait, and the honest thing is to show
// it waiting.
window.addEventListener('offline', () => connectivity.retrying());
}
/**
* Sleeps for `ms`, but wakes early the moment the OS reports a link again — so a
* retry that is biding its time does not sit out the last two seconds of a blip
* that has already ended.
*/
export function sleepOrOnline(ms) {
return new Promise((resolve) => {
let timer;
const done = () => {
clearTimeout(timer);
if (browser) window.removeEventListener('online', done);
resolve();
};
timer = setTimeout(done, ms);
if (browser) window.addEventListener('online', done, { once: true });
});
}
+5
View File
@@ -119,6 +119,7 @@ export const da = {
'nav.calendar': 'Kalender',
'nav.settings': 'Indstillinger',
'nav.signOut': 'Log ud',
'nav.signOutConfirm': 'Tryk igen for at logge ud',
'nav.main': 'Hovedmenu',
'nav.search': 'Søg',
'nav.searchLong': 'Søg i opgaver og projekter',
@@ -130,6 +131,8 @@ export const da = {
'nav.toggleTheme': 'Skift mellem lyst og mørkt tema',
'nav.offline': 'Offline',
'nav.offlineHint': 'Ændringer fra andre vises ikke lige nu',
'net.reconnecting': 'Genopretter forbindelse…',
'net.offline': 'Ingen forbindelse',
'nav.doItToday': 'Gør det i dag',
// --- the sidebar's own sections ------------------------------------------------
@@ -841,6 +844,8 @@ export const da = {
// --- the themes -------------------------------------------------------------------
'theme.dark': 'Nordlys',
'theme.darkNote': 'Mørk med grøn accent.',
'theme.charcoal': 'Kul',
'theme.charcoalNote': 'Neutral mørkegrå.',
'theme.dusk': 'Skumring',
'theme.duskNote': 'Mørk og varm, med rav.',
'theme.light': 'Dagslys',
+5
View File
@@ -115,6 +115,7 @@ export const en = {
'nav.calendar': 'Calendar',
'nav.settings': 'Settings',
'nav.signOut': 'Sign out',
'nav.signOutConfirm': 'Click again to sign out',
'nav.main': 'Main menu',
'nav.search': 'Search',
'nav.searchLong': 'Search tasks and projects',
@@ -126,6 +127,8 @@ export const en = {
'nav.toggleTheme': 'Switch between light and dark',
'nav.offline': 'Offline',
'nav.offlineHint': 'Changes from other people are not showing right now',
'net.reconnecting': 'Reconnecting…',
'net.offline': 'No connection',
'nav.doItToday': 'Do it today',
// --- the sidebar's own sections ------------------------------------------------
@@ -834,6 +837,8 @@ export const en = {
// --- the themes -------------------------------------------------------------------
'theme.dark': 'Northern lights',
'theme.darkNote': 'Dark, with a green accent.',
'theme.charcoal': 'Charcoal',
'theme.charcoalNote': 'Neutral dark grey.',
'theme.dusk': 'Dusk',
'theme.duskNote': 'Dark and warm, with amber.',
'theme.light': 'Daylight',
+1
View File
@@ -1006,6 +1006,7 @@ export const completedView = new CompletedView();
*/
export const THEMES = [
{ id: 'dark', name: 'theme.dark', note: 'theme.darkNote', dark: true },
{ id: 'charcoal', name: 'theme.charcoal', note: 'theme.charcoalNote', dark: true },
{ id: 'dusk', name: 'theme.dusk', note: 'theme.duskNote', dark: true },
{ id: 'light', name: 'theme.light', note: 'theme.lightNote', dark: false },
{ id: 'paper', name: 'theme.paper', note: 'theme.paperNote', dark: false },
+90
View File
@@ -1,6 +1,7 @@
<script>
import '../app.css';
import { app, theme, sidebar } from '$lib/stores.svelte.js';
import { connectivity } from '$lib/connectivity.svelte.js';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import Sidebar from '$lib/components/Sidebar.svelte';
@@ -14,6 +15,29 @@
let paletteOpen = $state(false);
let sidebarOpen = $state(false);
/**
* Whether to show the "reconnecting" pill.
*
* Held back seven tenths of a second while merely retrying, so a blip that ends
* on the first retry never flashes a pill nobody needed to see. A retry that has
* already given up ('lost') is a real error and shown at once — the delay is only
* for the hopeful case.
*/
let showNet = $state(false);
$effect(() => {
const s = connectivity.status;
if (s === 'online') {
showNet = false;
return;
}
if (s === 'lost') {
showNet = true;
return;
}
const timer = setTimeout(() => (showNet = true), 700);
return () => clearTimeout(timer);
});
/**
* The two pages that arrive by email, and are for somebody who is not signed in.
*
@@ -204,6 +228,16 @@
</div>
{/each}
</div>
<!-- A short drop, said quietly: it appears only if a save is still retrying after
the better part of a second, and leaves the moment the connection is back — so
a two-second blip that heals itself is felt as nothing at all. -->
{#if showNet}
<div class="netstatus" class:lost={connectivity.status === 'lost'} role="status">
<span class="net-dot" aria-hidden="true"></span>
{connectivity.status === 'lost' ? t('net.offline') : t('net.reconnecting')}
</div>
{/if}
{/if}
<style>
@@ -378,6 +412,62 @@
padding-bottom: env(safe-area-inset-bottom);
}
/* The reconnecting pill: at the top, small, centred. Not a toast — a toast is a
thing that happened and is over, this is a thing still happening. */
.netstatus {
position: fixed;
top: calc(var(--s3) + env(safe-area-inset-top));
left: 50%;
transform: translateX(-50%);
z-index: 60;
display: flex;
align-items: center;
gap: var(--s2);
padding: var(--s1) var(--s3);
border-radius: var(--radius-full);
background: var(--surface-raised);
border: 1px solid var(--line-strong);
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
font-size: var(--text-xs);
color: var(--ink-muted);
}
.net-dot {
width: 7px;
height: 7px;
flex: none;
border-radius: var(--radius-full);
background: var(--color-amber);
animation: net-pulse 1.1s ease-in-out infinite;
}
/* Given up: an amber pulse becomes a still red, the same red a failed toast
carries, so "still trying" and "gave up" do not look alike. */
.netstatus.lost {
color: var(--ink);
}
.netstatus.lost .net-dot {
background: var(--p1);
animation: none;
}
@keyframes net-pulse {
0%,
100% {
opacity: 0.35;
}
50% {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.net-dot {
animation: none;
}
}
.toast {
display: flex;
align-items: center;
+34 -6
View File
@@ -138,6 +138,7 @@
let totpSecret = $state('');
let totpURI = $state('');
let totpQR = $state('');
let totpCode = $state('');
let totpErrors = $state({});
let recoveryCodes = $state([]);
@@ -163,6 +164,7 @@
enablePassword = '';
totpSecret = r.secret;
totpURI = r.uri;
totpQR = r.qr;
} catch (e) {
totpErrors = e.fields ?? {};
if (!Object.keys(totpErrors).length) app.toast(humanMessage(e));
@@ -177,6 +179,7 @@
recoveryCodes = r.recovery_codes;
totpSecret = '';
totpURI = '';
totpQR = '';
totpCode = '';
app.user = await api.me();
} catch (e) {
@@ -492,8 +495,13 @@
{:else if totpSecret}
<div class="field">
<p class="hint">{t('account.scanHint')}</p>
{#if totpQR}
<!-- The server renders the otpauth URI as an SVG QR — one dark path on a
white square, so it scans in either theme. It is the URI it already
sent, drawn; nothing here builds it. -->
<div class="qr">{@html totpQR}</div>
{/if}
<p class="mono secret">{totpSecret}</p>
<p class="hint mono uri">{totpURI}</p>
</div>
<form onsubmit={confirmTOTP}>
@@ -514,7 +522,14 @@
<div class="row">
<button class="primary" type="submit">{t('account.confirm')}</button>
<button class="secondary" onclick={() => (totpSecret = '')}>{t('account.cancel')}</button>
<button
class="secondary"
onclick={() => {
totpSecret = '';
totpURI = '';
totpQR = '';
}}>{t('account.cancel')}</button
>
</div>
</form>
{:else}
@@ -859,6 +874,23 @@
color: var(--ink-faint);
}
/* On its own white card whatever the theme: a QR is dark-on-light or it does not
scan, so the square keeps its own background rather than taking the page's. */
.qr {
width: 176px;
height: 176px;
padding: var(--s2);
background: #ffffff;
border: 1px solid var(--line);
border-radius: var(--radius);
}
.qr :global(svg) {
display: block;
width: 100%;
height: 100%;
}
.secret {
margin: 0;
padding: var(--s3);
@@ -869,10 +901,6 @@
overflow-wrap: anywhere;
}
.uri {
overflow-wrap: anywhere;
}
/* The understated variant: present, not loud. Bordered and in the muted ink so
it reads as a footnote, brightening on hover. The cup is outline-only. */
.bmc {
+70 -13
View File
@@ -707,7 +707,10 @@
}}
/>
<div class="notes">
<!-- `has-note` drives the phone layout: one column, showing the list until a note
is opened and the editor once one is. On a wide screen both are always up and
the class does nothing. -->
<div class="notes" class:has-note={selected}>
<aside>
<div class="head">
<h1>{t('notes.title')}</h1>
@@ -917,6 +920,9 @@
<section class="editor">
{#if selected}
<!-- Phone only (hidden on a wide screen by CSS): the way back to the list,
since there the editor fills the screen and the list is not beside it. -->
<button class="back" onclick={() => open(null)}>‹ {t('notes.title')}</button>
<NoteEditor
note={selected}
notes={notes}
@@ -1068,8 +1074,9 @@
against the sidebar's rule, which reads as a rendering fault rather than
as a layout. */
/* Luft hele vejen rundt om arket. Højre og bund var nul, dengang editoren
ingen kant havde og ingenting kunne støde imod. */
padding: var(--s3) var(--s4) var(--s3) var(--s4);
ingen kant havde og ingenting kunne støde imod. Et par pixels mere om
notelisten, så kortet ikke ligger klods op ad menuen. */
padding: var(--s3) var(--s4) var(--s3) calc(var(--s4) + 3px);
display: grid;
grid-template-columns: minmax(220px, 300px) 1fr;
gap: var(--s4);
@@ -1083,13 +1090,15 @@
gap: var(--s2);
min-height: 0;
min-width: 0;
border-right: 1px solid var(--line);
padding-right: var(--s3);
/* A rounded card, the same corner and border as the editor beside it — the
list is its own sheet, not a column ruled off the page. */
border: 1px solid var(--line);
border-radius: var(--radius);
/* White in light, a nuance lighter than the ground in dark — the note list
is a surface you read down, so it lifts off the page like the editor does.
--surface-raised is #fff in the light themes and one step up in the dark. */
background: var(--surface-raised);
padding-left: var(--s3);
padding: var(--s3);
}
.head {
@@ -1477,8 +1486,20 @@
}
.row.on {
background: var(--surface-raised);
color: var(--ink);
background: var(--note-on-bg, var(--surface-raised));
color: var(--note-on-ink, var(--ink));
}
/* On a themed selection colour (Kul's gold), the row's own quieter tiers go dark
too, or the date and the filed line vanish into it. Other themes have no
--note-on-ink, so these fall back to their normal muted inks. */
.row.on .when,
.row.on .filed {
color: var(--note-on-ink, var(--ink-muted));
}
.row.on .filed-icon {
color: var(--note-on-ink, var(--ink-faint));
}
/* Samme størrelse som en opgavetitel. En note og en opgave er to ting af samme
@@ -1574,8 +1595,10 @@
min-height: 0;
min-width: 0;
/* A nuance lighter than the ground in dark, still white in light — matches
the note list beside it so the two read as one writing surface. */
background: var(--surface-raised);
the note list beside it so the two read as one writing surface. Kul gives
the text field its own darker grey via --editor-bg; other themes fall back
to the shared surface so the list and the editor stay the same colour. */
background: var(--editor-bg, var(--surface-raised));
border: 1px solid var(--line);
border-radius: var(--radius);
/* Luft nok til at teksten ikke rører kanten.
@@ -1894,14 +1917,48 @@
font-size: var(--text-sm);
}
/* The way back to the list on a phone — an iOS-style "‹ Noter" at the top of the
editor. Hidden on a wide screen, where the list is always beside the editor. */
.back {
display: none;
align-self: flex-start;
align-items: center;
gap: var(--s1);
margin-bottom: var(--s2);
padding: var(--s1) 0;
font-size: var(--text-base);
color: var(--accent);
}
@media (max-width: 700px) {
.notes {
grid-template-columns: 1fr;
padding: 0;
gap: 0;
}
aside {
border-right: 0;
padding-right: 0;
/* One pane at a time. The two-column card layout has no room on a phone, so
the list shows until a note is opened and the editor takes over once one is
— the back button is the way between them. Without this the editor stacked
below a full-height list, so a tapped note opened out of sight. */
.notes.has-note aside {
display: none;
}
.notes:not(.has-note) .editor {
display: none;
}
/* Full-bleed: the card border and rounded corners are for sitting beside
another card, and on one column there is nothing beside it. */
aside,
.editor {
border: 0;
border-radius: 0;
}
.back {
display: inline-flex;
}
}
</style>