[web] The web UI: hosts, add/edit with apply progress, undo, history and restore, share links, engine switch, certificates and device installs, signing by hand, settings and tokens; smoke test counts every §4 flow's clicks
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
import type { IconName } from "./icons";
|
||||
|
||||
// Handoff §2.1: disabled is aria-disabled (it stays focusable and its reason is read through
|
||||
// aria-describedby); pending keeps the label, adds a spinner and ignores clicks.
|
||||
let {
|
||||
variant = "quiet",
|
||||
icon,
|
||||
disabled = false,
|
||||
pending = false,
|
||||
describedby,
|
||||
label,
|
||||
small = false,
|
||||
full = false,
|
||||
type = "button",
|
||||
onclick,
|
||||
children,
|
||||
...rest
|
||||
}: {
|
||||
variant?: "primary" | "quiet" | "outline" | "danger" | "link";
|
||||
icon?: IconName;
|
||||
disabled?: boolean;
|
||||
pending?: boolean;
|
||||
describedby?: string;
|
||||
label?: string;
|
||||
small?: boolean;
|
||||
full?: boolean;
|
||||
type?: "button" | "submit";
|
||||
onclick?: (e: MouseEvent) => void;
|
||||
children?: Snippet;
|
||||
[key: string]: unknown;
|
||||
} = $props();
|
||||
|
||||
function click(e: MouseEvent) {
|
||||
if (disabled || pending) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
onclick?.(e);
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
{type}
|
||||
class="domi-btn {variant === 'quiet' ? '' : variant}"
|
||||
class:small
|
||||
class:full
|
||||
aria-disabled={disabled || pending ? "true" : undefined}
|
||||
aria-busy={pending ? "true" : undefined}
|
||||
aria-describedby={describedby}
|
||||
aria-label={label}
|
||||
onclick={click}
|
||||
{...rest}
|
||||
>
|
||||
{#if pending}<span class="spin" aria-hidden="true"></span>{:else if icon}<Icon name={icon} />{/if}
|
||||
{@render children?.()}
|
||||
</button>
|
||||
Reference in New Issue
Block a user