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

survey page styling #1646

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion src/features/surveys/components/surveyForm/OptionsQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ const OptionsQuestion: FC<{ element: ZetkinSurveyOptionsQuestionElement }> = ({
}) => {
return (
<FormControl>
<FormLabel id="demo-radio-buttons-group-label">
<FormLabel
id="demo-radio-buttons-group-label"
style={{
color: 'black',
fontSize: '1.5em',
fontWeight: '500',
marginBottom: '0.5em',
marginTop: '0.5em',
}}
>
{element.question.question}
</FormLabel>
{element.question.response_config.widget_type === 'checkbox' && (
Expand Down
14 changes: 12 additions & 2 deletions src/features/surveys/components/surveyForm/TextQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ const OptionsQuestion: FC<{ element: ZetkinSurveyTextQuestionElement }> = ({
element,
}) => {
return (
<FormControl>
<FormLabel id="demo-radio-buttons-group-label">
<FormControl sx={{ width: '100%' }}>
<FormLabel
id="demo-radio-buttons-group-label"
style={{
color: 'black',
fontSize: '1.5em',
fontWeight: '500',
marginBottom: '0.5em',
marginTop: '0.5em',
}}
>
{element.question.question}
</FormLabel>
<TextField
fullWidth
id={`input-${element.id}`}
name={`${element.id}.text`}
type="text"
Expand Down
2 changes: 1 addition & 1 deletion src/features/surveys/l10n/messageIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default makeMessages('feat.surveys', {
anonymous: m('Submit anonymously'),
nameAndEmail: m('Sign with name and e-mail'),
},
signOptions: m('Choose 1 of these signing options below'),
signOptions: m('Choose how to sign'),
submit: m('Submit'),
termsDescription: m<{ organization: string }>(
'When you submit this survey, the information you provide will be stored and processed in Zetkin by {organization} in order to organize activism and in accordance with the Zetkin privacy policy.'
Expand Down
54 changes: 46 additions & 8 deletions src/pages/o/[orgId]/surveys/[surveyId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ import ZUIAvatar from 'zui/ZUIAvatar';
import { FC, useState } from 'react';

import {
Container,
FormControlLabel,
FormControlLabelProps,
Link,
Radio,
RadioGroup,
TextField,
Typography,
useRadioGroup,
} from '@mui/material';

import { Msg, useMessages } from 'core/i18n';
Expand Down Expand Up @@ -163,6 +166,31 @@ type PageProps = {
type FormStatus = 'editing' | 'invalid' | 'error' | 'submitted';
type SignatureOption = 'authenticated' | 'email' | 'anonymous';

function RadioFormControlLabel(props: FormControlLabelProps) {
const radioGroup = useRadioGroup();

let checked = false;

if (radioGroup) {
checked = radioGroup.value === props.value;
}

if (checked) {
return (
<FormControlLabel
checked={checked}
sx={{
backgroundColor: '#fbcbd8',
borderRadius: '50px',
}}
{...props}
/>
);
}

return <FormControlLabel checked={checked} {...props} />;
}

const Page: FC<PageProps> = ({ orgId, status, survey }) => {
const messages = useMessages(messageIds);

Expand All @@ -177,7 +205,7 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
const currentUser = useCurrentUser();

return (
<>
<Container style={{ height: '100vh' }}>
<h1>{survey.title}</h1>

{status === 'error' && <ErrorMessage />}
Expand Down Expand Up @@ -211,7 +239,15 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
)}
</div>
))}
<Typography>
<Typography
style={{
color: 'black',
fontSize: '1.5em',
fontWeight: '500',
marginBottom: '0.5em',
marginTop: '0.5em',
}}
>
<Msg id={messageIds.surveyForm.signOptions} />
</Typography>

Expand All @@ -220,7 +256,7 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
onChange={(e) => handleRadioChange(e.target.value as SignatureOption)}
value={selectedOption}
>
<FormControlLabel
<RadioFormControlLabel
control={<Radio />}
label={
<Typography>
Expand All @@ -236,7 +272,7 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
value="authenticated"
/>

<FormControlLabel
<RadioFormControlLabel
control={<Radio />}
label={
<div>
Expand All @@ -254,8 +290,9 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
}
value="email"
/>

{survey.signature === 'allow_anonymous' && (
<FormControlLabel
<RadioFormControlLabel
control={<Radio />}
label={
<Typography>
Expand All @@ -273,13 +310,13 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
label={<Msg id={messageIds.surveyForm.accept} />}
name="privacy.approval"
/>
<Typography>
<Typography style={{ fontSize: '0.8em' }}>
<Msg
id={messageIds.surveyForm.termsDescription}
values={{ organization: survey.organization.title ?? '' }}
/>
</Typography>
<Typography>
<Typography style={{ fontSize: '0.8em', marginBottom: '0.5em' }}>
<Link
href={messages.surveyForm.policy.link()}
rel="noreferrer"
Expand All @@ -292,13 +329,14 @@ const Page: FC<PageProps> = ({ orgId, status, survey }) => {
<Button
color="primary"
data-testid="Survey-submit"
style={{ textAlign: 'center', width: '100%' }}
type="submit"
variant="contained"
>
{messages.surveyForm.submit()}
</Button>
</form>
</>
</Container>
);
};

Expand Down
Loading