채팅: 가리기 삭제, 100줄이 찬 뒤에도 맨 아래 고정(+새 메시지 수), 이름 줄과 말풍선으로 이름·내용 구분
- 공통 ChatMessage(이름 줄 + 말풍선, 내 말은 오른쪽, 이어 말하면 이름 한 번) — 방 채팅·마피아·라이어 게임, 그림 맞히기 이름 표시 - useStickToBottom: 개수 대신 목록 내용 변화를 보고 맨 아래 유지, 위로 올려 읽는 중엔 그대로, 보내면 다시 맨 아래 - 휴대폰 채팅 버튼의 새 메시지 수도 100줄 뒤에 0이 되던 문제(마지막 본 id 기준으로) - e2e/chat.e2e.ts: PC 대기실·게임 옆 칸·휴대폰 시트 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
/** 그림 맞히기 화면 (docs/games/catchmind.md §5.5, §9). */
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
|
||||
import type { CanvasOp, CatchmindOptions, CatchmindView, ChatView, TurnEndReason } from '@bg/games/catchmind';
|
||||
import type { PublicUser, ServerMessage } from '@bg/shared/lite';
|
||||
import { nameHue } from '../../components/ChatMessage';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
@@ -126,7 +127,10 @@ const CSS = `
|
||||
.cm-chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; min-height: 120px; max-height: 260px; }
|
||||
.cm-side .cm-chat-list { max-height: 340px; }
|
||||
.cm-line { font-size: .95rem; line-height: 1.35; word-break: break-word; }
|
||||
.cm-line b { margin-right: 6px; }
|
||||
.cm-line b .cm-tag { margin: 0 0 0 6px; }
|
||||
.cm-line b { display: block; font-size: .8rem; font-weight: 800; color: hsl(var(--name-h, 212) 70% var(--chat-name-l)); }
|
||||
.cm-line:not(.sys):not(.react) { background: var(--surface-2); border-radius: 4px 12px 12px 12px; padding: 4px 10px; align-self: flex-start; max-width: 100%; }
|
||||
.cm-line.mine { background: var(--primary-soft); }
|
||||
.cm-line.sys { color: var(--success); font-weight: 800; }
|
||||
.cm-line.close { color: var(--warning); }
|
||||
.cm-line.blocked { color: var(--text-sub); font-style: italic; }
|
||||
@@ -847,8 +851,10 @@ function chatLine(m: ChatView, me: string | null, players: Record<string, Public
|
||||
cls: '',
|
||||
body: (
|
||||
<>
|
||||
{m.solversOnly && <span className="cm-tag">맞힌 사람끼리</span>}
|
||||
<b>{who}</b>
|
||||
<b>
|
||||
{who}
|
||||
{m.solversOnly && <span className="cm-tag">맞힌 사람끼리</span>}
|
||||
</b>
|
||||
{m.text}
|
||||
</>
|
||||
),
|
||||
@@ -911,7 +917,7 @@ function GuessPanel({ v, me, players, act, pending }: { v: CatchmindView; me: st
|
||||
{v.chat.map((m) => {
|
||||
const { cls, body } = chatLine(m, me, players, v.drawer);
|
||||
return (
|
||||
<li key={m.id} className={`cm-line ${cls}`}>
|
||||
<li key={m.id} className={`cm-line ${cls}${m.from === me ? ' mine' : ''}`} style={{ '--name-h': nameHue(m.from) } as CSSProperties}>
|
||||
{body}
|
||||
</li>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user