[web] Domi UI: the web UI on @domi/ui v1.0.0 (fonts, roles, Button, TextField with seals, Checkbox, Select, Segmented)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// Links off: "Turn on share links" applies the change, then Copy link (4 clicks: open
|
||||
// question Q1 is not decided, so this is the fallback path the design allows).
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { DomiError, TextField } from "@domi/ui";
|
||||
import { Banner, Button, Dialog, Icon, Segmented } from "@ianitor/ui";
|
||||
import ApplyProgress from "./ApplyProgress.svelte";
|
||||
import { ApiError, call, del, newKey, patch, sentence } from "../lib/api";
|
||||
@@ -64,6 +65,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The seals of the two fields (domi-design TextField): a new link with this prefix or password, or the reason not.
|
||||
async function remint(field: "path_prefix" | "password") {
|
||||
await mint();
|
||||
if (fieldErr?.field === field) throw new DomiError(fieldErr.message);
|
||||
}
|
||||
|
||||
async function copy() {
|
||||
if (!link) return;
|
||||
try {
|
||||
@@ -111,7 +118,7 @@
|
||||
{:else}
|
||||
<p><strong>Share links are off for {hostname}.</strong></p>
|
||||
<p class="ia-text2">Turning them on is a change to the host, checked like any other.</p>
|
||||
{#if problem}<p class="domi-error" role="alert"><Icon name="ring" />{problem}</p>{/if}
|
||||
{#if problem}<p class="ia-error" role="alert"><Icon name="ring" />{problem}</p>{/if}
|
||||
<div><Button variant="outline" onclick={turnOn} disabled={!!app.overview?.paused}>Turn on share links</Button></div>
|
||||
{/if}
|
||||
{:else}
|
||||
@@ -130,34 +137,32 @@
|
||||
<p class="ia-status" data-s="kept" role="status"><Icon name="check" /><span>Copied</span></p>
|
||||
<p class="ia-hint">Expires on {longDate(link?.expires_at)}. To stop it sooner: Settings, Share links, Stop this link.</p>
|
||||
{:else}
|
||||
<Button variant="primary" full icon="copy" onclick={copy} disabled={!link || minting} data-autofocus>Copy link</Button>
|
||||
<Button variant="primary" full icon="copy" onclick={copy} pending={minting || (!link && !problem && !fieldErr)} disabled={!link && !minting && !!(problem || fieldErr)} data-autofocus>Copy link</Button>
|
||||
{/if}
|
||||
{#if refused}<p class="ia-hint" role="alert">Your browser did not allow copying. Press Ctrl+C to copy the selected link.</p>{/if}
|
||||
{#if copiedBefore && !copied}<p class="ia-hint">The link you copied before is stopped. Copy this one.</p>{/if}
|
||||
|
||||
<Segmented legend="Expires after" name="expiry" bind:value={days} onchange={() => mint()}
|
||||
options={[{ value: "1", label: "1 day" }, { value: "7", label: "7 days" }, { value: "30", label: "30 days" }]} />
|
||||
<div class="domi-field">
|
||||
<label class="domi-field-label" for="share-prefix">Only addresses starting with</label>
|
||||
<input id="share-prefix" class="domi-input" bind:value={prefix} onblur={() => mint()} onkeydown={(e) => { if (e.key === "Enter") { e.preventDefault(); void mint(); } }}
|
||||
aria-invalid={fieldErr?.field === "path_prefix" ? "true" : undefined} />
|
||||
{#if fieldErr?.field === "path_prefix"}<p class="domi-error"><Icon name="ring" />{fieldErr.message}</p>{/if}
|
||||
<p class="ia-hint">/ shares the whole site. Try /share/summer-2026 for one album.</p>
|
||||
<div class="ia-field" onfocusout={(e) => { if (!e.currentTarget.contains(e.relatedTarget as Node | null)) void mint(); }}>
|
||||
<TextField id="share-prefix" label="Only addresses starting with" bind:value={prefix} spellcheck={false} autocomplete="off"
|
||||
action="save" actionLabel="Make the link for these addresses" onsend={() => remint("path_prefix")}
|
||||
error={fieldErr?.field === "path_prefix" ? fieldErr.message : undefined}
|
||||
hint="/ shares the whole site. Try /share/summer-2026 for one album." />
|
||||
</div>
|
||||
{#if usingPassword}
|
||||
<p class="ia-hint">This link asks for the password.</p>
|
||||
<div><button type="button" class="domi-btn link" onclick={() => { usingPassword = false; password = ""; void mint(); }}>Remove the password</button></div>
|
||||
<div><button type="button" class="ia-link" onclick={() => { usingPassword = false; password = ""; void mint(); }}>Remove the password</button></div>
|
||||
{:else if showPassword}
|
||||
<div class="domi-field">
|
||||
<label class="domi-field-label" for="share-password">Password</label>
|
||||
<input id="share-password" class="domi-input" type="password" autocomplete="new-password" bind:value={password}
|
||||
aria-invalid={fieldErr?.field === "password" ? "true" : undefined} />
|
||||
{#if fieldErr?.field === "password"}<p class="domi-error"><Icon name="ring" />{fieldErr.message}</p>{/if}
|
||||
<p class="ia-hint">At least 8 characters. Send it to them separately.</p>
|
||||
<div class="ia-field">
|
||||
<TextField id="share-password" label="Password" type="password" autocomplete="new-password" bind:value={password}
|
||||
action="save" actionLabel="Ask for this password on the link" onsend={() => { usingPassword = true; return remint("password"); }}
|
||||
error={fieldErr?.field === "password" ? fieldErr.message : undefined}
|
||||
hint="At least 8 characters. Send it to them separately." />
|
||||
<div><Button onclick={() => { usingPassword = true; void mint(); }}>Use this password</Button></div>
|
||||
</div>
|
||||
{:else}
|
||||
<div><button type="button" class="domi-btn link" onclick={() => (showPassword = true)}>Add a password</button></div>
|
||||
<div><button type="button" class="ia-link" onclick={() => (showPassword = true)}>Add a password</button></div>
|
||||
{/if}
|
||||
{/if}
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user