Clear visible chat mentions in BGS and show date separators
This commit is contained in:
parent
df58484f36
commit
1992b87377
5 changed files with 52 additions and 7 deletions
|
|
@ -10,7 +10,7 @@
|
|||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.2.0",
|
||||
"@boardgamers/protocol": "0.2.1",
|
||||
"fuji-engine": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<script lang="ts">
|
||||
import { chatDateSeparators } from "@boardgamers/protocol/chat";
|
||||
import type { Store } from "./store.svelte";
|
||||
import { bindChatComposer, bindChatViewport, type ChatSuggestions } from "@boardgamers/protocol/chat/dom";
|
||||
let { store }: { store: Store } = $props();
|
||||
const chat = $derived(store.chatState);
|
||||
const dates = $derived(chatDateSeparators(chat.messages));
|
||||
let composer: HTMLInputElement | undefined = $state();
|
||||
let list: HTMLDivElement | undefined = $state();
|
||||
let contents: HTMLDivElement | undefined = $state();
|
||||
|
|
@ -63,6 +65,8 @@
|
|||
<div bind:this={contents}>
|
||||
{#if !chat.messages.length}<p class="empty">Plan your escape together.</p>{/if}
|
||||
{#each chat.messages as message, i (message._id ?? i)}
|
||||
{@const day = dates[i]}
|
||||
{#if day}<div class="chat-day"><time datetime={day.dateTime}>{day.label}</time></div>{/if}
|
||||
<article data-message-id={message._id} class:system={message.type === "system"}>
|
||||
{#if message.author}
|
||||
<div class="chat-author">
|
||||
|
|
@ -138,6 +142,24 @@
|
|||
{/if}
|
||||
|
||||
<style>
|
||||
.chat-day {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 12px 0 8px;
|
||||
font-size: 11px;
|
||||
color: #afbea9;
|
||||
}
|
||||
.chat-day::before,
|
||||
.chat-day::after {
|
||||
content: "";
|
||||
flex: 1;
|
||||
border-top: 1px solid #e6c78030;
|
||||
}
|
||||
.chat-day time {
|
||||
color: inherit;
|
||||
font-size: inherit;
|
||||
}
|
||||
.chat-mention {
|
||||
color: var(--gold, #e6c780);
|
||||
font: inherit;
|
||||
|
|
|
|||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -34,8 +34,8 @@ importers:
|
|||
packages/viewer:
|
||||
dependencies:
|
||||
'@boardgamers/protocol':
|
||||
specifier: 0.2.0
|
||||
version: 0.2.0
|
||||
specifier: 0.2.1
|
||||
version: 0.2.1
|
||||
fuji-engine:
|
||||
specifier: workspace:*
|
||||
version: link:../engine
|
||||
|
|
@ -61,8 +61,8 @@ importers:
|
|||
|
||||
packages:
|
||||
|
||||
'@boardgamers/protocol@0.2.0':
|
||||
resolution: {integrity: sha512-6vUH+vjERARwHmUeOX+Gg1AgvV3+glPJjnh73E3ZlJGrYv6bXFe53Z6Xs+Pvv4i3zvdVHRBnxjEfQ7GDAE3mVg==}
|
||||
'@boardgamers/protocol@0.2.1':
|
||||
resolution: {integrity: sha512-e114ohTXaZ1cHdzJs9kj+MkT1ciHGtcaqFherLVMFNrgvxLUGq8kZ8cCxsObXI4n0MGjzPU+Y/j+DAKD0yHoxw==}
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.13':
|
||||
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
|
||||
|
|
@ -631,7 +631,7 @@ packages:
|
|||
|
||||
snapshots:
|
||||
|
||||
'@boardgamers/protocol@0.2.0':
|
||||
'@boardgamers/protocol@0.2.1':
|
||||
dependencies:
|
||||
zod: 4.6.2
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
packages:
|
||||
- packages/*
|
||||
minimumReleaseAgeExclude:
|
||||
- "@boardgamers/protocol@0.2.0"
|
||||
- "@boardgamers/protocol@0.2.1"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ for (const width of [390, 1400]) {
|
|||
playerIndex: 1,
|
||||
type: "text",
|
||||
text: "Hi @You https://example.com",
|
||||
createdAt: new Date(2026, 8, 12, 23, 59).toISOString(),
|
||||
segments: [
|
||||
{ kind: "text", text: "Hi " },
|
||||
{ kind: "mention", id: "u1", name: "Full Name" },
|
||||
|
|
@ -72,6 +73,28 @@ for (const width of [390, 1400]) {
|
|||
assert.equal(await p.getByText(/Gatherer.*decide/).count(), 0);
|
||||
assert.equal(await p.getByText("Scenario 7", { exact: true }).isVisible(), true);
|
||||
assert.equal(await p.getByRole("button", { name: "Difficulty level 2: stamina costs" }).isVisible(), true);
|
||||
await p.evaluate(() =>
|
||||
e.emit("chat:appended", [
|
||||
{
|
||||
_id: "000000000000000000000002",
|
||||
type: "text",
|
||||
text: "Next day",
|
||||
createdAt: new Date(2026, 8, 13, 0, 1).toISOString(),
|
||||
},
|
||||
{
|
||||
_id: "000000000000000000000003",
|
||||
type: "text",
|
||||
text: "Same day",
|
||||
createdAt: new Date(2026, 8, 13, 0, 2).toISOString(),
|
||||
},
|
||||
])
|
||||
);
|
||||
await p.locator(".chat-day").nth(1).waitFor();
|
||||
assert.deepEqual(await p.locator(".chat-day time").evaluateAll((dates) => dates.map((date) => date.dateTime)), [
|
||||
"2026-09-12",
|
||||
"2026-09-13",
|
||||
]);
|
||||
await p.screenshot({ path: `/tmp/fuji-chat-dates-${width}.png`, fullPage: true });
|
||||
assert.deepEqual(errors, []);
|
||||
await p.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue