fix(viewer): place spectator chat beside the turn order

This commit is contained in:
coyotte508 2026-10-31 18:34:35 +01:00
commit f4ee221289
7 changed files with 30 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/old-ui",
"version": "1.2.18",
"version": "1.2.19",
"scripts": {
"serve": "vite --port 5193",
"build": "vite build",

View file

@ -4,7 +4,6 @@
<Charts />
</b-modal>
<Rules id="rules" />
<div class="game-chat-button-host game-chat-button-host--fallback"></div>
<div v-if="analysisNotice || analysisPendingRestore" class="row">
<div class="col-12">
@ -175,6 +174,7 @@
</div>
<FactionBrowser v-if="!setupActionsAtTop" :on-turn="canPlay" />
<span class="game-chat-button-host game-chat-button-host--fallback"></span>
</div>
</div>
<AdvancedLog
@ -225,6 +225,7 @@
@analysis-undo="undoLastAnalysisEntry"
@analysis-reset="resetAnalysisLine"
/>
<span class="game-chat-button-host game-chat-button-host--fallback"></span>
<AdvancedLog :currentMove="currentMove" :hideLog.sync="hideLog" v-if="logPlacement === 'top'" />
<Commands
@command="handleCommand"

View file

@ -1,6 +1,6 @@
{
"name": "@gaia-project/viewer",
"version": "5.22.17",
"version": "5.22.18",
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
"contributors": [
"coyotte508",

View file

@ -4,7 +4,6 @@
<Charts />
</b-modal>
<Rules id="rules" />
<div class="game-chat-button-host game-chat-button-host--fallback"></div>
<!-- Show planning and queue details above the board; own-turn simulation starts beside the actions. -->
<div v-if="analysisNotice || analysisPendingRestore" class="row">
@ -255,6 +254,7 @@
</div>
<FactionBrowser v-if="!setupActionsAtTop" :on-turn="canPlay" />
<span class="game-chat-button-host game-chat-button-host--fallback"></span>
</div>
</div>
<AdvancedLog
@ -297,6 +297,7 @@
<div v-else class="d-flex flex-column">
<SetupStatus v-if="!ended" />
<SpaceMap v-if="hasMap" :class="['mb-1', 'space-map', 'col-md-7']" />
<span class="game-chat-button-host game-chat-button-host--fallback"></span>
<AdvancedLog :currentMove="currentMove" :hideLog.sync="hideLog" v-if="logPlacement === 'top'" />
<Commands
@command="handleCommand"

View file

@ -1,6 +1,9 @@
<template>
<div class="turn-order">
<h5 v-if="!compact">Turn order</h5>
<div v-if="!compact" class="turn-order-heading">
<h5>Turn order</h5>
<span class="game-chat-button-host game-chat-button-host--turn-order"></span>
</div>
<svg viewBox="-1.2 -1.2 12.5 4" :width="compact ? 170 : 250" :height="compact ? 60 : 80" style="max-width: 100%">
<PlayerCircle
v-for="(player, index) in turnOrder"
@ -94,6 +97,16 @@ export default class TurnOrder extends Vue {
</script>
<style lang="scss">
.turn-order {
.turn-order-heading {
display: flex;
align-items: center;
gap: 0.25rem;
margin-bottom: 0.5rem;
h5 {
margin: 0;
}
}
& > svg {
max-width: 250px;
}

View file

@ -39,7 +39,7 @@ describe("game chat icon", () => {
}
);
document.body.innerHTML =
'<div id="host"><div class="game-chat-button-host--fallback"></div><div id="move-title"><span class="game-chat-button-host--desktop"></span></div></div>';
'<div id="host"><div class="game-chat-button-host--fallback"></div><div class="turn-order"><span class="game-chat-button-host--turn-order"></span></div><div id="move-title"><span class="game-chat-button-host--desktop"></span></div></div>';
host = document.querySelector("#host")!;
emitter = new ViewerEmitter();
dispose = mountGameChat(emitter, host);
@ -127,7 +127,7 @@ describe("game chat icon", () => {
expect(button.hidden).toBe(false);
});
it("moves one icon between desktop, mobile and fallback headers when controls remount", async () => {
it("moves one icon between action controls, spectator turn order and the remaining game controls", async () => {
const desktop = host.querySelector(".game-chat-button-host--desktop")!;
const mobile = document.createElement("div");
mobile.className = "mobile-sticky-actions mobile-sticky-actions--collapsed";
@ -146,6 +146,11 @@ describe("game chat icon", () => {
expect(desktop.contains(button)).toBe(true);
desktop.remove();
await Promise.resolve();
const turnOrder = host.querySelector(".turn-order")!;
expect(turnOrder.contains(button)).toBe(true);
button.click();
turnOrder.remove();
await Promise.resolve();
expect(host.querySelector(".game-chat-button-host--fallback")!.contains(button)).toBe(true);
expect(host.querySelectorAll(".game-chat-button")).toHaveLength(1);
});

View file

@ -60,7 +60,8 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, host: Element):
.game-chat-button-host{display:inline-flex;flex-shrink:0;margin-left:auto}
.game-chat-button-host:empty{display:none}
.game-chat-button-host--desktop{margin-left:.4rem}
.game-chat-button-host--fallback{display:flex;justify-content:flex-end}
.game-chat-button-host--turn-order,.game-chat-button-host--fallback{margin-left:0}
.game-chat-button-host--turn-order .game-chat-button{margin:-8px 0}
.game-chat-button{position:relative;display:inline-grid;place-items:center;flex-shrink:0;width:40px;height:40px;padding:7px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--ui-text-muted);cursor:pointer;line-height:1}
.game-chat-button[hidden],.game-chat-unread[hidden]{display:none}
.game-chat-button:hover,.game-chat-button:focus-visible{background:var(--ui-surface-hover);border-color:var(--ui-border);color:var(--ui-text)}
@ -178,6 +179,7 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, host: Element):
const destination =
mobileSlot ||
host.querySelector(".game-chat-button-host--desktop") ||
host.querySelector(".game-chat-button-host--turn-order") ||
host.querySelector(".game-chat-button-host--fallback");
if (destination && button.parentElement !== destination) destination.append(button);
button.hidden = analysis || !chat.snapshot.enabled;