Skip to content

Commit

Permalink
Add optional badge
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Dec 5, 2024
1 parent 135466a commit 9b50f5d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import QuestionHelp from './QuestionHelp'
import QuestionManagement from './QuestionManagement'
import QuestionText from './QuestionText'
import QuestionWidget from './QuestionWidget'
import QuestionOptional from './QuestionOptional'

const Question = ({ templates, question, values, focus, currentSet, createValue, updateValue, deleteValue }) => {
return (
<div className={`interview-question col-md-${question.width || '12'}`}>
{
question.is_optional && <QuestionOptional />
}
<QuestionText question={question} />
<QuestionHelp question={question} />
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const QuestionOptional = () => {
return (
<div className="badge badge-optional" title={gettext('This is an optional question.')}>
{gettext('Optional')}
</div>
)
}

export default QuestionOptional
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ const QuestionText = ({ question }) => {
return (
<div className={classnames}>
{question.text}
{question.is_optional && (
<>
{' '}
<span>{gettext('(optional)')}</span>
</>
)}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TextInput.propTypes = {
value: PropTypes.object.isRequired,
disabled: PropTypes.bool,
isDefault: PropTypes.bool,
isOptional: PropTypes.bool,
focus: PropTypes.bool,
updateValue: PropTypes.func.isRequired,
}
Expand Down
5 changes: 5 additions & 0 deletions rdmo/projects/assets/scss/interview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@
opacity: 0.5;
}
}

.badge-optional {
float: right;
margin-top: 1px;
}
}

.interview-question {
Expand Down

0 comments on commit 9b50f5d

Please sign in to comment.