accepted answer chip

This commit is contained in:
“spicecat” 2022-08-18 17:12:00 -04:00
commit 57e52c9a14
2 changed files with 26 additions and 13 deletions

View file

@ -20,7 +20,7 @@ export default function ListQuestion({
}) {
const sm = useMediaQuery((theme) => theme.breakpoints.only('sm'));
const md = useMediaQuery((theme) => theme.breakpoints.only('md'));
console.log(123123, tags)
return (
<span key={question_id}>
<ListItem disablePadding>
@ -31,7 +31,7 @@ export default function ListQuestion({
</Stack>
</Grid>
<Grid item xs={10}>
{sm || md ? null : <ListQuestionInfo {...{ upvotes, downvotes, answers, views, inline: true }} />}
{sm || md ? null : <ListQuestionInfo {...{ hasAcceptedAnswer, upvotes, downvotes, answers, views, inline: true }} />}
<CreationInfoTag {...{ createdAt, creator }} />
<Typography
variant='h6'
@ -44,8 +44,6 @@ export default function ListQuestion({
<Typography noWrap variant='body1'>
{text.replace(/<[^>]*>?/gm, '')}
</Typography>
<Typography>Accepted: {String(hasAcceptedAnswer)} </Typography>
</Grid>
</Grid>
</ListItem>

View file

@ -1,16 +1,31 @@
import { Typography } from "@mui/material"
export default function ListQuestionInfo({upvotes, downvotes, answers, views, inline}){
return inline? (
import { Chip, Typography } from '@mui/material';
export default function ListQuestionInfo({ upvotes, downvotes, answers, hasAcceptedAnswer, views, inline }) {
return inline ? (
<>
<Typography display = 'inline' variant='body1'>{upvotes - downvotes} votes | </Typography>
<Typography display = 'inline' variant='body1'>{answers} answers | </Typography>
<Typography display = 'inline' variant='body1'>{views} views</Typography>
<Typography display='inline'>{upvotes - downvotes} votes | </Typography>
<Typography display='inline'>{answers} answers | </Typography>
<Typography display='inline'>{views} views</Typography>
<Typography display='inline' m={1}>
Accepted:
</Typography>
<Chip
color={hasAcceptedAnswer ? 'success' : 'error'}
label={hasAcceptedAnswer ? 'yes' : 'no'}
size='small'
/>
</>
) : (
<>
<Typography display = 'block' variant='body1'>{upvotes - downvotes} votes</Typography>
<Typography display = 'block' variant='body1'>{answers} answers</Typography>
<Typography display = 'block' variant='body1'>{views} views</Typography>
<Typography display='block'>{upvotes - downvotes} votes</Typography>
<Typography display='block'>{answers} answers</Typography>
<Typography display='block'>{views} views</Typography>
<Typography display='block'>
Accepted: <Chip
color={hasAcceptedAnswer ? 'success' : 'error'}
label={hasAcceptedAnswer ? 'yes' : 'no'}
size='small'
/>
</Typography>
</>
)
}