@glimstone/react 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.
|
@@ -22,9 +22,9 @@ export interface CryptoDonateDialogProps {
|
|
|
22
22
|
copyLabel: string;
|
|
23
23
|
closeLabel: string;
|
|
24
24
|
};
|
|
25
|
-
/**
|
|
25
|
+
/** Draws the address in place of the window's own QR code. */
|
|
26
26
|
renderQr?: (value: string) => ReactNode;
|
|
27
|
-
/**
|
|
27
|
+
/** Draws a coin's mark in place of the core's. */
|
|
28
28
|
renderMark?: (coin: CryptoCoin) => ReactNode;
|
|
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;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { hueVars } from "@glimstone/core";
|
|
2
|
+
import { hueVars, qrCode } from "@glimstone/core";
|
|
3
|
+
import { CRYPTO_MARKS } from "@glimstone/core/cryptoMarks";
|
|
3
4
|
import { Badge } from "./Badge.js";
|
|
4
5
|
import { Button } from "./Button.js";
|
|
6
|
+
import { BrandMark } from "./ReadmeButton.js";
|
|
5
7
|
import { useLabelMode } from "./useLabelMode.js";
|
|
8
|
+
const MARKS = CRYPTO_MARKS;
|
|
9
|
+
// A camera reads dark modules on a light ground, so these two colours stay put in every theme.
|
|
10
|
+
function AddressQr({ value }) {
|
|
11
|
+
const code = qrCode(value);
|
|
12
|
+
const side = code.size + 8;
|
|
13
|
+
return (_jsxs("svg", { className: "glim-give-qr", "aria-hidden": "true", viewBox: `-4 -4 ${side} ${side}`, shapeRendering: "crispEdges", children: [_jsx("rect", { x: -4, y: -4, width: side, height: side, fill: "#ffffff" }), _jsx("path", { d: code.path, fill: "#161616" })] }));
|
|
14
|
+
}
|
|
15
|
+
function CoinMark({ coin, renderMark }) {
|
|
16
|
+
if (renderMark)
|
|
17
|
+
return renderMark(coin);
|
|
18
|
+
const mark = MARKS[coin.id];
|
|
19
|
+
return mark ? _jsx(BrandMark, { svg: mark.svg, hover: mark.hover }) : null;
|
|
20
|
+
}
|
|
6
21
|
export function CryptoDonateDialog({ coins, coin, network, onPick, text, renderQr, renderMark, onCopy, onClose, ref, }) {
|
|
7
22
|
// `reactive` shows both mark and ticker here: somebody searching a grid of
|
|
8
23
|
// coins should not have to hover every tile to find USDT.
|
|
@@ -12,12 +27,12 @@ export function CryptoDonateDialog({ coins, coin, network, onPick, text, renderQ
|
|
|
12
27
|
return (_jsx("div", { className: "glim-modal-backdrop", onClick: (e) => {
|
|
13
28
|
if (e.target === e.currentTarget)
|
|
14
29
|
onClose();
|
|
15
|
-
}, children: _jsxs("div", { "data-glim": "CryptoDonateDialog", "data-glim-title": text.title, ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "cryptodonate-title", className: "glim-modal-card glim-modal-card--wide", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "cryptodonate-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body glim-give-body--scroll", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsxs("div", { className: "glim-give-well", children: [renderQr
|
|
30
|
+
}, children: _jsxs("div", { "data-glim": "CryptoDonateDialog", "data-glim-title": text.title, ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "cryptodonate-title", className: "glim-modal-card glim-modal-card--wide", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "cryptodonate-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body glim-give-body--scroll", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsxs("div", { className: "glim-give-well", children: [renderQr ? renderQr(network.address) : _jsx(AddressQr, { value: network.address }), _jsx("p", { dir: "ltr", className: "glim-give-address", children: network.address }), _jsx("div", { className: "glim-give-networks", role: "listbox", "aria-label": text.networks, children: coin.networks.map((n, i) => (_jsx("button", { type: "button", role: "option", "aria-selected": n.id === network.id, onClick: () => onPick(coin, n), style: hueVars(i), className: `glim-give-network glim-hue${n.id === network.id ? " glim-active" : ""}`, children: n.name }, n.id))) }), network.note && _jsx("p", { className: "glim-give-note", children: network.note }), _jsx(Button, { label: text.copyLabel, labelKey: "common.copy", tone: "accent", hueIndex: coins.findIndex((c) => c.id === coin.id), onClick: () => onCopy(coin, network) })] }), _jsx("div", { className: "glim-give-coins", role: "listbox", "aria-label": text.title, children: coins.map((c, i) => {
|
|
16
31
|
const picked = c.id === coin.id;
|
|
17
32
|
const lit = !picked && c.tile;
|
|
18
|
-
return (_jsxs("button", { type: "button", role: "option", "aria-selected": picked, "aria-label": `${c.
|
|
33
|
+
return (_jsxs("button", { type: "button", role: "option", "aria-selected": picked, "aria-label": `${c.symbol}, ${c.name}`, title: c.name, onClick: () => onPick(c, c.networks[0]), style: {
|
|
19
34
|
...hueVars(i),
|
|
20
35
|
...(lit && { "--tile": c.tile.color, "--tile-ink": c.tile.ink }),
|
|
21
|
-
}, className: `glim-give-coin ${showTicker ? "glim-hue glim-hue-icon" : "glim-hue"} ${picked ? "glim-active" : lit ? "glim-brand-tile" : "
|
|
36
|
+
}, className: `glim-give-coin ${showTicker ? "glim-hue glim-hue-icon" : "glim-hue"} ${picked ? "glim-active" : lit ? "glim-brand-tile" : ""}`, children: [showMark && _jsx(CoinMark, { coin: c, renderMark: renderMark }), showTicker && _jsx("span", { className: "glim-give-ticker", children: c.symbol })] }, c.id));
|
|
22
37
|
}) })] }), _jsx("div", { className: "glim-give-foot", children: _jsx(Button, { label: text.closeLabel, labelKey: "common.close", tone: "neutral", onClick: onClose }) })] }) }));
|
|
23
38
|
}
|
package/dist/FieldRow.js
CHANGED
|
@@ -5,6 +5,8 @@ import { FieldRowContext, FieldRowGroupContext } from "./fieldName.js";
|
|
|
5
5
|
import { InfoBubble } from "./InfoBubble.js";
|
|
6
6
|
import { Pill } from "./Pill.js";
|
|
7
7
|
export function FieldRow({ label, drawn, hint, value, tone, wide, children, className, onClick, ...rest }) {
|
|
8
|
+
// A control in the row may take the row away before its click bubbles up,
|
|
9
|
+
// which empties this ref, so the row's own click takes the row from the event.
|
|
8
10
|
const row = useRef(null);
|
|
9
11
|
const inGroup = useContext(FieldRowGroupContext);
|
|
10
12
|
useEffect(() => watchRowStack(row.current), []);
|
|
@@ -12,6 +14,6 @@ export function FieldRow({ label, drawn, hint, value, tone, wide, children, clas
|
|
|
12
14
|
(value !== undefined && (_jsx(Pill, { className: "glim-num", tone: tone, children: value })));
|
|
13
15
|
return (_jsx(FieldRowContext.Provider, { value: label, children: _jsxs("div", { "data-glim": "FieldRow", "data-press": "", ...rest, ref: row, onClick: (e) => {
|
|
14
16
|
onClick?.(e);
|
|
15
|
-
pressRowSwitch(
|
|
17
|
+
pressRowSwitch(e.currentTarget, e.target);
|
|
16
18
|
}, className: ["glim-field-row", wide && "glim-field-row--wide", className].filter(Boolean).join(" "), children: [_jsxs("span", { className: "glim-field-row-name", children: [_jsx("span", { className: "glim-field-row-label", onClick: () => pressRowControl(row.current), children: drawn ?? label }), hint && _jsx(InfoBubble, { tip: hint })] }), inGroup ? _jsx("span", { className: "glim-field-row-controls", children: control }) : control] }) }));
|
|
17
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glimstone/react",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"description": "GlimStone's components for React",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": { "type": "git", "url": "git+https://github.com/junkerderprovinz/glimstone.git", "directory": "packages/react" },
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@glimstone/core": "5.0.
|
|
19
|
+
"@glimstone/core": "5.0.5"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@internationalized/date": "^3.12.4",
|