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

WSTEAM1-969: Add Checkbox #11610

Merged
merged 10 commits into from
May 13, 2024
32 changes: 21 additions & 11 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import React from 'react';
/** @jsx jsx */
import { jsx } from '@emotion/react';
import { InputProps } from '../types';
import Label from './FieldLabel';
import styles from './styles';

export default ({
id,
name,
handleChange,
inputState,
describedBy,
label,
}: InputProps) => {
const { isValid, value = false, required } = inputState;
return (
<input
id={id}
name={name}
type="checkbox"
checked={value as boolean}
onChange={e => handleChange(e.target.name, e.target.checked)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
<div css={[styles.checkboxContainer]}>
<input
css={[styles.checkbox, styles.focusIndicator]}
id={id}
name={name}
type="checkbox"
checked={value as boolean}
onChange={e => handleChange(e.target.name, e.target.checked)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
<Label id={id} css={[styles.checkboxLabel]}>
{label}
</Label>
</div>
);
};
27 changes: 16 additions & 11 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/EmailInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/react';
import { InputProps } from '../types';
import Label from './FieldLabel';
import styles from './styles';

export default ({
Expand All @@ -9,19 +10,23 @@ export default ({
handleChange,
inputState,
describedBy,
label,
}: InputProps) => {
const { isValid, value = '', required } = inputState;
return (
<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)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
<>
<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)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import styles from './styles';
export default ({
id,
children,
}: PropsWithChildren<{ id: InputProps['id'] }>) => (
<Text as="label" htmlFor={id} css={styles.fieldLabel}>
className,
}: PropsWithChildren<{ id: InputProps['id']; className?: string }>) => (
<Text as="label" className={className} htmlFor={id} css={styles.fieldLabel}>
{children}
</Text>
);
29 changes: 17 additions & 12 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/File.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import React from 'react';
import { InputProps } from '../types';
import Label from './FieldLabel';

export default ({
id,
name,
handleChange,
inputState,
describedBy,
label,
}: InputProps) => {
const { isValid, required } = inputState;
return (
<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}
/>
<>
<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}
/>
</>
);
};
27 changes: 16 additions & 11 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/Telephone.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/react';
import { InputProps } from '../types';
import Label from './FieldLabel';
import styles from './styles';

export default ({
Expand All @@ -9,19 +10,23 @@ export default ({
handleChange,
inputState,
describedBy,
label,
}: InputProps) => {
const { isValid, value = '', required } = inputState;
return (
<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)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
<>
<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)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
</>
);
};
27 changes: 16 additions & 11 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/react';
import { InputProps } from '../types';
import Label from './FieldLabel';
import styles from './styles';

export default ({
Expand All @@ -9,20 +10,24 @@ export default ({
handleChange,
inputState,
describedBy,
label,
}: InputProps) => {
const { isValid, value = '', required } = inputState;

return (
<textarea
id={id}
css={[styles.textField, styles.textArea, styles.focusIndicator]}
name={name}
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
rows={4}
/>
<>
<Label id={id}>{label}</Label>
<textarea
id={id}
css={[styles.textField, styles.textArea, styles.focusIndicator]}
name={name}
value={value as string}
onChange={e => handleChange(e.target.name, e.target.value)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
rows={4}
/>
</>
);
};
27 changes: 16 additions & 11 deletions ws-nextjs-app/pages/[service]/send/[id]/FormField/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/react';
import { InputProps } from '../types';
import Label from './FieldLabel';
import styles from './styles';

export default ({
Expand All @@ -9,19 +10,23 @@ export default ({
handleChange,
inputState,
describedBy,
label,
}: InputProps) => {
const { isValid, value = '', required } = inputState;
return (
<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)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
<>
<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)}
aria-invalid={!isValid}
aria-required={required}
aria-describedby={describedBy}
/>
</>
);
};
Loading
Loading