Skip to content

Commit 6035cb3

Browse files
kixelatedclaude
andauthored
fix(moq-boy): mute by default, escape to collapse, center grid (#1251)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ccb1601 commit 6035cb3

5 files changed

Lines changed: 13 additions & 17 deletions

File tree

js/moq-boy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@moq/boy",
33
"type": "module",
4-
"version": "0.2.1",
4+
"version": "0.2.2",
55
"description": "MoQ Boy - Crowd-controlled Game Boy streaming via MoQ",
66
"license": "(MIT OR Apache-2.0)",
77
"repository": {

js/moq-boy/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,6 @@ export class Game {
154154
this.#signals.run(this.#runCommands.bind(this, connection));
155155
}
156156

157-
/** Toggle this game's expanded state. */
158-
toggleExpand() {
159-
this.expanded.update((old) => (old === this.sessionId ? undefined : this.sessionId));
160-
}
161-
162157
/** Send a button state update. */
163158
sendButtons() {
164159
this.sendCommand({ type: "buttons", buttons: [...this.heldButtons] });

js/moq-boy/src/ui/components/Controls.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createAccessor } from "@moq/signals/solid";
2-
import { createSignal, For } from "solid-js";
1+
import { createAccessor, createPair } from "@moq/signals/solid";
2+
import { For } from "solid-js";
33
import { useGameUI } from "../hooks/use-boy-ui";
44

55
/** All game controls: D-pad, A/B, Start/Select, Mute, Reset, Jitter slider, Key hints. */
@@ -8,13 +8,11 @@ export default function Controls() {
88
const game = ctx.game;
99

1010
const jitter = createAccessor(game.jitter);
11-
const [userMuted, setUserMuted] = createSignal(game.userMuted.peek());
11+
const [userMuted, setUserMuted] = createPair(game.userMuted);
1212

1313
const toggleMute = (e: MouseEvent) => {
1414
e.stopPropagation();
15-
const muted = !game.userMuted.peek();
16-
game.userMuted.set(muted);
17-
setUserMuted(muted);
15+
setUserMuted((prev) => !prev);
1816
};
1917

2018
const onReset = (e: MouseEvent) => {

js/moq-boy/src/ui/components/GameCard.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ function GameCardInner() {
2727
game.videoRenderer.canvas.set(canvasRef);
2828
});
2929

30-
// Keyboard input.
30+
// Keyboard input — preventDefault when expanded or hovered.
31+
const isActive = () => game.expanded.peek() === game.sessionId || game.hovered.peek();
32+
3133
const onKeyDown = (e: KeyboardEvent) => {
32-
if (!game.active.peek()) return;
34+
if (!isActive()) return;
3335
if (e.repeat) return;
3436

3537
const button = KEY_MAP[e.key];
@@ -44,7 +46,7 @@ function GameCardInner() {
4446
};
4547

4648
const onKeyUp = (e: KeyboardEvent) => {
47-
if (!game.active.peek()) return;
49+
if (!isActive()) return;
4850
const button = KEY_MAP[e.key];
4951
if (button) {
5052
game.heldButtons.delete(button);
@@ -94,12 +96,12 @@ function GameCardInner() {
9496
ref={canvasRef}
9597
class="boy__video"
9698
tabIndex={0}
97-
onClick={() => game.toggleExpand()}
99+
onClick={() => game.expanded.set(game.sessionId)}
98100
onKeyDown={(e) => {
99101
if (e.key === " ") {
100102
e.preventDefault();
101103
e.stopPropagation();
102-
game.toggleExpand();
104+
game.expanded.set(game.sessionId);
103105
}
104106
}}
105107
/>

js/moq-boy/src/ui/styles/grid.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
.boy__grid {
2424
display: flex;
2525
flex-wrap: wrap;
26+
justify-content: center;
2627
gap: var(--spacing-16);
2728
padding: var(--spacing-16);
2829
}

0 commit comments

Comments
 (0)