Skip to content

Commit

Permalink
refactor(styling): Remove Tailwind (#253)
Browse files Browse the repository at this point in the history
* refactor(css): replace Tailwind classes with MUI sx
* chore(deps): remove classnames
* refactor(css): inline link baseline style
* feat(css): use modern-normalize
* chore(deps): remove tailwind
* refactor(css): inline all Sass files
* chore(deps): remove sass
  • Loading branch information
jeremyckahn authored Apr 10, 2024
1 parent 72526eb commit 6c434f8
Show file tree
Hide file tree
Showing 22 changed files with 179 additions and 1,098 deletions.
1,044 changes: 40 additions & 1,004 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"buffer": "^6.0.3",
"classnames": "^2.3.1",
"detectincognitojs": "^1.1.2",
"fast-memoize": "^2.5.2",
"file-saver": "^2.0.5",
"fun-animal-names": "^0.1.1",
"idb-chunk-store": "^1.0.1",
"localforage": "^1.10.0",
"modern-normalize": "^2.0.0",
"mui-markdown": "^0.5.5",
"querystring": "^0.2.1",
"react": "^18.2.0",
Expand Down Expand Up @@ -113,13 +113,10 @@
"mprocs": "^0.6.4",
"nodemon": "^3.0.1",
"parcel": "^2.10.0",
"postcss": "^8.4.31",
"prettier": "^3.2.5",
"pretty-quick": "^4.0.0",
"process": "^0.11.10",
"sass": "^1.69.5",
"serve": "^14.1.2",
"tailwindcss": "^3.1.8",
"url": "^0.11.0",
"util": "^0.12.5",
"vite": "^5.0.13",
Expand Down
6 changes: 0 additions & 6 deletions postcss.config.cjs

This file was deleted.

13 changes: 5 additions & 8 deletions src/components/ChatTranscript/ChatTranscript.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { HTMLAttributes, useRef, useEffect, useState, useContext } from 'react'
import cx from 'classnames'
import Box from '@mui/material/Box'
import useTheme from '@mui/material/styles/useTheme'

Expand All @@ -12,11 +11,7 @@ export interface ChatTranscriptProps extends HTMLAttributes<HTMLDivElement> {
userId: string
}

export const ChatTranscript = ({
className,
messageLog,
userId,
}: ChatTranscriptProps) => {
export const ChatTranscript = ({ messageLog, userId }: ChatTranscriptProps) => {
const { showRoomControls } = useContext(ShellContext)
const theme = useTheme()
const boxRef = useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -66,11 +61,13 @@ export const ChatTranscript = ({
return (
<Box
ref={boxRef}
className={cx('ChatTranscript', className)}
className="ChatTranscript"
sx={{
display: 'flex',
flexDirection: 'column',
py: transcriptMinPadding,
flexGrow: 1,
overflow: 'auto',
pb: transcriptMinPadding,
pt: showRoomControls ? theme.spacing(10) : theme.spacing(2),
px: `max(${transcriptPaddingX}, ${transcriptMinPadding})`,
transition: `padding-top ${theme.transitions.duration.short}ms ${theme.transitions.easing.easeInOut}`,
Expand Down
9 changes: 9 additions & 0 deletions src/components/Elements/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from '@mui/material/styles/styled'

// NOTE: These components are defined to enable raw DOM elements to be styled
// with MUI's sx prop.
// @see https://mui.com/system/styled/
// @see https://mui.com/system/getting-started/the-sx-prop/
export const Form = styled('form')({})
export const Input = styled('input')({})
export const Main = styled('main')({})
3 changes: 0 additions & 3 deletions src/components/Message/Message.sass

This file was deleted.

31 changes: 17 additions & 14 deletions src/components/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,10 @@ import Box from '@mui/material/Box'
import Tooltip from '@mui/material/Tooltip'
import Typography, { TypographyProps } from '@mui/material/Typography'
import Link, { LinkProps } from '@mui/material/Link'
import styled from '@mui/material/styles/styled'
import { materialDark } from 'react-syntax-highlighter/dist/esm/styles/prism'

// These imports need to be ts-ignored to prevent spurious errors that look
// like this:
//
// Module 'react-markdown' cannot be imported using this construct. The
// specifier only resolves to an ES module, which cannot be imported
// synchronously. Use dynamic import instead. (tsserver 1471)
//
// @ts-ignore
import Markdown from 'react-markdown'
// @ts-ignore
import { CodeProps } from 'react-markdown/lib/ast-to-react'
// @ts-ignore
import remarkGfm from 'remark-gfm'

import {
Expand All @@ -32,7 +22,7 @@ import { CopyableBlock } from 'components/CopyableBlock/CopyableBlock'

import { InlineMedia } from './InlineMedia'

import './Message.sass'
const StyledMarkdown = styled(Markdown)({})

export interface MessageProps {
message: IMessage | I_InlineMedia
Expand Down Expand Up @@ -154,13 +144,26 @@ export const Message = ({ message, showAuthor, userId }: MessageProps) => {
) : isYouTubeLink(message) ? (
<YouTube videoId={getYouTubeVideoId(message.text)} />
) : (
<Markdown
<StyledMarkdown
components={componentMap}
remarkPlugins={[remarkGfm]}
linkTarget="_blank"
sx={{
'& pre': {
overflow: 'auto',
},
'& ol': {
pl: 2,
listStyleType: 'decimal',
},
'& ul': {
pl: 2,
listStyleType: 'disc',
},
}}
>
{message.text}
</Markdown>
</StyledMarkdown>
)}
</Box>
</Tooltip>
Expand Down
19 changes: 12 additions & 7 deletions src/components/MessageForm/MessageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ArrowUpward from '@mui/icons-material/ArrowUpward'

import { messageCharacterSizeLimit } from 'config/messaging'
import { SettingsContext } from 'contexts/SettingsContext'
import classNames from 'classnames'
import { Form } from 'components/Elements'

interface MessageFormProps {
onMessageSubmit: (message: string) => void
Expand Down Expand Up @@ -76,12 +76,17 @@ export const MessageForm = ({
}

return (
<form
<Form
onSubmit={handleMessageSubmit}
className={classNames({
'pt-4 px-4': showActiveTypingStatus,
'p-4': !showActiveTypingStatus,
})}
sx={{
...(showActiveTypingStatus && {
pt: 2,
px: 2,
}),
...(!showActiveTypingStatus && {
p: 2,
}),
}}
>
<Stack direction="row" spacing={2}>
<FormControl fullWidth>
Expand Down Expand Up @@ -110,6 +115,6 @@ export const MessageForm = ({
<ArrowUpward />
</Fab>
</Stack>
</form>
</Form>
)
}
6 changes: 1 addition & 5 deletions src/components/Room/Room.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ export function Room({
height: landscape ? '100%' : '40%',
}}
>
<ChatTranscript
messageLog={messageLog}
userId={userId}
className="grow overflow-auto"
/>
<ChatTranscript messageLog={messageLog} userId={userId} />
<Divider />
<Box>
<MessageForm
Expand Down
6 changes: 4 additions & 2 deletions src/components/Room/RoomFileUploadControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import CircularProgress from '@mui/material/CircularProgress'
import { RoomContext } from 'contexts/RoomContext'
import { PeerRoom } from 'lib/PeerRoom'

import { Input } from 'components/Elements'

import { useRoomFileShare } from './useRoomFileShare'
import { MediaButton } from './MediaButton'

Expand Down Expand Up @@ -73,12 +75,12 @@ export function RoomFileUploadControls({
px: 1,
}}
>
<input
<Input
multiple
ref={fileInputRef}
type="file"
id="file-upload"
className="hidden"
sx={{ display: 'none' }}
onChange={handleFileSelect}
/>
<Tooltip
Expand Down
3 changes: 0 additions & 3 deletions src/components/Shell/PeerDownloadFileButton.sass

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/Shell/PeerDownloadFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { fileTransfer } from 'lib/FileTransfer'
import { Peer } from 'models/chat'
import { ShellContext } from 'contexts/ShellContext'

import './PeerDownloadFileButton.sass'
import { usePeerNameDisplay } from 'components/PeerNameDisplay/usePeerNameDisplay'

interface PeerDownloadFileButtonProps {
Expand Down Expand Up @@ -65,6 +64,9 @@ export const PeerDownloadFileButton = ({
<CircularProgress
variant={downloadProgress === null ? 'indeterminate' : 'determinate'}
value={downloadProgress === null ? undefined : downloadProgress}
sx={{
transition: 'none',
}}
/>
) : (
<Tooltip
Expand Down
20 changes: 20 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
a {
color: inherit;
text-decoration: inherit;
}

blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
margin: 0;
}
9 changes: 0 additions & 9 deletions src/index.sass

This file was deleted.

3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import './polyfills'
import ReactDOM from 'react-dom/client'
import 'typeface-roboto'

import './index.sass'
import 'modern-normalize/modern-normalize.css'
import './index.css'

import { ThemeProvider, createTheme } from '@mui/material/styles'
import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter'
Expand Down
16 changes: 13 additions & 3 deletions src/pages/About/About.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { useContext, useEffect } from 'react'
import MuiMarkdown from 'mui-markdown'
import Box from '@mui/material/Box'
import useTheme from '@mui/material/styles/useTheme'

import { ShellContext } from 'contexts/ShellContext'
import {
messageTranscriptSizeLimit,
messageCharacterSizeLimit,
} from 'config/messaging'

import './index.sass'

const messageTranscriptSizeLimitFormatted = Intl.NumberFormat().format(
messageTranscriptSizeLimit
)
Expand All @@ -20,13 +19,24 @@ const messageCharacterSizeLimitFormatted = Intl.NumberFormat().format(

export const About = () => {
const { setTitle } = useContext(ShellContext)
const theme = useTheme()

useEffect(() => {
setTitle('About')
}, [setTitle])

return (
<Box className="About max-w-3xl mx-auto p-4">
<Box
className="About"
sx={{
p: 2,
mx: 'auto',
maxWidth: theme.breakpoints.values.md,
'& p': {
mb: 2,
},
}}
>
<MuiMarkdown>
{`
### User Guide
Expand Down
3 changes: 0 additions & 3 deletions src/pages/About/index.sass

This file was deleted.

16 changes: 13 additions & 3 deletions src/pages/Disclaimer/Disclaimer.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { useContext, useEffect } from 'react'
import Box from '@mui/material/Box'
import MuiMarkdown from 'mui-markdown'
import useTheme from '@mui/material/styles/useTheme'

import { ShellContext } from 'contexts/ShellContext'

import './index.sass'

export const Disclaimer = () => {
const { setTitle } = useContext(ShellContext)
const theme = useTheme()

useEffect(() => {
setTitle('Disclaimer')
}, [setTitle])

return (
<Box className="Disclaimer max-w-3xl mx-auto p-4">
<Box
className="Disclaimer"
sx={{
p: 2,
mx: 'auto',
maxWidth: theme.breakpoints.values.md,
'& p': {
mb: 2,
},
}}
>
<MuiMarkdown>
{`
### Interpretation and Definitions
Expand Down
6 changes: 0 additions & 6 deletions src/pages/Disclaimer/index.sass

This file was deleted.

Loading

2 comments on commit 6c434f8

@Con198811
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@Con198811
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{"userId":"c22f6692-3d23-436c-95ff-2c537e89927d","customUsername":"Hello","colorMode":"dark","playSoundOnNewMessage":true,"showNotificationOnNewMessage":true,"showActiveTypingStatus":true,"publicKey":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwSKYCZ8wHkPrAOi/dy+FSDzE3E9tQ8o2s8aH9pxEgRhQsoa9pgsYNcgpTMSH37wUiw5HBWVGVz+R5WBUSTdJbFBFvk+rxPdPuUtU/l9WJmq8GnCBg2NJZKVqVpvMRutyRw7+ms8j3g31pC9gMcLcpZBC31Me0FUQPpCsxRbE6XLXQi5wuvA5ukvtILZQlHkcUDcgJqL9d8y5cZh7AqMkxjvKMd2tlcWVIbWCv2Lq8PhUZkD1vyk+ut4wzW8TGueuInnveufnNDTzwl+QSFONtSd4g44IRRMdDQojzTwyFbXiI92EMqtHLvTnrNs5gBSS7F7lf9cIDZUSviePB8/RrQIDAQAB","privateKey":"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBIpgJnzAeQ+sA6L93L4VIPMTcT21Dyjazxof2nESBGFCyhr2mCxg1yClMxIffvBSLDkcFZUZXP5HlYFRJN0lsUEW+T6vE90+5S1T+X1YmarwacIGDY0lkpWpWm8xG63JHDv6azyPeDfWkL2AxwtylkELfUx7QVRA+kKzFFsTpctdCLnC68Dm6S+0gtlCUeRxQNyAmov13zLlxmHsCoyTGO8ox3a2VxZUhtYK/Yurw+FRmQPW/KT663jDNbxMa564iee965+c0NPPCX5BIU421J3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w2rRCNGKICe3jqQMAy1jrpDOhiSwz9wWAiZpmt8eWFTg/jEoxAbftr3v8ka5AoGBAJGqDHhjAKd2MdcDd/Mt3hTNCeUREa6kHOHMr4cAOqkB2TDdoev9uja7aXSTb6CFX9XptNeRZejxEb2+kevHYU51Wz+ij4PeO6LjEQfE4yg3hj87iTdz4nsQjYC8qayH81sqsVQO4/LAo/wPsHJzEgS4bSk7c0E3IFO5MqDuKiW4"}
chitchatter-profile-c22f6692-3d23-436c-95ff-2c537e89927d.json
chitchatter-profile-c22f6692-3d23-436c-95ff-2c537e89927d 2.json
chitchatter-profile-c22f6692-3d23-436c-95ff-2c537e89927d 3.json

Please sign in to comment.