styles type Dropdown

This commit is contained in:
Tatiana Nikolaeva 2025-04-05 21:14:19 +05:00
parent 2cbfb06b4a
commit 05d5d396b8
8 changed files with 74 additions and 35 deletions

View file

@ -1,9 +1,9 @@
/*QuestionItem.module.css*/
.questionCard{
width: 100%;
background-color: white;
display: flex;
justify-content: space-between;
margin-bottom: 34px;
padding: 27px 29px 26px 36px;
border-radius: 14px;
@ -11,4 +11,9 @@
.questionCard:last-child{
margin-bottom: 0;
}
.questionContainer{
display: flex;
flex-direction: column;
}

View file

@ -11,10 +11,15 @@ interface QuestionItemProps {
}
const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQuestion = `Вопрос ${indexQuestion}`}) => {
const [selectedType, setSelectedType] = useState<'single' | 'multiply'>('single');
const [answerOption, setAnswerOption] = useState(['']);
const [questionType] = useState('single');
const [textQuestion, setTextQuestion] = useState(initialTextQuestion);
const handleTypeChange = (type: 'single' | 'multiply') => {
setSelectedType(type);
}
const handleAddAnswer = () => {
setAnswerOption([...answerOption, '']);
};
@ -33,17 +38,15 @@ const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQu
<div className={styles.questionCard}>
<div className={styles.questionContainer}>
<h2>
<textarea
value={textQuestion}
onChange={handleQuestionChange}
/>
<textarea
value={textQuestion}
onChange={handleQuestionChange}
/>
</h2>
{answerOption.map((answerText, index) => (
<AnswerOption
key={index}
src={questionType === "single" ?
'../../../public/radio_button_checked.svg' :
'../../../public/check_box.svg' }
selectedType={selectedType}
index={index + 1} // Индекс ответа
value={answerText}
onChange={(value) => handleAnswerChange(index, value)}
@ -54,7 +57,7 @@ const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQu
onClick={handleAddAnswer}
/>
</div>
<TypeDropdown/>
<TypeDropdown selectedType={selectedType} onTypeChange={handleTypeChange}/>
</div>
);
}