refactor: use Box instead of div

This commit is contained in:
Jeremy Kahn 2022-08-27 21:48:22 -05:00
parent dd82d9e1eb
commit 707e090f8b
4 changed files with 12 additions and 8 deletions

View File

@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'
import { Routes, Route } from 'react-router-dom' import { Routes, Route } from 'react-router-dom'
import { v4 as uuid } from 'uuid' import { v4 as uuid } from 'uuid'
import localforage from 'localforage' import localforage from 'localforage'
import Box from '@mui/material/Box'
import { Home } from 'pages/Home/' import { Home } from 'pages/Home/'
import { PublicRoom } from 'pages/PublicRoom/' import { PublicRoom } from 'pages/PublicRoom/'
@ -47,7 +48,7 @@ function Bootstrap({
}, [hasLoadedSettings, persistedStorage, settings, userId]) }, [hasLoadedSettings, persistedStorage, settings, userId])
return ( return (
<div className="Chitchatter"> <Box className="Chitchatter">
{hasLoadedSettings ? ( {hasLoadedSettings ? (
<Routes> <Routes>
{['/', '/index.html'].map(path => ( {['/', '/index.html'].map(path => (
@ -59,7 +60,7 @@ function Bootstrap({
/> />
</Routes> </Routes>
) : null} ) : null}
</div> </Box>
) )
} }

View File

@ -1,5 +1,6 @@
import { HTMLAttributes } from 'react' import { HTMLAttributes } from 'react'
import cx from 'classnames' import cx from 'classnames'
import Box from '@mui/material/Box'
import { Message as IMessage } from 'models/chat' import { Message as IMessage } from 'models/chat'
import { Message } from 'components/Message' import { Message } from 'components/Message'
@ -15,10 +16,10 @@ export const ChatTranscript = ({
userId, userId,
}: ChatTranscriptProps) => { }: ChatTranscriptProps) => {
return ( return (
<div className={cx('ChatTranscript flex flex-col', className)}> <Box className={cx('ChatTranscript flex flex-col', className)}>
{messageLog.map(message => { {messageLog.map(message => {
return <Message key={message.id} message={message} userId={userId} /> return <Message key={message.id} message={message} userId={userId} />
})} })}
</div> </Box>
) )
} }

View File

@ -1,5 +1,6 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import { v4 as uuid } from 'uuid' import { v4 as uuid } from 'uuid'
import Box from '@mui/material/Box'
import FormControl from '@mui/material/FormControl' import FormControl from '@mui/material/FormControl'
import Typography from '@mui/material/Typography' import Typography from '@mui/material/Typography'
import Stack from '@mui/material/Stack' import Stack from '@mui/material/Stack'
@ -97,7 +98,7 @@ export function Room({
}) })
return ( return (
<div className="h-full p-4 flex flex-col"> <Box className="h-full p-4 flex flex-col">
<Typography>Room ID: {roomId}</Typography> <Typography>Room ID: {roomId}</Typography>
<ChatTranscript <ChatTranscript
messageLog={messageLog} messageLog={messageLog}
@ -132,6 +133,6 @@ export function Room({
</Fab> </Fab>
</Stack> </Stack>
</form> </form>
</div> </Box>
) )
} }

View File

@ -1,6 +1,7 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import Button from '@mui/material/Button' import Button from '@mui/material/Button'
import Box from '@mui/material/Box'
import FormControl from '@mui/material/FormControl' import FormControl from '@mui/material/FormControl'
import Typography from '@mui/material/Typography' import Typography from '@mui/material/Typography'
import TextField from '@mui/material/TextField' import TextField from '@mui/material/TextField'
@ -21,7 +22,7 @@ export function Home() {
} }
return ( return (
<div className="Home"> <Box className="Home">
<header className="max-w-3xl text-center mx-auto"> <header className="max-w-3xl text-center mx-auto">
<Typography variant="h1">chitchatter</Typography> <Typography variant="h1">chitchatter</Typography>
<Typography variant="body1"> <Typography variant="body1">
@ -55,6 +56,6 @@ export function Home() {
</Button> </Button>
</form> </form>
</main> </main>
</div> </Box>
) )
} }