@hadoku/game-ui 0.1.46 → 0.1.47
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.
- package/dist/front/Gallery.js +5 -17
- package/dist/front/gallery.d.ts +0 -4
- package/dist/front/gallery.js +1 -9
- package/dist/front/icons.d.ts +3 -2
- package/dist/front/icons.js +3 -3
- package/package.json +4 -4
package/dist/front/Gallery.js
CHANGED
|
@@ -2,12 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
/*
|
|
3
3
|
* A front card as a manual gallery (`./gallery.ts`): one page at a time, its title in the card's
|
|
4
4
|
* head with the arrows beside it, its own action in the foot with the dots. The reader turns it
|
|
5
|
-
* with the arrows
|
|
5
|
+
* with the arrows or a dot; it never turns itself, and a drag across a page selects its text
|
|
6
|
+
* (the operator, 2026-11-18: the swipe that once turned it took every highlight). Upcoming (Calendar | Polls)
|
|
6
7
|
* and the wildcard are both one.
|
|
7
8
|
*/
|
|
8
|
-
import {
|
|
9
|
+
import { useState } from 'react';
|
|
9
10
|
import { playRole } from "../sound/index.js";
|
|
10
|
-
import { keepPage, stepPage
|
|
11
|
+
import { keepPage, stepPage } from "./gallery.js";
|
|
11
12
|
/**
|
|
12
13
|
* The arrow inside a gallery's round button, drawn, not typed: a text ‹ › sits wherever its font
|
|
13
14
|
* puts the glyph in its line box (1.25 px low and 0.4 px aside, measured on Linux; it moves with the
|
|
@@ -21,7 +22,6 @@ export function Gallery({ testId, pages, opening }) {
|
|
|
21
22
|
const [key, setKey] = useState(null);
|
|
22
23
|
const at = keepPage(pages.map((p) => p.key), key ?? opening ?? null, 0);
|
|
23
24
|
const page = pages[at];
|
|
24
|
-
const down = useRef(null);
|
|
25
25
|
if (page === undefined)
|
|
26
26
|
return null;
|
|
27
27
|
const turn = (to) => {
|
|
@@ -32,17 +32,5 @@ export function Gallery({ testId, pages, opening }) {
|
|
|
32
32
|
setKey(next.key);
|
|
33
33
|
};
|
|
34
34
|
const many = pages.length > 1;
|
|
35
|
-
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: "front-card__head", children: [_jsx("h3", { className: "front-card__title", "data-testid": `${testId}-title`, children: page.title }), many && (_jsxs("span", { className: "gallery__arrows", children: [_jsx("button", { type: "button", className: "gallery__arrow", "aria-label": "Previous", "data-testid": `${testId}-prev`, onClick: () => turn(stepPage(at, -1, pages.length)), children: _jsx(ArrowGlyph, { dir: "prev" }) }), _jsx("button", { type: "button", className: "gallery__arrow", "aria-label": "Next", "data-testid": `${testId}-next`, onClick: () => turn(stepPage(at, 1, pages.length)), children: _jsx(ArrowGlyph, { dir: "next" }) })] }))] }), _jsx("div", { className: "gallery__page", "data-testid": `${testId}-page`, "data-page": page.key,
|
|
36
|
-
down.current = { x: e.clientX, y: e.clientY };
|
|
37
|
-
}, onPointerUp: (e) => {
|
|
38
|
-
const from = down.current;
|
|
39
|
-
down.current = null;
|
|
40
|
-
if (from === null || !many)
|
|
41
|
-
return;
|
|
42
|
-
const step = swipeStep(e.clientX - from.x, e.clientY - from.y);
|
|
43
|
-
if (step !== 0)
|
|
44
|
-
turn(stepPage(at, step, pages.length));
|
|
45
|
-
}, onPointerCancel: () => {
|
|
46
|
-
down.current = null;
|
|
47
|
-
}, children: page.body }, page.key), (many || page.action !== undefined) && (_jsxs("div", { className: "front-card__foot", children: [many && (_jsx("span", { className: "gallery__dots", children: pages.map((p, i) => (_jsx("button", { type: "button", className: "gallery__dot", "aria-label": p.title, "aria-current": i === at ? 'true' : undefined, "data-testid": `${testId}-dot`, "data-page": p.key, onClick: () => turn(i) }, p.key))) })), page.action] }))] }));
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsxs("header", { className: "front-card__head", children: [_jsx("h3", { className: "front-card__title", "data-testid": `${testId}-title`, children: page.title }), many && (_jsxs("span", { className: "gallery__arrows", children: [_jsx("button", { type: "button", className: "gallery__arrow", "aria-label": "Previous", "data-testid": `${testId}-prev`, onClick: () => turn(stepPage(at, -1, pages.length)), children: _jsx(ArrowGlyph, { dir: "prev" }) }), _jsx("button", { type: "button", className: "gallery__arrow", "aria-label": "Next", "data-testid": `${testId}-next`, onClick: () => turn(stepPage(at, 1, pages.length)), children: _jsx(ArrowGlyph, { dir: "next" }) })] }))] }), _jsx("div", { className: "gallery__page", "data-testid": `${testId}-page`, "data-page": page.key, children: page.body }, page.key), (many || page.action !== undefined) && (_jsxs("div", { className: "front-card__foot", children: [many && (_jsx("span", { className: "gallery__dots", children: pages.map((p, i) => (_jsx("button", { type: "button", className: "gallery__dot", "aria-label": p.title, "aria-current": i === at ? 'true' : undefined, "data-testid": `${testId}-dot`, "data-page": p.key, onClick: () => turn(i) }, p.key))) })), page.action] }))] }));
|
|
48
36
|
}
|
package/dist/front/gallery.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
/** How far a sideways drag must travel to turn the page. */
|
|
2
|
-
export declare const SWIPE_PX = 40;
|
|
3
1
|
/** One page on from `index` (`delta` ±1), wrapping at both ends. */
|
|
4
2
|
export declare function stepPage(index: number, delta: number, count: number): number;
|
|
5
|
-
/** A drag of `dx`×`dy` px as a page step: ±1 past the threshold, 0 for a short or mostly vertical one (scrolling a list). */
|
|
6
|
-
export declare function swipeStep(dx: number, dy: number): -1 | 0 | 1;
|
|
7
3
|
/**
|
|
8
4
|
* The Upcoming card's page as the front page opens: Polls when it has something and Calendar has
|
|
9
5
|
* nothing (the operator, 2026-11-04), else Calendar.
|
package/dist/front/gallery.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* The front cards' manual gallery (`./Gallery.tsx`): pages the reader flips with the arrows, the
|
|
3
|
-
* dots
|
|
3
|
+
* dots, and never on a timer. The pure steps, so they are tested without mounting it.
|
|
4
4
|
*/
|
|
5
|
-
/** How far a sideways drag must travel to turn the page. */
|
|
6
|
-
export const SWIPE_PX = 40;
|
|
7
5
|
/** One page on from `index` (`delta` ±1), wrapping at both ends. */
|
|
8
6
|
export function stepPage(index, delta, count) {
|
|
9
7
|
if (count <= 1)
|
|
10
8
|
return 0;
|
|
11
9
|
return (((index + delta) % count) + count) % count;
|
|
12
10
|
}
|
|
13
|
-
/** A drag of `dx`×`dy` px as a page step: ±1 past the threshold, 0 for a short or mostly vertical one (scrolling a list). */
|
|
14
|
-
export function swipeStep(dx, dy) {
|
|
15
|
-
if (Math.abs(dx) < SWIPE_PX || Math.abs(dy) > Math.abs(dx))
|
|
16
|
-
return 0;
|
|
17
|
-
return dx < 0 ? 1 : -1;
|
|
18
|
-
}
|
|
19
11
|
/**
|
|
20
12
|
* The Upcoming card's page as the front page opens: Polls when it has something and Calendar has
|
|
21
13
|
* nothing (the operator, 2026-11-04), else Calendar.
|
package/dist/front/icons.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ export declare function TrophyIcon({ size }: {
|
|
|
14
14
|
export declare function LockIcon({ size }: {
|
|
15
15
|
size?: number;
|
|
16
16
|
}): import("react").JSX.Element;
|
|
17
|
-
/** A
|
|
18
|
-
export declare function PersonIcon({ size }: {
|
|
17
|
+
/** A count of people: a room's seats unless `label` says what it counts. */
|
|
18
|
+
export declare function PersonIcon({ size, label }: {
|
|
19
19
|
size?: number;
|
|
20
|
+
label?: string;
|
|
20
21
|
}): import("react").JSX.Element;
|
|
21
22
|
/** Classic: crossed swords — blade, point, guard, grip and pommel each. */
|
|
22
23
|
export declare function SwordsIcon({ size }: {
|
package/dist/front/icons.js
CHANGED
|
@@ -35,9 +35,9 @@ export function TrophyIcon({ size = 16 }) {
|
|
|
35
35
|
export function LockIcon({ size = 15 }) {
|
|
36
36
|
return (_jsxs(Glyph, { label: "Locked", size: size, children: [_jsx("rect", { x: "5", y: "11", width: "14", height: "10", rx: "2" }), _jsx("path", { d: "M8 11V7a4 4 0 0 1 8 0v4" })] }));
|
|
37
37
|
}
|
|
38
|
-
/** A
|
|
39
|
-
export function PersonIcon({ size = 14 }) {
|
|
40
|
-
return (_jsxs(Glyph, { label:
|
|
38
|
+
/** A count of people: a room's seats unless `label` says what it counts. */
|
|
39
|
+
export function PersonIcon({ size = 14, label = 'Seats' }) {
|
|
40
|
+
return (_jsxs(Glyph, { label: label, size: size, children: [_jsx("circle", { cx: "12", cy: "8", r: "3.2" }), _jsx("path", { d: "M5.5 20c0-3.6 2.9-6 6.5-6s6.5 2.4 6.5 6" })] }));
|
|
41
41
|
}
|
|
42
42
|
/** Classic: crossed swords — blade, point, guard, grip and pommel each. */
|
|
43
43
|
export function SwordsIcon({ size = 14 }) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/game-ui",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.47",
|
|
4
|
+
"gitHead": "caad21298cc7023d10fe8931969d2539795931fa",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The browser parts any hosted game shares, above ui-shell: the room shell and session, seats and looks, the room route, the front page's generic pieces (gate, polls, gallery, patch notes), the bundle slot and relay channel a game's client mounts in, settings and trim screens, the HTTP and socket helpers, and the generic components (modal, popover, avatar, action button, radio cards). Knows no game; Magic's UI (games/magic/ui) plugs in, composed by the site (apps/ui). MIT; imports only react, react-dom, socket.io-client, @wolffm/* and the platform packages.",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"react-dom": "^19.2.8"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
53
|
-
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.
|
|
52
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.47",
|
|
53
|
+
"@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.47",
|
|
54
54
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.1.27",
|
|
55
55
|
"@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.111",
|
|
56
56
|
"@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.111",
|