Skip to content

Commit

Permalink
Merge branch 'latest' into WSTEAM1-1020-adds-default-styling-text-lin…
Browse files Browse the repository at this point in the history
…k-uploader
  • Loading branch information
HarveyPeachey committed May 20, 2024
2 parents bdb2cc4 + 26f5b4e commit 5c3f14b
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 120 deletions.
9 changes: 4 additions & 5 deletions ws-nextjs-app/pages/[service]/send/[id]/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Form({
privacyNotice,
}: Props) {
const { handleSubmit, submissionError, submitted } = useFormContext();

const translation = 'Our data policy';
const formFields = fields?.map(({ id, label, htmlType }) => (
<FormField key={id} id={id} label={label} htmlType={htmlType} />
));
Expand All @@ -45,12 +45,11 @@ export default function Form({
<form onSubmit={handleSubmit} noValidate>
{formFields}

<Heading // TODO: need translations for this, it doesn't come through from the api
level={3}
<strong // TODO: need translations for this, it doesn't come through from the api
css={styles.privacyHeading}
>
Our data policy
</Heading>
{translation}
</strong>
<div
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: privacyNotice }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default ({
})}
{...(required && { 'aria-required': required })}
/>

<Label id={id} css={[styles.checkboxLabel]}>
{label}
</Label>
Expand Down
28 changes: 15 additions & 13 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/EmailInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ export default ({
return (
<>
<Label id={id}>{label}</Label>
<input
css={[styles.textField, styles.focusIndicator]}
id={id}
name={name}
type="email"
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
{...(hasAttemptedSubmit && {
...(wasInvalid && { 'aria-invalid': !isValid }),
...(required && { 'aria-required': required }),
...(!isValid && { 'aria-describedby': describedBy }),
})}
/>
<div>
<input
css={[styles.textField, styles.focusIndicator]}
id={id}
name={name}
type="email"
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
{...(hasAttemptedSubmit && {
...(wasInvalid && { 'aria-invalid': !isValid }),
...(required && { 'aria-required': required }),
...(!isValid && { 'aria-describedby': describedBy }),
})}
/>
</div>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export default ({
id,
children,
className,
}: PropsWithChildren<{ id: InputProps['id']; className?: string }>) => (
}: PropsWithChildren<{
id: InputProps['id'];
className?: string;
}>) => (
<Text as="label" className={className} htmlFor={id} css={styles.fieldLabel}>
{children}
</Text>
Expand Down
26 changes: 14 additions & 12 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ export default ({
return (
<>
<Label id={id}>{label}</Label>
<input
id={id}
name={name}
type="file"
onChange={e =>
e.target.files && handleChange(e.target.name, e.target.files)
}
multiple
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
<div>
<input
id={id}
name={name}
type="file"
onChange={e =>
e.target.files && handleChange(e.target.name, e.target.files)
}
multiple
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
</div>
</>
);
};
28 changes: 15 additions & 13 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/Telephone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ export default ({
return (
<>
<Label id={id}>{label}</Label>
<input
id={id}
css={[styles.textField, styles.focusIndicator]}
name={name}
type="tel"
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
{...(hasAttemptedSubmit && {
...(wasInvalid && { 'aria-invalid': !isValid }),
...(required && { 'aria-required': required }),
...(!isValid && { 'aria-describedby': describedBy }),
})}
/>
<div>
<input
id={id}
css={[styles.textField, styles.focusIndicator]}
name={name}
type="tel"
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
{...(hasAttemptedSubmit && {
...(wasInvalid && { 'aria-invalid': !isValid }),
...(required && { 'aria-required': required }),
...(!isValid && { 'aria-describedby': describedBy }),
})}
/>
</div>
</>
);
};
10 changes: 10 additions & 0 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/react';
import Paragraph from '#app/components/Paragraph';
import pixelsToRem from '#app/utilities/pixelsToRem';
import { InputProps } from '../types';
import Label from './FieldLabel';
import styles from './styles';
Expand All @@ -14,10 +16,18 @@ export default ({
hasAttemptedSubmit,
}: InputProps) => {
const { isValid, value = '', required, wasInvalid } = inputState ?? {};
const translation = 'Maximum 500 Words';

return (
<>
<Label id={id}>{label}</Label>
<Paragraph
css={{ marginBottom: `${pixelsToRem(6)}rem` }}
fontVariant="sansRegular"
size="brevier"
>
{translation}
</Paragraph>
<textarea
id={id}
css={[styles.textField, styles.textArea, styles.focusIndicator]}
Expand Down
28 changes: 15 additions & 13 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ export default ({
return (
<>
<Label id={id}>{label}</Label>
<input
css={[styles.textField, styles.focusIndicator]}
id={id}
name={name}
type="text"
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
{...(hasAttemptedSubmit && {
...(wasInvalid && { 'aria-invalid': !isValid }),
...(required && { 'aria-required': required }),
...(!isValid && { 'aria-describedby': describedBy }),
})}
/>
<div>
<input
css={[styles.textField, styles.focusIndicator]}
id={id}
name={name}
type="text"
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
{...(hasAttemptedSubmit && {
...(wasInvalid && { 'aria-invalid': !isValid }),
...(required && { 'aria-required': required }),
...(!isValid && { 'aria-describedby': describedBy }),
})}
/>
</div>
</>
);
};
Loading

0 comments on commit 5c3f14b

Please sign in to comment.