[web] Domi UI: the web UI on @domi/ui v1.0.4, vendored (CPAL-1.0), with the Built on Domi credit (PR #14, squashed)
@domi/ui v1.0.4 vendored unchanged in packages/domi-ui by domi-design's tools/vendor.mjs and used as workspace:*, so the Nix build fetches nothing from Gitea (web.nix sources the folder; fetchPnpmDeps hash from the NixOS runner). Its fonts, roles (data-domi-room="ianitor", the same hex) and controls replace Ianitor's copies: Button through Ianitor's adapter (desktop sizes kept), every text field a TextField with its seal, Checkbox, Select, Segmented. Ianitor's 22 role names renamed to --domi-*. <DomiCredit /> on every screen and in About, with the CPAL section 15 note beside the source link; the README names the vendored package. Disabled buttons are natively disabled.
This commit was merged in pull request #14.
This commit is contained in:
@@ -3,11 +3,17 @@
|
||||
- License 1.0: see LICENSE (its Exhibit A is this file's notice). -->
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import { Button as DomiButton } from "@domi/ui";
|
||||
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.
|
||||
// Ianitor's buttons are @domi/ui's Button (struck plate, leaf, states, 48 px on touch). This maps Ianitor's props
|
||||
// onto it, so the sizes on a desktop stay as they were: an ordinary button 44 px (lg), the primary 50 px (xl),
|
||||
// a small one 34 px (md). quiet and outline were both bordered buttons here; they are the plate now.
|
||||
// pending the button shows its work (status loading); a second press does nothing
|
||||
// disabled not pressable; say elsewhere why (describedby points at that text)
|
||||
// label the accessible name when it says more than the words ("+ Host" is "Add a host")
|
||||
// icon one of Ianitor's icons, before the words
|
||||
let {
|
||||
variant = "quiet",
|
||||
icon,
|
||||
@@ -22,7 +28,7 @@
|
||||
children,
|
||||
...rest
|
||||
}: {
|
||||
variant?: "primary" | "quiet" | "outline" | "danger" | "link";
|
||||
variant?: "primary" | "quiet" | "outline" | "danger";
|
||||
icon?: IconName;
|
||||
disabled?: boolean;
|
||||
pending?: boolean;
|
||||
@@ -31,32 +37,28 @@
|
||||
small?: boolean;
|
||||
full?: boolean;
|
||||
type?: "button" | "submit";
|
||||
onclick?: (e: MouseEvent) => void;
|
||||
onclick?: (e: MouseEvent) => unknown;
|
||||
children?: Snippet;
|
||||
[key: string]: unknown;
|
||||
} = $props();
|
||||
|
||||
function click(e: MouseEvent) {
|
||||
if (disabled || pending) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
onclick?.(e);
|
||||
}
|
||||
const uid = $props.id();
|
||||
const nameId = `ia-btn-name-${uid}`;
|
||||
const domiVariant = $derived(variant === "primary" ? "primary" : variant === "danger" ? "danger" : "plate");
|
||||
const size = $derived(small ? "md" : variant === "primary" ? "xl" : "lg");
|
||||
</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}
|
||||
<DomiButton
|
||||
{...rest}
|
||||
variant={domiVariant}
|
||||
{size}
|
||||
{type}
|
||||
block={full}
|
||||
{disabled}
|
||||
status={pending ? "loading" : undefined}
|
||||
aria-describedby={describedby}
|
||||
aria-labelledby={label ? nameId : undefined}
|
||||
{onclick}
|
||||
>
|
||||
{#if pending}<span class="spin" aria-hidden="true"></span>{:else if icon}<Icon name={icon} />{/if}
|
||||
{@render children?.()}
|
||||
</button>
|
||||
{#if icon}<Icon name={icon} />{/if}{@render children?.()}{#if label}<span id={nameId} hidden>{label}</span>{/if}
|
||||
</DomiButton>
|
||||
|
||||
Reference in New Issue
Block a user