@glimstone/svelte 5.0.3 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,9 +25,9 @@
25
25
  copyLabel: string;
26
26
  closeLabel: string;
27
27
  };
28
- /** The address as a scannable square. */
28
+ /** Draws the address in place of the window's own QR code. */
29
29
  renderQr?: Snippet<[string]>;
30
- /** A coin's own mark. */
30
+ /** Draws a coin's mark in place of the core's. */
31
31
  renderMark?: Snippet<[CryptoCoin]>;
32
32
  /** Copy the address and say so in a toast, in the app's own words. */
33
33
  onCopy: (coin: CryptoCoin, network: CryptoNetwork) => void;
@@ -38,10 +38,12 @@
38
38
  </script>
39
39
 
40
40
  <script lang="ts">
41
- import { hueVars } from "@glimstone/core";
41
+ import { hueVars, qrCode, type TileMark } from "@glimstone/core";
42
+ import { CRYPTO_MARKS } from "@glimstone/core/cryptoMarks";
42
43
  import { useLabelMode } from "./engines.svelte.js";
43
44
  import { css } from "./style.js";
44
45
  import Badge from "./Badge.svelte";
46
+ import BrandMark from "./BrandMark.svelte";
45
47
  import Button from "./Button.svelte";
46
48
 
47
49
  // The window for giving from a crypto wallet.
@@ -53,9 +55,9 @@
53
55
  // sits above the picker, since it is what the window is opened for.
54
56
  //
55
57
  // The component holds no state and touches no `document`; the app owns the
56
- // selection, Escape, the portal and the toast. `renderQr` and `renderMark` are
57
- // props because a QR code needs a library and a coin's mark is someone else's
58
- // brand; without them the window shows the address, a copy button and tickers.
58
+ // selection, Escape, the portal and the toast. The window draws the address as
59
+ // a QR code and a coin's mark from the core's set by itself; `renderQr` and
60
+ // `renderMark` let an app draw its own instead.
59
61
  let { coins, coin, network, onPick, text, renderQr, renderMark, onCopy, onClose, ref = $bindable(null) }: CryptoDonateDialogProps = $props();
60
62
 
61
63
  // `reactive` shows both mark and ticker here: somebody searching a grid of
@@ -63,6 +65,8 @@
63
65
  const mode = useLabelMode("buttons");
64
66
  const showMark = $derived(mode.current !== "text");
65
67
  const showTicker = $derived(mode.current !== "glyph");
68
+ const MARKS: Record<string, TileMark | undefined> = CRYPTO_MARKS;
69
+ const code = $derived(qrCode(network.address));
66
70
  </script>
67
71
 
68
72
  <!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
@@ -95,7 +99,15 @@
95
99
  <p class="glim-give-intro">{text.intro}</p>
96
100
 
97
101
  <div class="glim-give-well">
98
- {@render renderQr?.(network.address)}
102
+ {#if renderQr}
103
+ {@render renderQr(network.address)}
104
+ {:else}
105
+ <!-- A camera reads dark modules on a light ground, so these two colours stay put in every theme. -->
106
+ <svg class="glim-give-qr" aria-hidden="true" viewBox="-4 -4 {code.size + 8} {code.size + 8}" shape-rendering="crispEdges">
107
+ <rect x={-4} y={-4} width={code.size + 8} height={code.size + 8} fill="#ffffff" />
108
+ <path d={code.path} fill="#161616" />
109
+ </svg>
110
+ {/if}
99
111
  <!-- Never shortened, since an address is checked by eye before sending.
100
112
  `dir="ltr"` keeps it left-to-right in a right-to-left interface. -->
101
113
  <p dir="ltr" class="glim-give-address">{network.address}</p>
@@ -140,15 +152,17 @@
140
152
  type="button"
141
153
  role="option"
142
154
  aria-selected={picked}
143
- aria-label={`${c.name} (${c.symbol})`}
155
+ aria-label={`${c.symbol}, ${c.name}`}
144
156
  title={c.name}
145
157
  onclick={() => onPick(c, c.networks[0]!)}
146
158
  style={css({ ...hueVars(i), ...(lit && { "--tile": c.tile!.color, "--tile-ink": c.tile!.ink }) })}
147
159
  class={`glim-give-coin ${showTicker ? "glim-hue glim-hue-icon" : "glim-hue"} ${
148
- picked ? "glim-active" : lit ? "glim-brand-tile" : "glim-give-coin--plain"
160
+ picked ? "glim-active" : lit ? "glim-brand-tile" : ""
149
161
  }`}
150
162
  >
151
- {#if showMark}{@render renderMark?.(c)}{/if}
163
+ {#if showMark}
164
+ {#if renderMark}{@render renderMark(c)}{:else if MARKS[c.id]}<BrandMark svg={MARKS[c.id]!.svg} hover={MARKS[c.id]!.hover} />{/if}
165
+ {/if}
152
166
  {#if showTicker}<span class="glim-give-ticker">{c.symbol}</span>{/if}
153
167
  </button>
154
168
  {/each}
@@ -22,9 +22,9 @@ export interface CryptoDonateDialogProps {
22
22
  copyLabel: string;
23
23
  closeLabel: string;
24
24
  };
25
- /** The address as a scannable square. */
25
+ /** Draws the address in place of the window's own QR code. */
26
26
  renderQr?: Snippet<[string]>;
27
- /** A coin's own mark. */
27
+ /** Draws a coin's mark in place of the core's. */
28
28
  renderMark?: Snippet<[CryptoCoin]>;
29
29
  /** Copy the address and say so in a toast, in the app's own words. */
30
30
  onCopy: (coin: CryptoCoin, network: CryptoNetwork) => void;
@@ -36,6 +36,8 @@
36
36
 
37
37
  setContext(FIELD_ROW, () => label);
38
38
  const inGroup = getContext<boolean | undefined>(FIELD_ROW_GROUP) ?? false;
39
+ // A control in the row may take the row away before its click bubbles up,
40
+ // which empties this binding, so the row's own click takes the row from the event.
39
41
  let row: HTMLDivElement;
40
42
  $effect(() => watchRowStack(row));
41
43
  </script>
@@ -52,7 +54,7 @@
52
54
  bind:this={row}
53
55
  onclick={(e) => {
54
56
  onclick?.(e);
55
- pressRowSwitch(row, e.target);
57
+ pressRowSwitch(e.currentTarget, e.target);
56
58
  }}
57
59
  class={["glim-field-row", wide && "glim-field-row--wide", className].filter(Boolean).join(" ")}>
58
60
  <span class="glim-field-row-name">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimstone/svelte",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "GlimStone's components for Svelte",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -146,7 +146,7 @@
146
146
  "build": "svelte-package -i src -o dist"
147
147
  },
148
148
  "dependencies": {
149
- "@glimstone/core": "5.0.3"
149
+ "@glimstone/core": "5.0.5"
150
150
  },
151
151
  "peerDependencies": {
152
152
  "@internationalized/date": "^3.12.4",