Anchor chat composer and separate activity controls; publish viewer 0.1.189
This commit is contained in:
parent
de6803342f
commit
04f2fe0dcb
5 changed files with 107 additions and 5 deletions
|
|
@ -708,3 +708,13 @@ rather than submitting a normal Construct action. Regression coverage includes
|
|||
neutral and angry activated cities, zero actions, declining, payment, and opponent
|
||||
views. These presentation changes ship in the viewer's bundled rules bridge;
|
||||
the deployed game engine remains unchanged.
|
||||
|
||||
## Viewer 0.1.189 / engine unchanged (0.4.126)
|
||||
|
||||
Anchor the chat composer and Send button at the bottom of the activity panel,
|
||||
letting the message list fill and scroll within the remaining space. Browsers
|
||||
without `::details-content` retain the protocol's bounded message list. Position
|
||||
the activity close button in the top-right corner with a 44px touch target, reserve
|
||||
space for it in the tabs, and separate the mobile minimize control from it.
|
||||
Includes desktop/mobile browser layout regression checks with empty, short and
|
||||
long chat histories. No engine or bundled rules bridge changes.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.188",
|
||||
"version": "0.1.189",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.188",
|
||||
"version": "0.1.189",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.188",
|
||||
"version": "0.1.189",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
62
web-client/scripts/chat-layout.test.mjs
Normal file
62
web-client/scripts/chat-layout.test.mjs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Run explicitly with: node --test scripts/chat-layout.test.mjs
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const css = await readFile(new URL('../src/style.css', import.meta.url), 'utf8');
|
||||
const protocolSource = await readFile(
|
||||
new URL('../node_modules/@boardgamers/protocol/dist/chat-dom.js', import.meta.url), 'utf8',
|
||||
);
|
||||
const protocolCss = protocolSource.split('const styles = `')[1].split('`;')[0];
|
||||
|
||||
test('chat composer stays at the bottom and close/minimize controls do not overlap', async () => {
|
||||
const browser = await chromium.launch();
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
assert(await page.evaluate(() => CSS.supports('selector(::details-content)')));
|
||||
for (const width of [390, 1400]) {
|
||||
for (const count of [0, 2, 60]) {
|
||||
await page.setViewportSize({ width, height: 800 });
|
||||
await page.setContent(`<style>${protocolCss}\n${css}</style>
|
||||
<div class="game-shell"><section class="activity floating-panel mobile-minimize-positioned mobile-minimize-has-close"
|
||||
style="position:absolute;top:10px;left:10px;width:360px;height:500px">
|
||||
<button class="mobile-panel-minimize">−</button>
|
||||
<div class="activity-tabs"><button>Journal</button><button>Chat</button>
|
||||
<button class="icon-button close-activity">×</button></div>
|
||||
<div class="chat-panel"><details open class="bgs-game-chat"><summary>Chat</summary>
|
||||
<div class="chat-messages"><div class="chat-contents">${'<article>Message</article>'.repeat(count)}</div></div>
|
||||
<div class="chat-composer"><input><button>Send</button></div><div class="chat-status"></div>
|
||||
</details></div>
|
||||
</section></div>`);
|
||||
const boxes = await page.evaluate(() => {
|
||||
const rect = (selector) => document.querySelector(selector).getBoundingClientRect().toJSON();
|
||||
return {
|
||||
panel: rect('.activity'), composer: rect('.chat-composer'), close: rect('.close-activity'),
|
||||
minimize: rect('.mobile-panel-minimize'), messages: rect('.chat-messages'),
|
||||
scroll: document.querySelector('.chat-messages').scrollHeight,
|
||||
};
|
||||
});
|
||||
const context = JSON.stringify({ width, count, boxes });
|
||||
assert(boxes.panel.bottom - boxes.composer.bottom < 35, context);
|
||||
assert(boxes.composer.bottom <= boxes.panel.bottom, context);
|
||||
assert(boxes.panel.right - boxes.close.right < 8, context);
|
||||
assert(boxes.close.top - boxes.panel.top < 3, context);
|
||||
assert.equal(boxes.close.width, 44, context);
|
||||
assert.equal(boxes.close.height, 44, context);
|
||||
assert(boxes.messages.bottom <= boxes.composer.top, context);
|
||||
if (width === 390) assert(boxes.minimize.right < boxes.close.left, context);
|
||||
if (count === 60) assert(boxes.scroll > boxes.messages.height, context);
|
||||
}
|
||||
}
|
||||
// Simulate an older browser rejecting the feature query: keep its scroll cap.
|
||||
await page.setContent(`<style>${protocolCss}\n${css.replace('@supports selector(::details-content)', '@supports (unknown-chat-feature: yes)')}</style>
|
||||
<div class="chat-panel" style="height:400px"><details open class="bgs-game-chat">
|
||||
<div class="chat-messages">${'<article>Message</article>'.repeat(60)}</div>
|
||||
<div class="chat-composer"><input><button>Send</button></div>
|
||||
</details></div>`);
|
||||
assert.notEqual(await page.locator('.chat-messages').evaluate((el) => getComputedStyle(el).maxHeight), 'none');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
});
|
||||
|
|
@ -1417,6 +1417,27 @@ small {
|
|||
padding: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.chat-panel .bgs-game-chat {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* Keep the protocol's bounded message list on older details implementations. */
|
||||
@supports selector(::details-content) {
|
||||
.chat-panel .bgs-game-chat::details-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
.chat-panel .bgs-game-chat .chat-messages {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
}
|
||||
.chat-panel .bgs-game-chat .chat-composer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
.chat-panel details {
|
||||
border: 0 !important;
|
||||
background: transparent !important;
|
||||
|
|
@ -2396,7 +2417,15 @@ small {
|
|||
margin-left: auto;
|
||||
}
|
||||
.activity-tabs button.close-activity {
|
||||
width: 26px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 4px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
justify-content: center;
|
||||
}
|
||||
.activity-tabs {
|
||||
padding-right: 56px;
|
||||
}
|
||||
.end-confirm {
|
||||
display: flex;
|
||||
|
|
@ -5212,7 +5241,8 @@ small {
|
|||
background: var(--paper);
|
||||
}
|
||||
.game-shell .mobile-minimize-positioned.mobile-minimize-has-close > .mobile-panel-minimize {
|
||||
right: 44px;
|
||||
/* Leave a gap beside the close control's 44px mobile touch target. */
|
||||
right: 56px;
|
||||
}
|
||||
.mobile-minimize-positioned > h2 {
|
||||
padding-right: 40px;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue