-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
223 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import palette from '~/styles/app-theme/app.pallete' | ||
import { TypographyVariantEnum } from '~/types' | ||
|
||
const actionIconWrapper = { | ||
display: 'flex', | ||
alignItems: 'center' | ||
} | ||
|
||
const actionIcon = { | ||
fontSize: '18px', | ||
mr: '10px' | ||
} | ||
|
||
export const styles = { | ||
root: { | ||
width: '60%', | ||
background: palette.basic.white, | ||
borderRadius: '6px', | ||
p: '24px' | ||
}, | ||
header: { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center' | ||
}, | ||
iconTitleDescription: { | ||
container: { display: 'flex', columnGap: '16px', alignItems: 'center' }, | ||
icon: { | ||
svg: { width: '16px', height: '16px', color: 'primary.600' } | ||
}, | ||
titleWithDescription: { | ||
wrapper: { display: 'flex', flexDirection: 'column', rowGap: '3px' }, | ||
title: { | ||
typography: TypographyVariantEnum.Subtitle2, | ||
color: 'primary.900' | ||
}, | ||
description: { | ||
typography: TypographyVariantEnum.Caption, | ||
color: 'primary.400' | ||
} | ||
} | ||
}, | ||
iconWrapper: { | ||
backgroundColor: 'basic.grey', | ||
borderRadius: '4px', | ||
p: '8px' | ||
}, | ||
categoryChip: { | ||
backgroundColor: 'inherit', | ||
border: `2px solid ${palette.basic.turquoiseDark}`, | ||
borderRadius: '50px', | ||
'& .MuiChip-label': { p: '0px 8px' }, | ||
my: '12px' | ||
}, | ||
categoryChipLabel: { | ||
typography: TypographyVariantEnum.Caption, | ||
fontWeight: 500, | ||
color: 'basic.turquoiseDark' | ||
}, | ||
questionBody: { | ||
my: '24px' | ||
}, | ||
questionText: { | ||
typography: TypographyVariantEnum.MidTitle | ||
}, | ||
answers: { | ||
display: 'flex', | ||
flexDirection: 'column' | ||
}, | ||
answer: { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center' | ||
}, | ||
moreIcon: { | ||
fontSize: '20px' | ||
}, | ||
dragIconWrapper: { | ||
display: 'flex', | ||
justifyContent: 'center' | ||
}, | ||
dragIcon: { | ||
fontSize: '30px', | ||
transform: 'rotate(90deg)', | ||
color: 'primary.400', | ||
cursor: 'pointer' | ||
}, | ||
editIconWrapper: actionIconWrapper, | ||
deleteIconWrapper: { ...actionIconWrapper, color: 'error.700' }, | ||
editIcon: actionIcon, | ||
deleteIcon: { | ||
...actionIcon, | ||
color: 'error.700' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { FC } from 'react' | ||
|
||
import Box from '@mui/material/Box' | ||
import Divider from '@mui/material/Divider' | ||
import Typography from '@mui/material/Typography' | ||
import FormControlLabel from '@mui/material/FormControlLabel' | ||
import Checkbox from '@mui/material/Checkbox' | ||
import CheckIcon from '@mui/icons-material/Check' | ||
import appPallete from '~/styles/app-theme/app.pallete' | ||
import DragIndicatorIcon from '@mui/icons-material/DragIndicator' | ||
import IconButton from '@mui/material/IconButton' | ||
import MoreVertIcon from '@mui/icons-material/MoreVert' | ||
import EditIcon from '@mui/icons-material/Edit' | ||
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline' | ||
import LibraryAddCheckOutlinedIcon from '@mui/icons-material/LibraryAddCheckOutlined' | ||
|
||
import IconTitleDescription from '~/components/icon-title-description/IconTitleDescription' | ||
import AppChip from '~/components/app-chip/AppChip' | ||
|
||
import { ColorEnum, Answer, TableActionFunc, QuestionCategory } from '~/types' | ||
import { styles } from '~/components/question/Question.styles' | ||
import useMenu from '~/hooks/use-menu' | ||
import { MenuItem } from '@mui/material' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
interface QuestionProps { | ||
title: string | ||
answers: Answer[] | ||
text: string | ||
category: QuestionCategory | ||
} | ||
|
||
const Question: FC<QuestionProps> = ({ title, answers, text, category }) => { | ||
const { t } = useTranslation() | ||
const { openMenu, renderMenu, closeMenu } = useMenu() | ||
|
||
const onAction = async (actionFunc: TableActionFunc) => { | ||
closeMenu() | ||
await actionFunc('dw') | ||
} | ||
const rowActions = [ | ||
{ | ||
label: ( | ||
<Box sx={styles.editIconWrapper}> | ||
<EditIcon sx={styles.editIcon} /> | ||
{` ${t('common.edit')}`} | ||
</Box> | ||
), | ||
func: (id: string) => { | ||
console.log('Edit', id) | ||
} | ||
}, | ||
{ | ||
label: ( | ||
<Box sx={styles.deleteIconWrapper}> | ||
<DeleteOutlineIcon color='primary' sx={styles.deleteIcon} /> | ||
{` ${t('common.delete')}`} | ||
</Box> | ||
), | ||
func: (id: string) => { | ||
console.log('delete', id) | ||
} | ||
} | ||
] | ||
const menuItems = rowActions.map(({ label, func }) => ( | ||
<MenuItem key={label} onClick={() => void onAction(func)}> | ||
{label} | ||
</MenuItem> | ||
)) | ||
|
||
const answersList = answers.map((answer, i) => ( | ||
<Box key={answer.text} sx={styles.answer}> | ||
<FormControlLabel | ||
checked={i == 1} | ||
control={<Checkbox />} | ||
label={answer.text} | ||
/> | ||
|
||
{answer.isCorrect ? ( | ||
<CheckIcon sx={{ color: appPallete.basic.orientalHerbs }} /> | ||
) : null} | ||
</Box> | ||
)) | ||
|
||
return ( | ||
<Box sx={styles.root}> | ||
<Box sx={styles.dragIconWrapper}> | ||
<DragIndicatorIcon sx={styles.dragIcon} /> | ||
</Box> | ||
<Box sx={styles.header}> | ||
<IconTitleDescription | ||
icon={ | ||
<Box sx={styles.iconWrapper}> | ||
<LibraryAddCheckOutlinedIcon /> | ||
</Box> | ||
} | ||
sx={styles.iconTitleDescription} | ||
title={title} | ||
/> | ||
<IconButton onClick={openMenu}> | ||
<MoreVertIcon color={ColorEnum.Primary} sx={styles.moreIcon} /> | ||
</IconButton> | ||
{renderMenu(menuItems)} | ||
</Box> | ||
<AppChip labelSx={styles.categoryChipLabel} sx={styles.categoryChip}> | ||
{category.name} | ||
</AppChip> | ||
|
||
<Divider /> | ||
<Box sx={styles.questionBody}> | ||
<Typography sx={styles.questionText}>{text}</Typography> | ||
<Box sx={styles.answers}>{answersList}</Box> | ||
</Box> | ||
</Box> | ||
) | ||
} | ||
|
||
export default Question |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,4 +98,4 @@ const QuestionsContainer = () => { | |
) | ||
} | ||
|
||
export default QuestionsContainer | ||
export default QuestionsContainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters