@hadoku/game-ui 0.1.155 → 0.1.156

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.
@@ -0,0 +1,58 @@
1
+ /*
2
+ * The edge cue (the operator, 2026-11-02: "i would prefer if there was a '>' or '<' for which
3
+ * direction the extra cards are"): a fade with a small chevron in it, on each edge a sideways
4
+ * scroller can still scroll toward. `./edgeCue.ts` toggles the two classes; this draws them on the
5
+ * scroller's own `::before` (`‹`) and `::after` (`›`), so the scroller has no child of its own for
6
+ * them. Drawn first for portrait's lanes (`portrait.css`); the pod's seats and its bracket draw the
7
+ * same one.
8
+ *
9
+ * The scroller is a flex row. Each cue sits in it, sticky to its edge, and takes no room: its
10
+ * negative margin cancels its own width and the gap before it, so nothing moves when a cue appears.
11
+ * Sticky insets count from inside the scroller's padding, hence the negative padding that puts the
12
+ * cue flush with its visible edge. Vertically centred, over what peeks out from under it.
13
+ *
14
+ * A scroller sets, where they are not 0:
15
+ * --edge-cue-gap its own column gap
16
+ * --edge-cue-pad-l its left padding
17
+ * --edge-cue-pad-r its right padding
18
+ * --edge-cue-tail the room it keeps after its last item with its own `::after` (the cue keeps it too)
19
+ * --edge-cue-bg what it stands on, when that is not the page (a card): the colour the fade ends in
20
+ */
21
+ .edge-cue.edge-cue--r::after,
22
+ .edge-cue.edge-cue--l::before {
23
+ --cue-w: 24px;
24
+
25
+ position: sticky;
26
+ align-self: stretch;
27
+ flex: none;
28
+ width: var(--cue-w);
29
+ box-sizing: border-box;
30
+ display: flex;
31
+ align-items: center;
32
+ padding-inline: 3px;
33
+ color: var(--color-text);
34
+ font-size: 20px;
35
+ font-weight: 700;
36
+ line-height: 1;
37
+ text-shadow: 0 0 4px var(--edge-cue-bg, var(--color-bg));
38
+ pointer-events: none;
39
+ z-index: 1;
40
+ }
41
+
42
+ .edge-cue.edge-cue--r::after {
43
+ content: '›';
44
+ right: calc(-1 * var(--edge-cue-pad-r, 0px));
45
+ order: 999;
46
+ justify-content: flex-end;
47
+ margin-left: calc(var(--edge-cue-tail, 0px) - var(--cue-w) - var(--edge-cue-gap, 0px));
48
+ background: linear-gradient(90deg, transparent, var(--edge-cue-bg, var(--color-bg)));
49
+ }
50
+
51
+ .edge-cue.edge-cue--l::before {
52
+ content: '‹';
53
+ left: calc(-1 * var(--edge-cue-pad-l, 0px));
54
+ order: -999;
55
+ justify-content: flex-start;
56
+ margin-right: calc(-1 * (var(--cue-w) + var(--edge-cue-gap, 0px)));
57
+ background: linear-gradient(-90deg, transparent, var(--edge-cue-bg, var(--color-bg)));
58
+ }
@@ -0,0 +1,14 @@
1
+ import { type RefObject } from 'react';
2
+ import './EdgeCue.css';
3
+ /**
4
+ * Mark `el`'s edges: `edge-cue--l` while it can scroll left, `edge-cue--r` while it can scroll right.
5
+ * Drawn only where `el` also has the class `edge-cue`, which its owner gives it (portrait's lanes have it
6
+ * only in portrait, so a lane measured once in portrait draws nothing back on the desktop board).
7
+ */
8
+ export declare function measureEdgeCue(el: HTMLElement): void;
9
+ /**
10
+ * Keep `ref`'s scroller's edge cue current: on its scroll, on a change of its own size (a window
11
+ * resized across a breakpoint), and after every commit of the component that draws it, since an item
12
+ * arriving or leaving changes its `scrollWidth` without resizing its box.
13
+ */
14
+ export declare function useEdgeCue(ref: RefObject<HTMLElement | null>): void;
@@ -0,0 +1,46 @@
1
+ /*
2
+ * A sideways scroller's edge cue (`./EdgeCue.css`): the fade and chevron on each edge it can still
3
+ * scroll toward. The direction is the information, so there is no count and no element: two classes
4
+ * on the scroller, toggled imperatively, since a scroll fires every frame while a finger drags it and
5
+ * two class toggles cost far less than a React render for the same frame.
6
+ */
7
+ import { useEffect, useLayoutEffect } from 'react';
8
+ import './EdgeCue.css';
9
+ const SCROLLS = new Set(['auto', 'scroll']);
10
+ /**
11
+ * Mark `el`'s edges: `edge-cue--l` while it can scroll left, `edge-cue--r` while it can scroll right.
12
+ * Drawn only where `el` also has the class `edge-cue`, which its owner gives it (portrait's lanes have it
13
+ * only in portrait, so a lane measured once in portrait draws nothing back on the desktop board).
14
+ */
15
+ export function measureEdgeCue(el) {
16
+ // A strip that overflows without scrolling (a game drawing the seats in a row that spills on purpose) has no edge to cue.
17
+ const scrolls = SCROLLS.has(getComputedStyle(el).overflowX);
18
+ // A pixel of slack either way, for a fractional `scrollLeft`.
19
+ const room = scrolls ? el.scrollWidth - el.clientWidth : 0;
20
+ el.classList.toggle('edge-cue--l', el.scrollLeft > 1);
21
+ el.classList.toggle('edge-cue--r', el.scrollLeft < room - 1);
22
+ }
23
+ /**
24
+ * Keep `ref`'s scroller's edge cue current: on its scroll, on a change of its own size (a window
25
+ * resized across a breakpoint), and after every commit of the component that draws it, since an item
26
+ * arriving or leaving changes its `scrollWidth` without resizing its box.
27
+ */
28
+ export function useEdgeCue(ref) {
29
+ useLayoutEffect(() => {
30
+ if (ref.current !== null)
31
+ measureEdgeCue(ref.current);
32
+ });
33
+ useEffect(() => {
34
+ const el = ref.current;
35
+ if (el === null)
36
+ return undefined;
37
+ const measure = () => measureEdgeCue(el);
38
+ el.addEventListener('scroll', measure, { passive: true });
39
+ const resized = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
40
+ resized?.observe(el);
41
+ return () => {
42
+ el.removeEventListener('scroll', measure);
43
+ resized?.disconnect();
44
+ };
45
+ }, [ref]);
46
+ }
@@ -10,7 +10,8 @@
10
10
  *
11
11
  * strip --seat-list-gap, -list-justify, -list-align, -list-min-width, -list-margin,
12
12
  * --seat-list-narrow-wrap, -narrow-overflow-x, -narrow-overflow-y, -narrow-padding,
13
- * -narrow-tail (the trailing spacer's `content`)
13
+ * -narrow-tail (the trailing spacer's `content`), -narrow-bg (what the strip stands on,
14
+ * where its edge cue's fade ends)
14
15
  * seat --seat-position, -gap, -width, -min-width, -flex, -wrap-position, -wrap-display
15
16
  * avatar --seat-avatar-display, -size, -border, -edge, -radius, -bg, -ink, -text, -weight,
16
17
  * -overflow, -flex, -fit, -rendering, --seat-ready-ring, --seat-unready-edge
@@ -40,9 +41,11 @@
40
41
 
41
42
  /*
42
43
  * Below 560px, eight wrapped seats (each with its buttons under it) filled a phone's whole first
43
- * screen, so the strip becomes one row that scrolls sideways. The scroller clips at its padding
44
- * edge, so 6px clears the ready ring's 3px and a focus outline; the trailing spacer is a real flex
45
- * item because Chromium does not count a scroller's own trailing padding toward its extent.
44
+ * screen, so the strip becomes one row that scrolls sideways, with the edge cue on each edge it can
45
+ * still scroll toward (`../components/EdgeCue.css`). The scroller clips at its padding edge, so 6px
46
+ * clears the ready ring's 3px and a focus outline; the trailing spacer is a real flex item because
47
+ * Chromium does not count a scroller's own trailing padding toward its extent, and the right cue,
48
+ * drawn on that same `::after`, keeps its room.
46
49
  */
47
50
  @media (max-width: 560px) {
48
51
  .pod-seats {
@@ -50,6 +53,10 @@
50
53
  overflow-x: var(--seat-list-narrow-overflow-x, auto);
51
54
  overflow-y: var(--seat-list-narrow-overflow-y, hidden);
52
55
  padding: var(--seat-list-narrow-padding, 6px 0 6px 6px);
56
+ --edge-cue-gap: var(--seat-list-gap, 14px);
57
+ --edge-cue-pad-l: 6px;
58
+ --edge-cue-tail: calc(var(--seat-list-gap, 14px) + 6px);
59
+ --edge-cue-bg: var(--seat-list-narrow-bg, var(--color-bg-card));
53
60
  }
54
61
 
55
62
  .pod-seats::after {
@@ -14,7 +14,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  * Its paint is `./SeatChip.css`, after `.ct-action`'s: a game drawing the seats at its own scale
15
15
  * (bomberman's overlay, over its board) sets that file's custom properties, never a copy of it.
16
16
  */
17
+ import { useRef } from 'react';
17
18
  import { ActionButton } from "../components/ActionButton.js";
19
+ import { useEdgeCue } from "../components/edgeCue.js";
18
20
  import { Avatar } from "../components/Avatar.js";
19
21
  import { PlayerName } from "../room/look.js";
20
22
  import { StatusPill } from "../components/StatusPill.js";
@@ -24,7 +26,10 @@ import './SeatChip.css';
24
26
  export const SEAT_CROWN_PATH = 'M2 9V3.5l2.2 2L6 2.6l1.8 2.9L10 3.5V9Z';
25
27
  /** A strip of seats, one `<li>` each: dashed-open / "×"-closed / the bot's own look / a member's avatar, a label underneath, every action its own always-visible button. */
26
28
  export function SeatList({ slots, iLead, shut = false, readiness = true, fieldFixed = false, realSeatCount, mySeat, onSit, onBotOn, onBotOff, onCloseSeat, onOpenSeat, onRemoveMember, onBotReplace, onMakeLeader }) {
27
- return (_jsx("ul", { className: "pod-seats", "data-testid": "pod-seats", children: slots.map(({ seat, occupant }) => {
29
+ // Below 560px the strip scrolls sideways: its edges say which way more seats are.
30
+ const strip = useRef(null);
31
+ useEdgeCue(strip);
32
+ return (_jsx("ul", { className: "pod-seats edge-cue", "data-testid": "pod-seats", ref: strip, children: slots.map(({ seat, occupant }) => {
28
33
  if (occupant.kind === 'open') {
29
34
  return (_jsxs("li", { className: "pod-seats__seat", "data-testid": `pod-seat-${seat}`, children: [_jsx(ActionButton, { action: "sit", className: "pod-seats__avatar pod-seats__avatar--open", "data-testid": "pod-seat-sit", "data-seat": seat, "aria-label": `Sit in seat ${seat + 1}`, disabled: shut || (mySeat !== null && seat >= realSeatCount), onPress: () => onSit?.(seat), children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M12 5v14M5 12h14" }) }) }), _jsx("span", { className: "pod-seats__label", children: "Open" }), !fieldFixed && iLead && (_jsxs("span", { className: "pod-seats__actions", children: [_jsx(ActionButton, { action: "ai", className: "pod-seats__action ct-action", "data-testid": "pod-seat-ai", "data-seat": seat, "aria-label": `Fill seat ${seat + 1} with AI`, disabled: shut, onPress: () => onBotOn?.(seat), children: _jsx("span", { className: "ct-action__label", children: "AI" }) }), seat < realSeatCount && (_jsx(ActionButton, { action: "close", className: "pod-seats__action ct-action", "data-testid": "pod-seat-close", "data-seat": seat, "aria-label": `Close seat ${seat + 1}`, onPress: () => onCloseSeat?.(seat), children: _jsx("span", { className: "ct-action__label", children: "Close" }) }))] }))] }, seat));
30
35
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-ui",
3
- "version": "0.1.155",
4
- "gitHead": "57586f6329004b90a6811e9fbea44892db00bc76",
3
+ "version": "0.1.156",
4
+ "gitHead": "496faea307d7bf63bcf9c3b3c3c8bbb3e4147297",
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.",
@@ -54,8 +54,8 @@
54
54
  "react-dom": "^19.2.8"
55
55
  },
56
56
  "dependencies": {
57
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.159",
58
- "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.159",
57
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.160",
58
+ "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.160",
59
59
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.2",
60
60
  "@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.143",
61
61
  "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.143",