[web] Design review: last row's menu not clipped, Hostname focused after loading, popover closes on Esc and outside click, phone engine chip in the top bar, paused and needs-attention copy with Restore in the panel, change bar offers and countdown, focus after share and kept, fingerprint check when signing by hand, draft kept through sign-in
This commit is contained in:
@@ -3,16 +3,17 @@
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
<script lang="ts">
|
||||
// Handoff §5: the main screen.
|
||||
import { Banner, Button, Icon } from "@ianitor/ui";
|
||||
import { tick } from "svelte";
|
||||
import { Banner, Button } from "@ianitor/ui";
|
||||
import ChangeBar from "../components/ChangeBar.svelte";
|
||||
import EnginePopover from "../components/EnginePopover.svelte";
|
||||
import EngineChip from "../components/EngineChip.svelte";
|
||||
import HostList from "../components/HostList.svelte";
|
||||
import HostPanel from "../components/HostPanel.svelte";
|
||||
import IntermediateBanner from "../components/IntermediateBanner.svelte";
|
||||
import ShareDialog from "../components/ShareDialog.svelte";
|
||||
import { call, newKey, post, sentence } from "../lib/api";
|
||||
import { app, changesBlocked, navigate, refresh, toast } from "../lib/app.svelte";
|
||||
import { countsSentence, when } from "../lib/format";
|
||||
import { atTime, countsSentence } from "../lib/format";
|
||||
import type { ApplyView, HostSpec } from "../lib/types";
|
||||
|
||||
let { route }: { route: { newHost: boolean; edit?: string } } = $props();
|
||||
@@ -25,12 +26,18 @@
|
||||
const panelOpen = $derived(route.newHost || !!route.edit || app.panel?.kind === "host");
|
||||
const blocked = $derived(changesBlocked());
|
||||
|
||||
function closePanel() {
|
||||
async function closePanel() {
|
||||
prefill = null;
|
||||
focusField = undefined;
|
||||
if (app.panel?.kind === "host") app.panel = null;
|
||||
if (route.newHost || route.edit) navigate("/");
|
||||
void refresh();
|
||||
await refresh();
|
||||
const h = app.focusHost;
|
||||
app.focusHost = null;
|
||||
if (h) {
|
||||
await tick();
|
||||
document.querySelector<HTMLElement>(`[aria-label="More for ${h.replace(/["\\]/g, "")}"]`)?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(h: string) {
|
||||
@@ -62,27 +69,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
const engineName = $derived(o?.engine.running === "caddy" ? "Caddy" : "Pingora");
|
||||
const engineLabel = $derived(
|
||||
o?.engine.state === "switching" ? "Engine: switching" : `Engine: ${engineName}${o?.engine.state === "stopped" ? ", not answering" : ""}. Change engine`,
|
||||
);
|
||||
</script>
|
||||
|
||||
<div class="head">
|
||||
<div>
|
||||
<h1 class="ia-display">Hosts</h1>
|
||||
{#if o}<p class="ia-text2">{countsSentence(o.counts)}</p>{/if}
|
||||
{#if o}<p class={app.phone ? "ia-sub" : "ia-text2"}>{countsSentence(o.counts, app.phone)}</p>{/if}
|
||||
</div>
|
||||
<div class="actions">
|
||||
{#if o}
|
||||
<button type="button" class="ia-engine" aria-haspopup="dialog" aria-expanded={app.panel?.kind === "engine"} aria-label={engineLabel}
|
||||
onclick={() => (app.panel = app.panel?.kind === "engine" ? null : { kind: "engine" })}>
|
||||
{#if o.engine.state === "switching"}<Icon name="clock" /> Engine Switching…{:else}
|
||||
<span class="ia-status" data-s={o.engine.state === "stopped" ? "down" : "healthy"}><span class="ia-dot"></span></span>
|
||||
<small class="desktop">Engine</small> {engineName}{#if o.engine.running === "caddy"} <small>(fallback)</small>{/if}{/if}
|
||||
<Icon name="chevron" />
|
||||
</button>
|
||||
{/if}
|
||||
{#if !app.phone}<EngineChip />{/if}
|
||||
<Button variant="primary" icon="plus" label="Add a host" disabled={!!blocked} describedby={blocked ? "add-blocked" : undefined} onclick={() => navigate("/hosts/new")}>Host</Button>
|
||||
{#if blocked}<span class="sr-only" id="add-blocked">{blocked}</span>{/if}
|
||||
</div>
|
||||
@@ -115,7 +110,7 @@
|
||||
<hr class="ia-ornament" />
|
||||
<p class="ia-muted footer">
|
||||
Routes live in the {o.repo.name} repository, one file per host.
|
||||
{#if o.repo.last_push_at}Last pushed to Gitea at {when(o.repo.last_push_at, app.now)}.{/if}
|
||||
{#if o.repo.last_push_at}Last pushed to Gitea {atTime(o.repo.last_push_at, app.now)}.{/if}
|
||||
{#if o.repo.unpushed}{o.repo.unpushed} changes not yet pushed.{/if}
|
||||
<button type="button" class="domi-btn link" onclick={() => navigate("/history")}>See history</button>
|
||||
</p>
|
||||
@@ -129,13 +124,9 @@
|
||||
{#if app.panel?.kind === "share"}
|
||||
<ShareDialog hostname={app.panel.hostname} onclose={() => { app.panel = null; void refresh(); }} />
|
||||
{/if}
|
||||
{#if app.panel?.kind === "engine"}
|
||||
<EnginePopover onclose={() => (app.panel = null)} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
|
||||
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
|
||||
.footer { text-align: center; }
|
||||
@media (max-width: 719.98px) { .desktop { display: none; } }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user