Keep the mobile board scrollable and let chat scroll into view
This commit is contained in:
parent
fed212b4a6
commit
c88540c103
6 changed files with 29 additions and 43 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "container-viewer",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/boardgamers/container.git",
|
||||
|
|
|
|||
|
|
@ -143,6 +143,28 @@ try {
|
|||
const el = document.querySelector('.chat-messages');
|
||||
return el && Math.abs(el.scrollHeight - el.scrollTop - el.clientHeight) < 3;
|
||||
});
|
||||
if (width < 1000) {
|
||||
await page.setViewportSize({ width, height: 600 });
|
||||
await panel.evaluate((el) => window.scrollTo(0, window.scrollY + el.getBoundingClientRect().top - 400));
|
||||
await list.evaluate((el) => {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
});
|
||||
const point = await list.evaluate((el) => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return { x: rect.left + 50, y: rect.top + 50 };
|
||||
});
|
||||
await page.mouse.move(point.x, point.y);
|
||||
await page.mouse.wheel(0, 500);
|
||||
await page.waitForFunction(
|
||||
() => {
|
||||
const composer = document.querySelector('.chat-composer').getBoundingClientRect();
|
||||
return composer.bottom <= window.innerHeight + 1;
|
||||
},
|
||||
null,
|
||||
{ timeout: 3000 }
|
||||
);
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
}
|
||||
assert.equal(await panel.locator('summary').textContent(), 'Chat', 'old history is not unread');
|
||||
await input.fill('@');
|
||||
assert.deepEqual(await panel.locator('.chat-suggestions button').allTextContents(), ['@Ada Lovelace', '@Bob']);
|
||||
|
|
|
|||
|
|
@ -22,27 +22,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<div v-if="G" class="mobile-board-navigation" aria-label="Board view">
|
||||
<button
|
||||
class="board-view-toggle"
|
||||
:aria-pressed="mobileOverview"
|
||||
:aria-label="mobileOverview ? 'Enlarge board' : 'Board overview'"
|
||||
:title="mobileOverview ? 'Enlarge board' : 'Board overview'"
|
||||
@click="mobileOverview = !mobileOverview"
|
||||
>
|
||||
<svg v-if="mobileOverview" viewBox="0 0 20 20" aria-hidden="true">
|
||||
<path d="M7 3H3v4m10-4h4v4M3 13v4h4m10-4v4h-4M3 3l5 5m9-5-5 5M3 17l5-5m9 5-5-5" />
|
||||
</svg>
|
||||
<svg v-else viewBox="0 0 20 20" aria-hidden="true">
|
||||
<rect x="3" y="3" width="14" height="14" rx="1" />
|
||||
<path d="M3 8h14M8 3v14M12 8v9M8 12h9" />
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
class="player-board-tab"
|
||||
v-for="(p, i) in G.players"
|
||||
:key="i"
|
||||
:style="{ '--player-colour': playerColors[i] }"
|
||||
:aria-pressed="!mobileOverview && mobilePlayer === i"
|
||||
:aria-pressed="mobilePlayer === i"
|
||||
:title="p.name"
|
||||
@click="viewPlayerBoard(i)"
|
||||
>
|
||||
|
|
@ -65,12 +50,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div key="board-and-journal" class="board-and-journal">
|
||||
<div
|
||||
ref="boardScroll"
|
||||
:class="['board-scroll', { overview: mobileOverview }]"
|
||||
tabindex="0"
|
||||
aria-label="Game board"
|
||||
>
|
||||
<div ref="boardScroll" class="board-scroll" tabindex="0" aria-label="Game board">
|
||||
<svg
|
||||
@click="ui.selected = null"
|
||||
@keydown.esc="ui.selected = null"
|
||||
|
|
@ -1035,12 +1015,10 @@ export default class Game extends Vue {
|
|||
}
|
||||
}
|
||||
|
||||
mobileOverview = false;
|
||||
mobilePlayer: number | null = null;
|
||||
|
||||
get mobileOffers() {
|
||||
if (!this.canMove || this.mobilePlayer === null || this.mobilePlayer === this.player || this.mobileOverview)
|
||||
return [];
|
||||
if (!this.canMove || this.mobilePlayer === null || this.mobilePlayer === this.player) return [];
|
||||
const seller = this.G!.players[this.mobilePlayer];
|
||||
const seen = new Set<string>();
|
||||
return this.containers
|
||||
|
|
@ -1075,7 +1053,6 @@ export default class Game extends Vue {
|
|||
|
||||
viewPlayerBoard(index: number) {
|
||||
this.mobilePlayer = index;
|
||||
this.mobileOverview = false;
|
||||
this.$nextTick(() => {
|
||||
const board = this.$refs.boardScroll as HTMLElement;
|
||||
board.scrollTo({ left: (index * 250 * board.scrollWidth) / 1250, behavior: 'smooth' });
|
||||
|
|
@ -2111,8 +2088,7 @@ text {
|
|||
background: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.selection-close svg,
|
||||
.board-view-toggle svg {
|
||||
.selection-close svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: block;
|
||||
|
|
@ -2183,14 +2159,6 @@ text {
|
|||
font: 12px Arial, sans-serif;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mobile-board-navigation .board-view-toggle {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
width: 34px;
|
||||
padding: 6px;
|
||||
background: #203a45;
|
||||
}
|
||||
.mobile-board-navigation .player-board-tab {
|
||||
border-bottom: 3px solid var(--player-colour);
|
||||
}
|
||||
|
|
@ -2218,9 +2186,6 @@ text {
|
|||
background: #102b35;
|
||||
box-shadow: none;
|
||||
}
|
||||
.board-scroll.overview #scene {
|
||||
width: 100%;
|
||||
}
|
||||
.board-scroll #scene {
|
||||
width: 1000px;
|
||||
max-width: none;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ summary {
|
|||
height: var(--game-panel-content-height, 300px);
|
||||
overflow: auto;
|
||||
overflow-anchor: none;
|
||||
overscroll-behavior: contain;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.journal-entry {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, host: Element):
|
|||
.bgs-game-chat .chat-day time{margin:0;color:inherit;font-size:inherit}
|
||||
.bgs-game-chat .chat-body{height:var(--game-panel-content-height,300px);display:flex;flex-direction:column;margin-top:8px}
|
||||
.bgs-game-chat .chat-body > :not(.chat-messages){flex-shrink:0}
|
||||
.bgs-game-chat .chat-messages{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;margin:0 0 8px}
|
||||
.bgs-game-chat .chat-messages{flex:1;min-height:0;overflow:auto;overflow-anchor:none;margin:0 0 8px}
|
||||
.bgs-game-chat article{padding:5px 0;border-bottom:1px solid #75818d26;white-space:pre-wrap;overflow-wrap:anywhere}
|
||||
.bgs-game-chat article strong{padding:0 3px;font-weight:bold}
|
||||
.bgs-game-chat article:last-child{border-bottom:0}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe('Game chat mount point', () => {
|
|||
await wrapper.setProps({ state: setup(5, {}, 'chat-slot') });
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(wrapper.element.contains(messages), 'first state must not replace the chat DOM').to.equal(true);
|
||||
await wrapper.setData({ mobilePlayer: 2, mobileOverview: true });
|
||||
await wrapper.setData({ mobilePlayer: 2 });
|
||||
expect(wrapper.element.querySelector('.chat-host')).to.equal(slot);
|
||||
expect(wrapper.element.contains(messages)).to.equal(true);
|
||||
wrapper.destroy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue