Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 Add prop for SQForm questions to support rich text #888

Open
wants to merge 3 commits into
base: epic/style-updates
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/fields/SQFormDropdown/SQFormDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
InputLabel,
MenuItem,
Select,
Typography,
} from '@mui/material';
import {useForm} from '../../../hooks/useForm';
import {
Expand All @@ -33,6 +34,8 @@ export type SQFormDropdownProps = BaseFieldProps & {
onChange?: SelectProps['onChange'];
/** Any valid prop for material ui select child component - https://material-ui.com/api/select/#props */
muiFieldProps?: SelectProps;
/** OPTIONAL - Questions that could be asked with the dropdown label */
questions?: string[];
};

const EMPTY_VALUE = '';
Expand All @@ -49,6 +52,14 @@ const classes = {
},
fontWeight: 600,
},
typographyStyle: {
color: 'var(--color-granite)',
fontSize: 'var(--base-font-size)',
fontWeight: 'var(--font-weight-normal)',
whiteSpace: 'pre-line',
margin: '20px 0px 16px 25px',
lineHeight: '15px',
},
};

function SQFormDropdown({
Expand All @@ -62,6 +73,7 @@ function SQFormDropdown({
onChange,
size = 'auto',
muiFieldProps = {},
questions,
}: SQFormDropdownProps): React.ReactElement {
const {
formikField: {field},
Expand Down Expand Up @@ -137,6 +149,11 @@ function SQFormDropdown({
<InputLabel shrink={true} id={labelID}>
{label}
</InputLabel>
{questions && (
<Typography sx={classes.typographyStyle}>
{questions.map((question) => `- ${question}\n`)}
</Typography>
)}
<Select
sx={classes.selectHeight}
displayEmpty={true}
Expand Down
14 changes: 12 additions & 2 deletions stories/SQFormDropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ const MOCK_STATE_OPTIONS = [
{label: 'Missouri', value: 'MO'},
];

const questions = [
'What benefits do you use more often?',
"Are there benefits that you don't use today, but would like to learn if you have them?",
'Are there any quesions that you have about your plan?',
];

const defaultArgs = {
label: 'State',
label: 'Is there anything else you would like your plan to do for you?',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing the default label broke most of the tests for the dropdown component. Can you revert this change and make a second example story with the questions instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurelbean I have made the suggested changes and the checks are also passed

name: 'state',
children: MOCK_STATE_OPTIONS,
sqFormProps: {
Expand All @@ -70,7 +76,11 @@ const Template: DropdownStoryType = (args) => {
validationSchema={schema}
{...sqFormProps}
>
<SQFormDropdownComponent {...dropdownProps} size={getSizeProp(size)} />
<SQFormDropdownComponent
{...dropdownProps}
size={getSizeProp(size)}
questions={questions}
/>
</SQFormStoryWrapper>
</div>
);
Expand Down