suggestions

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
eternal-flame-AD 2025-08-05 15:31:05 -05:00
parent d929e66aa2
commit 8741d1e50d
No known key found for this signature in database
1 changed files with 57 additions and 86 deletions

View File

@ -1,4 +1,4 @@
import {Button, Theme} from '@mui/material'; import {Button, Theme, useMediaQuery, useTheme} from '@mui/material';
import IconButton from '@mui/material/IconButton'; import IconButton from '@mui/material/IconButton';
import {makeStyles} from 'tss-react/mui'; import {makeStyles} from 'tss-react/mui';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
@ -33,6 +33,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
}, },
messageContentWrapper: { messageContentWrapper: {
minWidth: 200, minWidth: 200,
width: '100%',
}, },
image: { image: {
marginRight: 15, marginRight: 15,
@ -40,34 +41,14 @@ const useStyles = makeStyles()((theme: Theme) => ({
width: 32, width: 32,
height: 32, height: 32,
}, },
[theme.breakpoints.down('sm')]: {
display: 'none',
},
},
appName: {
opacity: 0.7,
}, },
date: { date: {
[theme.breakpoints.down('md')]: { [theme.breakpoints.down('md')]: {
order: 1,
flexBasis: '100%',
opacity: 0.7, opacity: 0.7,
}, },
}, },
messageWrapper: {
display: 'grid',
gridTemplateColumns: '70px 1fr',
[theme.breakpoints.down('sm')]: {
gridTemplateColumns: '1fr',
},
gap: 16,
width: '100%',
},
actionsWrapper: {
flex: 1,
display: 'flex',
justifyContent: 'flex-end',
flexDirection: 'row',
alignItems: 'flex-start',
},
imageWrapper: { imageWrapper: {
display: 'flex', display: 'flex',
}, },
@ -131,10 +112,12 @@ const Message = ({
onExpand, onExpand,
expanded: initialExpanded, expanded: initialExpanded,
}: IProps) => { }: IProps) => {
const theme = useTheme();
const [previewRef, setPreviewRef] = React.useState<HTMLDivElement | null>(null); const [previewRef, setPreviewRef] = React.useState<HTMLDivElement | null>(null);
const {classes} = useStyles(); const {classes} = useStyles();
const [expanded, setExpanded] = React.useState(initialExpanded); const [expanded, setExpanded] = React.useState(initialExpanded);
const [isOverflowing, setOverflowing] = React.useState(false); const [isOverflowing, setOverflowing] = React.useState(false);
const dateWrapped = useMediaQuery(theme.breakpoints.down('md'));
React.useEffect(() => { React.useEffect(() => {
setOverflowing(!!previewRef && previewRef.scrollHeight > previewRef.clientHeight); setOverflowing(!!previewRef && previewRef.scrollHeight > previewRef.clientHeight);
@ -163,7 +146,8 @@ const Message = ({
borderLeftWidth: 6, borderLeftWidth: 6,
borderLeftStyle: 'solid', borderLeftStyle: 'solid',
}}> }}>
<div className={classes.messageWrapper}> <div style={{display: 'flex', width: '100%'}}>
<div className={classes.imageWrapper}>
{image !== null ? ( {image !== null ? (
<img <img
src={config.get('url') + image} src={config.get('url') + image}
@ -173,28 +157,17 @@ const Message = ({
className={classes.image} className={classes.image}
/> />
) : null} ) : null}
<div style={{width: '100%'}}> </div>
<div style={{display: 'flex', width: '100%'}}>
<div className={classes.messageContentWrapper}> <div className={classes.messageContentWrapper}>
<div className={classes.header}> <div className={classes.header}>
<Typography <Typography className={`${classes.headerTitle} title`} variant="h5">
className={`${classes.headerTitle} title`}
variant="h5">
{title} {title}
</Typography> </Typography>
</div>
<div className={classes.appName}>
<Typography variant="body1" className={classes.date}>
{appName}
</Typography>
</div>
</div>
<div className={classes.actionsWrapper}>
<Typography variant="body1" className={classes.date}> <Typography variant="body1" className={classes.date}>
<TimeAgo <TimeAgo
date={date} date={date}
formatter={makeIntlFormatter({ formatter={makeIntlFormatter({
style: 'narrow', style: dateWrapped ? 'long' : 'narrow',
})} })}
/> />
</Typography> </Typography>
@ -205,8 +178,7 @@ const Message = ({
<Delete /> <Delete />
</IconButton> </IconButton>
</div> </div>
</div>
<div>
<Typography <Typography
component="div" component="div"
ref={setPreviewRef} ref={setPreviewRef}
@ -216,6 +188,7 @@ const Message = ({
{renderContent()} {renderContent()}
</Typography> </Typography>
</div> </div>
</div>
{isOverflowing && ( {isOverflowing && (
<Button <Button
style={{marginTop: 16}} style={{marginTop: 16}}
@ -228,8 +201,6 @@ const Message = ({
{expanded ? 'Read Less' : 'Read More'} {expanded ? 'Read Less' : 'Read More'}
</Button> </Button>
)} )}
</div>
</div>
</Container> </Container>
</div> </div>
); );