update msgboard UX

This commit is contained in:
Jeff Emmett 2024-08-31 16:17:05 +02:00
parent 2c35a0c53c
commit 836d37df76
3 changed files with 76 additions and 11 deletions

View File

@ -12,6 +12,7 @@ import { ChatBoxTool } from '@/tools/ChatBoxTool'
import { IChatBoxShape, ChatBoxShape } from '@/shapes/ChatBoxShape'
import { multiplayerAssetStore } from '../client/multiplayerAssetStore' // Adjusted path if necessary
import { customSchema } from '../../worker/TldrawDurableObject'
import './ChatBoxStyles.css' // Add a CSS file for styles
const WORKER_URL = `https://jeffemmett-canvas.jeffemmett.workers.dev`
@ -62,6 +63,22 @@ export function Board() {
)
}
// Assuming you have a message structure like this
interface ChatMessage {
id: string;
text: string;
isUser: boolean; // New property to identify the sender
}
// Example rendering function for messages
function renderMessage(message: ChatMessage) {
return (
<div className={message.isUser ? 'user-message' : 'other-message'}>
{message.text}
</div>
)
}
// How does our server handle bookmark unfurling?
async function unfurlBookmarkUrl({ url }: { url: string }): Promise<TLBookmarkAsset> {
const asset: TLBookmarkAsset = {

View File

@ -0,0 +1,59 @@
/* General chatbox styles */
.chatbox {
display: flex;
flex-direction: column;
padding: 10px;
border: 1px solid #ccc;
border-radius: 8px;
max-width: 400px; /* Adjust as needed */
margin: auto; /* Center on the page */
}
/* Message styles */
.message {
padding: 8px;
margin: 5px 0;
border-radius: 5px;
word-wrap: break-word; /* Ensure long words break */
}
/* User message styles */
.user-message {
background-color: #d1e7dd; /* Light green */
color: #0c5460; /* Darker text color for contrast */
align-self: flex-end; /* Align to the right */
}
/* Other message styles */
.other-message {
background-color: #f8d7da; /* Light red */
color: #721c24; /* Darker text color for contrast */
align-self: flex-start; /* Align to the left */
}
/* Input area styles */
.input-area {
display: flex;
margin-top: 10px;
}
.input-area input {
flex: 1;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.input-area button {
padding: 10px;
margin-left: 5px;
border: none;
background-color: #007bff; /* Bootstrap primary color */
color: white;
border-radius: 5px;
cursor: pointer;
}
.input-area button:hover {
background-color: #0056b3; /* Darker shade on hover */
}

11
sw.ts
View File

@ -1,11 +0,0 @@
self.addEventListener('push', function(event) {
const data = event.data.json();
const options = {
body: data.message,
icon: 'path/to/icon.png',
badge: 'path/to/badge.png'
};
event.waitUntil(
self.registration.showNotification('New Message', options)
);
});