diff options
author | Hailey <me@haileyok.com> | 2024-03-19 12:47:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-19 12:47:46 -0700 |
commit | a1c4f19731878f7026d398d28e475bbeb7de824a (patch) | |
tree | 3b4b869b69f71dacda41707b786916bb46a9f3f1 /src/components/forms/DateField/index.tsx | |
parent | b6903419a1112bae5397a398756e46a46afcf65f (diff) | |
download | voidsky-a1c4f19731878f7026d398d28e475bbeb7de824a.tar.zst |
Use ALF for signup flow, improve a11y of signup (#3151)
* Use ALF for signup flow, improve a11y of signup * adjust padding * rm log * org imports * clarify allowance of hyphens Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * fix a few accessibility items * Standardise date input across platforms (#3223) * make the date input consistent across platforms * integrate into new signup form * rm log * add transitions * show correct # of steps * use `FormError` * animate buttons * use `ScreenTransition` * fix android text overflow via flex -> flex_1 * change button color * (android) make date input the same height as others * fix deps * fix deps --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> Co-authored-by: Samuel Newman <mozzius@protonmail.com>
Diffstat (limited to 'src/components/forms/DateField/index.tsx')
-rw-r--r-- | src/components/forms/DateField/index.tsx | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/src/components/forms/DateField/index.tsx b/src/components/forms/DateField/index.tsx index 49e47a01e..22fa3a9f5 100644 --- a/src/components/forms/DateField/index.tsx +++ b/src/components/forms/DateField/index.tsx @@ -1,11 +1,16 @@ import React from 'react' import {View} from 'react-native' -import {useTheme, atoms} from '#/alf' +import {useTheme, atoms as a} from '#/alf' import * as TextField from '#/components/forms/TextField' import {toSimpleDateString} from '#/components/forms/DateField/utils' import {DateFieldProps} from '#/components/forms/DateField/types' import DatePicker from 'react-native-date-picker' +import * as Dialog from '#/components/Dialog' +import {DateFieldButton} from './index.shared' +import {Button, ButtonText} from '#/components/Button' +import {Trans, msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' export * as utils from '#/components/forms/DateField/utils' export const Label = TextField.Label @@ -22,8 +27,12 @@ export function DateField({ onChangeDate, testID, label, + isInvalid, + accessibilityHint, }: DateFieldProps) { + const {_} = useLingui() const t = useTheme() + const control = Dialog.useDialogControl() const onChangeInternal = React.useCallback( (date: Date | undefined) => { @@ -36,17 +45,43 @@ export function DateField({ ) return ( - <View style={[atoms.relative, atoms.w_full]}> - <DatePicker - theme={t.name === 'light' ? 'light' : 'dark'} - date={new Date(value)} - onDateChange={onChangeInternal} - mode="date" - testID={`${testID}-datepicker`} - aria-label={label} - accessibilityLabel={label} - accessibilityHint={undefined} + <> + <DateFieldButton + label={label} + value={value} + onPress={control.open} + isInvalid={isInvalid} + accessibilityHint={accessibilityHint} /> - </View> + <Dialog.Outer control={control} testID={testID}> + <Dialog.Handle /> + <Dialog.Inner label={label}> + <View style={a.gap_lg}> + <View style={[a.relative, a.w_full, a.align_center]}> + <DatePicker + theme={t.name === 'light' ? 'light' : 'dark'} + date={new Date(value)} + onDateChange={onChangeInternal} + mode="date" + testID={`${testID}-datepicker`} + aria-label={label} + accessibilityLabel={label} + accessibilityHint={accessibilityHint} + /> + </View> + <Button + label={_(msg`Done`)} + onPress={() => control.close()} + size="medium" + color="primary" + variant="solid"> + <ButtonText> + <Trans>Done</Trans> + </ButtonText> + </Button> + </View> + </Dialog.Inner> + </Dialog.Outer> + </> ) } |