blob: aa7fdd081c09d778188fd03e5fe6860899157b54 [file] [log] [blame]
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +02001// Copyright 2021 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import React from 'react'
6import OutlinedInput from "@material-ui/core/OutlinedInput";
7import {makeStyles} from '@material-ui/styles';
8
9const userStyles = makeStyles({
10 head: {
11 marginTop: '1.5rem',
12 fontSize: '1rem'
13 },
14 inputArea: {
15 width: '100%',
16 },
17});
18
19type Props = {
20 question: string,
21 updateAnswers: Function,
22}
23
24export default function CustomQuestionInput(props: Props): React.ReactElement {
25
26 const classes = userStyles();
27
28 const {question, updateAnswers} = props;
29 const [answer, setAnswer] = React.useState('');
30 const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
31 setAnswer(e.target.value);
32 updateAnswers(e.target.value);
33 };
34 const getInnerHtml = ()=> {
35 return {__html: question};
36 }
37 return (
38 <>
39 <h3 dangerouslySetInnerHTML={getInnerHtml()} className={classes.head}/>
40 <OutlinedInput
41 value={answer}
42 onChange={handleChange}
43 className={classes.inputArea}
44 inputProps={{ maxLength: 1000 }}
45 />
46 </>
47 );
48}