From c758deda1f6c3b9487a3d6d30586e3558492644f Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Wed, 19 Feb 2025 21:42:30 +1100 Subject: [PATCH] feat: enhance SingleDatePicker with localization support and improved accessibility --- playground/app.tsx | 1 + src/components/SingleDatePicker.tsx | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/playground/app.tsx b/playground/app.tsx index de24280..bd11158 100644 --- a/playground/app.tsx +++ b/playground/app.tsx @@ -18,6 +18,7 @@ export default () => { day: 1 }} onSelect={onSelect} + localization="zh-CN" /> ) diff --git a/src/components/SingleDatePicker.tsx b/src/components/SingleDatePicker.tsx index 2c30f0a..cb97e0a 100644 --- a/src/components/SingleDatePicker.tsx +++ b/src/components/SingleDatePicker.tsx @@ -83,37 +83,45 @@ export default ({ value, onSelect, localization }: Props) => { + }} aria-label={`Go to last year, ${currentYear - 1}, you are now at year ${currentYear}`}> setCurrentYear(parseInt(e.target.value))} + aria-label="Year input, type a year to go to that year" /> + }} aria-label={`Go to next year, ${currentYear + 1}, you are now at year ${currentYear}`}>
{Array.from({ length: 12 }).map((_, index) => )}
) else return (
- - + - +
{l10nDays.map((day, index) =>
{day}
)} - {dates.map(date => )}