Skip to content

Commit

Permalink
Show info question texts with a dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Keskimaki committed Mar 13, 2023
1 parent 59a97af commit 0d0e3c3
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions src/client/components/InteractiveForm/RenderQuestions.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
import React from 'react'
import { Box, Container } from '@mui/material'
import { InputProps, Locales } from '../../types'
import { Box, Container, Typography } from '@mui/material'
import { InputProps, Locales, Question } from '../../types'
import styles from './styles'
import MultiChoice from '../Choices/MultiChoice'
import SingleChoice from '../Choices/SingleChoice'
import DimensionSelect from '../Choices/DimensionSelect'
import Markdown from '../Common/Markdown'
import ShowMore from '../Common/ShowMore'

const classes = styles.cardStyles

const QuestionText = ({
question,
language,
}: {
question: Question
language: keyof Locales
}) => {
if (question.optionData.type === 'info')
return (
<Typography component="span">
{question.title[language]}
<ShowMore text={question.text[language as keyof Locales]} />
</Typography>
)

return (
<>
<Markdown>{question.title[language]}</Markdown>
<Box sx={classes.content}>
<Markdown>{question.text[language]}</Markdown>
</Box>
</>
)
}

const RenderQuestions = ({
control,
@@ -14,8 +42,6 @@ const RenderQuestions = ({
questions,
language,
}: InputProps) => {
const classes = styles.cardStyles

if (question.visibility?.options) {
const [...options] = question.visibility.options

@@ -42,11 +68,7 @@ const RenderQuestions = ({

return (
<Container sx={classes.questionsContainer}>
<Markdown>{question.title[language as keyof Locales]}</Markdown>
<Box sx={classes.content}>
<Markdown>{question.text[language as keyof Locales]}</Markdown>
</Box>

<QuestionText question={question} language={language as keyof Locales} />
<Choice
key={question.id as unknown as string}
control={control}

0 comments on commit 0d0e3c3

Please sign in to comment.