Skip to content

Commit 59af529

Browse files
authored
DatePicker blog post and docs updates (#3233)
1 parent f2b495b commit 59af529

30 files changed

+545
-28
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ A library of React Hooks that provides cross-platform state management for your
2020

2121
[More information about React Stately](https://react-spectrum.adobe.com/react-stately/index.html)
2222

23+
### Internationalized
24+
25+
A collection of framework-agnostic internationalization libraries for the web.
26+
27+
[Internationalized Packages](https://react-spectrum.adobe.com/internationalized/index.html)
28+
2329
## Features
2430

2531
* ♿️ **[Accessible](https://react-spectrum.adobe.com/react-aria/accessibility.html)** – Accessibility and behavior is implemented according to [WAI-ARIA Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.2/), including full screen reader and keyboard navigation support. All components have been tested across a wide variety of screen readers and devices to ensure the best experience possible for all users.

packages/@internationalized/date/docs/CalendarDate.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ import {parseDate} from '@internationalized/date';
4848
let date = parseDate('2022-02-03');
4949
```
5050

51+
Today's date can be retrieved using the <TypeLink links={docs.links} type={docs.exports.today} /> function. This requires a time zone identifier to be provided, which is used to determine the local date. The <TypeLink links={docs.links} type={docs.exports.getLocalTimeZone} /> function can be used to retrieve the user's current time zone.
52+
53+
```tsx
54+
import {today, getLocalTimeZone} from '@internationalized/date';
55+
56+
let nyDate = today('America/New_York');
57+
let localDate = today(getLocalTimeZone());
58+
```
59+
5160
Once you have a `CalendarDate` object, you can read its properties, or manipulate it as described in the [Manipulating dates](#manipulating-dates) section below. You can also convert it to an ISO 8601 string, native JavaScript `Date` object, or another representation. See the [Conversion](#conversion) section below for details.
5261

5362
```tsx
@@ -320,7 +329,7 @@ isWeekday(date, 'en-US'); // false
320329
isWeekday(date, 'he-IL'); // true
321330

322331
isWeekend(date, 'en-US'); // true
323-
isWeekday(date, 'he-IL'); // false
332+
isWeekend(date, 'he-IL'); // false
324333
```
325334

326335
### Weeks in month

packages/@internationalized/date/docs/CalendarDateTime.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ isWeekday(date, 'en-US'); // false
378378
isWeekday(date, 'he-IL'); // true
379379

380380
isWeekend(date, 'en-US'); // true
381-
isWeekday(date, 'he-IL'); // false
381+
isWeekend(date, 'he-IL'); // false
382382
```
383383

384384
### Weeks in month

packages/@internationalized/date/docs/ZonedDateTime.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ let date = parseAbsolute('2021-11-07T07:45:00Z', 'America/Los_Angeles');
6161
let date = parseAbsoluteToLocal('2021-11-07T07:45:00Z');
6262
```
6363

64+
The current time can be retrieved using the <TypeLink links={docs.links} type={docs.exports.now} /> function. This requires a time zone identifier to be provided, which is used to determine the local time. The <TypeLink links={docs.links} type={docs.exports.getLocalTimeZone} /> function can be used to retrieve the user's current time zone.
65+
66+
```tsx
67+
import {now, getLocalTimeZone} from '@internationalized/date';
68+
69+
let nyTime = now('America/New_York');
70+
let localTime = now(getLocalTimeZone());
71+
```
72+
6473
Once you have a `ZonedDateTime` object, you can read its properties, or manipulate it as described in the [Manipulating dates](#manipulating-dates) section below. You can also convert it to an ISO 8601 string, native JavaScript `Date` object, or another representation. See the [Conversion](#conversion) section below for details.
6574

6675
```tsx
@@ -464,7 +473,7 @@ isWeekday(date, 'en-US'); // false
464473
isWeekday(date, 'he-IL'); // true
465474

466475
isWeekend(date, 'en-US'); // true
467-
isWeekday(date, 'he-IL'); // false
476+
isWeekend(date, 'he-IL'); // false
468477
```
469478

470479
### Weeks in month

packages/@internationalized/date/docs/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import packageData from '@internationalized/date/package.json';
1717
category: Date and Time
1818
keywords: [date, time]
1919
order: -1
20-
title: Introduction
20+
navigationTitle: Introduction
21+
description: The @internationalized/date package provides objects and functions for representing and manipulating dates and times in a locale-aware manner.
2122
---
2223

2324
# @internationalized/date

packages/@internationalized/number/docs/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import packageData from '@internationalized/number/package.json';
1717
category: Numbers
1818
keywords: [number, internationalization]
1919
order: 0
20-
title: Introduction
20+
navigationTitle: Introduction
21+
description: The @internationalized/number package provides utilities for formatting and parsing numbers across locales and numbering systems.
2122
---
2223

2324
# @internationalized/number

packages/@react-aria/calendar/docs/useCalendar.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ There is no standalone calendar element in HTML. `<input type="date">` is close,
5151
* **Accessible** – Calendar cells can be navigated and selected using the keyboard, and localized screen reader messages are included to announce when the selection and visible date range change.
5252
* **Customizable** – As with all of React Aria, the DOM structure and styling of all elements can be fully customized.
5353

54+
Read our [blog post](../blog/date-and-time-pickers-for-all.html) for more details about the internationalization, accessibility, and user experience features implemented by `useCalendar`.
55+
5456
## Anatomy
5557

56-
<Anatomy />
58+
<Anatomy
59+
role="img"
60+
aria-label="Anatomy diagram of a calendar component, which consists of a heading, grid of cells, previous, and next buttons." />
5761

5862
A calendar consists of a grouping element containing one or more date grids (e.g. months), and a previous and next button for navigating between date ranges. Each calendar grid consists of cells containing button elements that can be pressed and navigated to using the arrow keys to select a date.
5963

packages/@react-aria/calendar/docs/useRangeCalendar.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ There is no standalone range calendar element in HTML. Two separate `<input type
5050
* **Touch friendly** – Date ranges can be selected by dragging over dates in the calendar using a touch screen, and all interactions are accessible using touch-based screen readers.
5151
* **Customizable** – As with all of React Aria, the DOM structure and styling of all elements can be fully customized.
5252

53+
Read our [blog post](../blog/date-and-time-pickers-for-all.html) for more details about the internationalization, accessibility, and user experience features implemented by `useRangeCalendar`.
54+
5355
## Anatomy
5456

55-
<Anatomy />
57+
<Anatomy
58+
role="img"
59+
aria-label="Anatomy diagram of a range calendar component, which consists of a heading, grid of cells, previous, and next buttons." />
5660

5761
A range calendar consists of a grouping element containing one or more date grids (e.g. months), and a previous and next button for navigating through time. Each calendar grid consists of cells containing button elements that can be pressed and navigated to using the arrow keys to select a date range. Once a start date is selected, the user can navigate to another date using the keyboard or by hovering over it, and clicking it or pressing the <Keyboard>Enter</Keyboard> key commits the selected date range.
5862

packages/@react-aria/datepicker/docs/useDateField.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ A date field can be built using `<input type="date">`, but this is very limited
4949
* **Touch friendly** – Date segments are editable using an easy to use numeric keypad, and all interactions are accessible using touch-based screen readers.
5050
* **Customizable** – As with all of React Aria, the DOM structure and styling of all elements can be fully customized.
5151

52+
Read our [blog post](../blog/date-and-time-pickers-for-all.html) for more details about the internationalization, accessibility, and user experience features implemented by `useDateField`.
53+
5254
## Anatomy
5355

54-
<Anatomy />
56+
<Anatomy
57+
role="img"
58+
aria-label="Anatomy diagram of a date field component, which consists of a label, field, segments for each date unit." />
5559

5660
A date field consists of a label, and a group of segments representing each unit of a date and time (e.g. years, months, days, etc.). Each segment is individually focusable and editable by the user, by typing or using the arrow keys to increment and decrement the value. This approach allows values to be formatted and parsed correctly regardless of the locale or date format, and offers an easy and error-free way to edit dates using the keyboard.
5761

@@ -261,7 +265,7 @@ import {parseZonedDateTime} from '@internationalized/date';
261265
defaultValue={parseZonedDateTime('2022-11-07T00:45[America/Los_Angeles]')} />
262266
```
263267

264-
`useDateField` displays times in the time zone included in the `ZoneDateTime` object. The above example is always displayed in Pacific Standard Time because the `America/Los_Angeles` time zone identifier is provided. [@internationalized/date](../internationalized/date/) includes functions for converting dates between time zones, or parsing a date directly into a specific time zone or the user's local time zone, as shown below.
268+
`useDateField` displays times in the time zone included in the `ZonedDateTime` object. The above example is always displayed in Pacific Standard Time because the `America/Los_Angeles` time zone identifier is provided. [@internationalized/date](../internationalized/date/) includes functions for converting dates between time zones, or parsing a date directly into a specific time zone or the user's local time zone, as shown below.
265269

266270
```tsx example
267271
import {parseAbsoluteToLocal} from '@internationalized/date';

packages/@react-aria/datepicker/docs/useDatePicker.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ A date picker can be built using `<input type="date">`, but this is very limited
4949
* **Touch friendly** – Date segments are editable using an easy to use numeric keypad, and all interactions are accessible using touch-based screen readers.
5050
* **Customizable** – As with all of React Aria, the DOM structure and styling of all elements can be fully customized.
5151

52+
Read our [blog post](../blog/date-and-time-pickers-for-all.html) for more details about the internationalization, accessibility, and user experience features implemented by `useDatePicker`.
53+
5254
## Anatomy
5355

54-
<Anatomy />
56+
<Anatomy
57+
role="img"
58+
aria-label="Anatomy diagram of an expanded date picker component, which consists of a labelled group containing a date field, and a button that toggles a popover dialog containing a calendar." />
5559

5660
A date picker consists of a label, and group containing a [date field](useDateField.html) and a button. Clicking the button opens a popup containing a [calendar](useCalendar.html). The date field includes segments representing each unit of a date and time (e.g. years, months, days, etc.), each of which is individually focusable and editable using the keyboard. The calendar popup offers a more visual way of choosing a date.
5761

@@ -518,7 +522,7 @@ import {parseZonedDateTime} from '@internationalized/date';
518522
defaultValue={parseZonedDateTime('2022-11-07T00:45[America/Los_Angeles]')} />
519523
```
520524

521-
`useDatePicker` displays times in the time zone included in the `ZoneDateTime` object. The above example is always displayed in Pacific Standard Time because the `America/Los_Angeles` time zone identifier is provided. [@internationalized/date](../internationalized/date/) includes functions for converting dates between time zones, or parsing a date directly into a specific time zone or the user's local time zone, as shown below.
525+
`useDatePicker` displays times in the time zone included in the `ZonedDateTime` object. The above example is always displayed in Pacific Standard Time because the `America/Los_Angeles` time zone identifier is provided. [@internationalized/date](../internationalized/date/) includes functions for converting dates between time zones, or parsing a date directly into a specific time zone or the user's local time zone, as shown below.
522526

523527
```tsx example
524528
import {parseAbsoluteToLocal} from '@internationalized/date';

0 commit comments

Comments
 (0)