feat: improve message styling
This commit is contained in:
parent
6fb021e6c4
commit
3be1f2e88a
@ -4,9 +4,10 @@ import { UnsentMessage, ReceivedMessage } from 'models/chat'
|
|||||||
|
|
||||||
export interface ChatTranscriptProps {
|
export interface ChatTranscriptProps {
|
||||||
messageLog: Array<UnsentMessage | ReceivedMessage>
|
messageLog: Array<UnsentMessage | ReceivedMessage>
|
||||||
|
userId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChatTranscript = ({ messageLog }: ChatTranscriptProps) => {
|
export const ChatTranscript = ({ messageLog, userId }: ChatTranscriptProps) => {
|
||||||
return (
|
return (
|
||||||
<div className="ChatTranscript flex flex-col">
|
<div className="ChatTranscript flex flex-col">
|
||||||
{messageLog.map((message, idx) => (
|
{messageLog.map((message, idx) => (
|
||||||
@ -15,11 +16,12 @@ export const ChatTranscript = ({ messageLog }: ChatTranscriptProps) => {
|
|||||||
key={`${idx}_${message}`}
|
key={`${idx}_${message}`}
|
||||||
variant="body1"
|
variant="body1"
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor: 'primary.dark',
|
backgroundColor:
|
||||||
|
message.authorId === userId ? 'primary.dark' : 'grey.700',
|
||||||
margin: 0.5,
|
margin: 0.5,
|
||||||
padding: 1,
|
padding: 1,
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
float: 'left',
|
float: message.authorId === userId ? 'right' : 'left',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{message.text}
|
{message.text}
|
||||||
|
@ -93,7 +93,7 @@ export function Room({
|
|||||||
Send
|
Send
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
<ChatTranscript messageLog={messageLog} />
|
<ChatTranscript messageLog={messageLog} userId={userId} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import ReactDOM from 'react-dom/client'
|
|||||||
import { BrowserRouter as Router } from 'react-router-dom'
|
import { BrowserRouter as Router } from 'react-router-dom'
|
||||||
import { ThemeProvider, createTheme } from '@mui/material/styles'
|
import { ThemeProvider, createTheme } from '@mui/material/styles'
|
||||||
import CssBaseline from '@mui/material/CssBaseline'
|
import CssBaseline from '@mui/material/CssBaseline'
|
||||||
|
import 'typeface-roboto'
|
||||||
|
|
||||||
import * as serviceWorkerRegistration from 'serviceWorkerRegistration'
|
import * as serviceWorkerRegistration from 'serviceWorkerRegistration'
|
||||||
import 'index.sass'
|
import 'index.sass'
|
||||||
|
Loading…
Reference in New Issue
Block a user