misc: final touches to layout

This commit is contained in:
Alexander Daichendt 2025-02-13 15:23:56 +01:00
parent 64d360a9c5
commit 8bb3c09e70
5 changed files with 10 additions and 8 deletions

View file

@ -91,7 +91,7 @@ pnpm test
- no user authentication - no user authentication
- Client Websockets should be more robust, i.e. reconnecting - Client Websockets should be more robust, i.e. reconnecting
- Client state does not persist on refresh - Client state does not persist on refresh
- Client messages are rendered all at once, a virtual list would be better after a certain amount of messages - Performance: when sending a very large amount of messages, like 100000, the browser will freeze. This is not due to bad rendering per se, but the websocket message ingestion. Fixing this would be quite easy with a server-sided message debounce.
- Test coverage very limited: only a single component is tested - Test coverage very limited: only a single component is tested
- Keyboard navigation and focus management could be improved - Keyboard navigation and focus management could be improved
- Entire deployment process is missing, i.e. Dockerfiles, CI/CD, reverse proxy - Entire deployment process is missing, i.e. Dockerfiles, CI/CD, reverse proxy

View file

@ -39,7 +39,7 @@ function ChatMessageDisplay({
return ( return (
<article <article
key={message.id} key={message.id}
className={`${isOwn ? "ml-auto" : "mr-auto"}`} className={`m-2 ${isOwn ? "ml-auto" : "mr-auto"}`}
aria-label={`Message from ${message.author.name} on ${timestamp}`} aria-label={`Message from ${message.author.name} on ${timestamp}`}
> >
<MessageHeader <MessageHeader

View file

@ -5,11 +5,11 @@ interface LayoutProps {
function Layout({ children }: LayoutProps) { function Layout({ children }: LayoutProps) {
return ( return (
<> <>
<main className="min-h-screen p-4"> <main className="min-h-screen p-1 sm:p-4">
<header className="top-0 w-full bg-white" role="banner"> <header className="top-0 w-full bg-white" role="banner">
<h1 className="text-3xl text-center">Simple Chat</h1> <h1 className="text-3xl text-center mb-3">Simple Chat</h1>
</header> </header>
<div className="max-w-2xl md:p-8 m-auto" role="main"> <div className="max-w-2xl m-auto" role="main">
{children} {children}
</div> </div>
</main> </main>

View file

@ -37,9 +37,9 @@ function MessageDisplay({ sendMessage }: MessageDisplayProps) {
sendMessage(editMessage); sendMessage(editMessage);
}; };
// Scroll to bottom when messages change
useEffect(() => { useEffect(() => {
if (listRef.current) { if (listRef.current) {
// Scroll to bottom when messages change
listRef.current.scrollToItem(state.messages.length - 1); listRef.current.scrollToItem(state.messages.length - 1);
} }
}, [state.messages]); }, [state.messages]);
@ -83,7 +83,7 @@ function MessageDisplay({ sendMessage }: MessageDisplayProps) {
}; };
return ( return (
<div className="h-[calc(100vh-theme('spacing.48'))]"> <div className="h-[calc(100vh-theme('spacing.64'))]">
<AutoSizer> <AutoSizer>
{({ height, width }) => ( {({ height, width }) => (
<List <List

View file

@ -13,7 +13,9 @@ function RoomHeader(props: RoomHeaderProps) {
<h2 className="text-xl bg-gray-100 p-4 flex justify-between items-center"> <h2 className="text-xl bg-gray-100 p-4 flex justify-between items-center">
<span className="font-medium">Room ID: {props.roomId}</span> <span className="font-medium">Room ID: {props.roomId}</span>
{state.currentUser && ( {state.currentUser && (
<span className="font-medium">User: {state.currentUser?.name}</span> <span className="font-medium hidden sm:block">
User: {state.currentUser?.name}
</span>
)} )}
<span <span
className={`px-3 py-1 text-sm font-medium rounded-xl ${ className={`px-3 py-1 text-sm font-medium rounded-xl ${