-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a13ee5f
commit c8b30e1
Showing
10 changed files
with
84 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/page-modules/contact/components/form/time-selector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import style from './form.module.css'; | ||
import { TranslatedString, useTranslation } from '@atb/translations'; | ||
import { parseTime } from '@internationalized/date'; | ||
import { | ||
DateInput, | ||
DateSegment, | ||
Label, | ||
TimeField, | ||
} from 'react-aria-components'; | ||
|
||
export type TimeSelectorProps = { | ||
label: TranslatedString; | ||
value: string; | ||
onChange: (value: string) => void; | ||
}; | ||
export default function TimeSelector({ | ||
label, | ||
value, | ||
onChange, | ||
}: TimeSelectorProps) { | ||
const { t } = useTranslation(); | ||
const parsedValue = parseTime(value); | ||
|
||
return ( | ||
<div className={style.time_field_container}> | ||
<Label>{t(label)}</Label> | ||
<TimeField | ||
value={parsedValue} | ||
onChange={(change) => onChange(change.toString())} | ||
hourCycle={24} | ||
shouldForceLeadingZeros | ||
className={style.timeSelector} | ||
data-testid="searchTimeSelector-time" | ||
granularity="minute" | ||
> | ||
<DateInput className={style.timeSelectorInput}> | ||
{(segment) => ( | ||
<DateSegment | ||
className={style.timeSelectorSegment} | ||
segment={segment} | ||
/> | ||
)} | ||
</DateInput> | ||
</TimeField> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters