Skip to content

Commit 67c19ff

Browse files
authored
Reorganize React Aria Components docs (#4999)
1 parent 9255da6 commit 67c19ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6262
-4695
lines changed

packages/@react-spectrum/combobox/docs/ComboBox.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ function Example() {
130130
<ComboBox
131131
label="Adobe product (Uncontrolled)"
132132
defaultItems={options}
133-
defaultInputValue={"Adobe XD"}>
133+
defaultInputValue="Adobe XD">
134134
{item => <Item>{item.name}</Item>}
135135
</ComboBox>
136136

137137
<ComboBox
138138
label="Pick an Adobe product (Controlled)"
139-
defaultItems={options} inputValue={value}
139+
defaultItems={options}
140+
inputValue={value}
140141
onInputChange={setValue}>
141142
{item => <Item>{item.name}</Item>}
142143
</ComboBox>
Lines changed: 18 additions & 0 deletions
Loading
Lines changed: 25 additions & 0 deletions
Loading
Lines changed: 28 additions & 0 deletions
Loading

packages/dev/docs/src/Layout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {ToC} from './ToC';
3737
import typographyStyles from '@adobe/spectrum-css-temp/components/typography/vars.css';
3838
import {VersionBadge} from './VersionBadge';
3939

40-
const ENABLE_PAGE_TYPES = false;
40+
const ENABLE_PAGE_TYPES = true;
4141
const INDEX_RE = /^(?:[^/]+\/)?index\.html$/;
4242
const TLD = 'react-spectrum.adobe.com';
4343
const HERO = {

packages/dev/docs/src/docs.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ h2.sectionHeader {
667667
margin-bottom: 8px;
668668
}
669669

670+
h3.sectionHeader.sectionHeader,
671+
h4.sectionHeader.sectionHeader {
672+
margin-top: 2em;
673+
}
674+
670675
.anchor {
671676
opacity: 0;
672677
transition: all 125ms ease-in-out;

packages/react-aria-components/docs/Breadcrumbs.mdx

Lines changed: 85 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {Divider} from '@react-spectrum/divider';
2121
import {ExampleCard} from '@react-spectrum/docs/src/ExampleCard';
2222
import {Keyboard} from '@react-spectrum/text';
2323
import Link from '@react-spectrum/docs/pages/assets/component-illustrations/Link.svg';
24+
import Collections from '@react-spectrum/docs/pages/assets/component-illustrations/Collections.svg';
2425

2526
---
2627
category: Navigation
@@ -147,11 +148,29 @@ parent pages of the current page. Each of these parent links can be clicked, tap
147148
triggered via the <Keyboard>Enter</Keyboard> key to navigate to that page. Optionally, breadcrumbs can be used
148149
in place of a page title, in which case the last breadcrumb acts as a heading.
149150

151+
```tsx
152+
import {Breadcrumbs, Item, Link, Heading} from 'react-aria-components';
153+
154+
<Breadcrumbs>
155+
<Item><Link /></Item>
156+
<Item><Heading /></Item>
157+
</Breadcrumbs>
158+
```
159+
150160
### Concepts
151161

152162
`Breadcrumbs` makes use of the following concepts:
153163

154-
* [Collections](../react-stately/collections.html)
164+
<section className={styles.cardGroup} data-size="small">
165+
166+
<ExampleCard
167+
url="../react-stately/collections.html"
168+
title="Collections"
169+
description="Defining collections of items, async loading, and updating items over time.">
170+
<Collections />
171+
</ExampleCard>
172+
173+
</section>
155174

156175
### Composed components
157176

@@ -168,69 +187,7 @@ in place of a page title, in which case the last breadcrumb acts as a heading.
168187

169188
</section>
170189

171-
## Props
172-
173-
<PropTable component={docs.exports.Breadcrumbs} links={docs.links} />
174-
175-
## Styling
176-
177-
React Aria components can be styled in many ways, including using CSS classes, inline styles, utility classes (e.g. Tailwind), CSS-in-JS (e.g. Styled Components), etc. By default, all components include a builtin `className` attribute which can be targeted using CSS selectors. These follow the `react-aria-ComponentName` naming convention.
178-
179-
```css
180-
.react-aria-Breadcrumbs {
181-
/* ... */
182-
}
183-
```
184-
185-
A custom `className` can also be specified on any component. This overrides the default `className` provided by React Aria with your own.
186-
187-
```jsx
188-
<Breadcrumbs className="my-breadcrumbs">
189-
{/* ... */}
190-
</Breadcrumbs>
191-
```
192-
193-
In addition, some components support multiple UI states (e.g. focused, placeholder, readonly, etc.). React Aria components expose states using data attributes, which you can target in CSS selectors. For example:
194-
195-
```css
196-
.react-aria-Link[data-current] {
197-
/* ... */
198-
}
199-
```
200-
201-
The `className` and `style` props also accept functions which receive states for styling. This lets you dynamically determine the classes or styles to apply, which is useful when using utility CSS libraries like [Tailwind](https://tailwindcss.com/).
202-
203-
```jsx
204-
<Link className={({isCurrent}) => isCurrent ? 'bg-gray-700' : 'bg-gray-600'} />
205-
```
206-
207-
The states, selectors, and render props for all components used in `Breadcrumbs` are documented below.
208-
209-
### Breadcrumbs
210-
211-
`Breadcrumbs` can be targed with the `.react-aria-Breadcrumbs` CSS selector, or by overriding with a custom `className`. It is rendered as a `<nav>` element, and contains an `<ol>` element representing the list of items. This additional element can be targed with the `ol` selector.
212-
213-
```css render=false
214-
.react-aria-Breadcrumbs {
215-
& ol {
216-
/* ... */
217-
}
218-
}
219-
```
220-
221-
### Item
222-
223-
An `Item` can be targeted with the `.react-aria-Item` CSS selector, or by overriding with a custom `className`. It is rendered as an `<li>` element, and should contain a `<Link>` or `<Heading>`. It may also include another element such as a [separator icon](#separator-icons).
224-
225-
### Link
226-
227-
A `Link` can be targeted with the `.react-aria-Link` CSS selector, or by overriding with a custom `className`. It clones its only child element (e.g. `<a>`) and adds additional props, which should be passed through to the underlying DOM node. If only text is provided, it is rendered as a `<span>`. Links support the following states and render props:
228-
229-
<StateTable properties={docs.exports.LinkRenderProps.properties} />
230-
231-
## Usage
232-
233-
### Dynamic collections
190+
## Content
234191

235192
`Breadcrumbs` follows the [Collection Components API](../react-stately/collections.html), accepting both static and dynamic collections.
236193
The examples above show static collections, which can be used when the full list of options is known ahead of time. Dynamic collections,
@@ -259,7 +216,7 @@ function Example() {
259216
}
260217
```
261218

262-
### Heading
219+
## Heading
263220

264221
The last breadcrumb may be used as a heading for the page by placing a `<Heading>` element within the `<Item>` instead of a `<Link>`. By default, this is an `h3` element, but this can be changed with the `level` prop on the `Heading`.
265222

@@ -273,7 +230,7 @@ import {Heading} from 'react-aria-components';
273230
</Breadcrumbs>
274231
```
275232

276-
### Router links
233+
## Router links
277234

278235
The `<Link>` component can wrap a custom link element provided by a router like [React Router](https://reactrouter.com/en/main).
279236

@@ -286,7 +243,7 @@ import {Link as RouterLink} from 'react-router-dom';
286243
</Breadcrumbs>
287244
```
288245

289-
### Separator icons
246+
## Separator icons
290247

291248
The above examples use the CSS `:after` pseudo class to add separators between each item. These may also be DOM elements instead, e.g. SVG icons. Be sure that they have `aria-hidden="true"` so they are hidden from assistive technologies.
292249

@@ -315,7 +272,7 @@ import ChevronIcon from '@spectrum-icons/workflow/ChevronDoubleRight';
315272

316273
</details>
317274

318-
### Disabled
275+
## Disabled
319276

320277
Breadcrumbs can be disabled using the `isDisabled` prop. This indicates that navigation is not currently available. When a breadcrumb is disabled, `onPress` will not be triggered, navigation will not occur, and links will be marked as `aria-disabled` for assistive technologies.
321278

@@ -337,6 +294,66 @@ Individual breadcrumbs can also be disabled by passing the `isDisabled` prop to
337294
</Breadcrumbs>
338295
```
339296

297+
## Props
298+
299+
<PropTable component={docs.exports.Breadcrumbs} links={docs.links} />
300+
301+
## Styling
302+
303+
React Aria components can be styled in many ways, including using CSS classes, inline styles, utility classes (e.g. Tailwind), CSS-in-JS (e.g. Styled Components), etc. By default, all components include a builtin `className` attribute which can be targeted using CSS selectors. These follow the `react-aria-ComponentName` naming convention.
304+
305+
```css
306+
.react-aria-Breadcrumbs {
307+
/* ... */
308+
}
309+
```
310+
311+
A custom `className` can also be specified on any component. This overrides the default `className` provided by React Aria with your own.
312+
313+
```jsx
314+
<Breadcrumbs className="my-breadcrumbs">
315+
{/* ... */}
316+
</Breadcrumbs>
317+
```
318+
319+
In addition, some components support multiple UI states (e.g. focused, placeholder, readonly, etc.). React Aria components expose states using data attributes, which you can target in CSS selectors. For example:
320+
321+
```css
322+
.react-aria-Link[data-current] {
323+
/* ... */
324+
}
325+
```
326+
327+
The `className` and `style` props also accept functions which receive states for styling. This lets you dynamically determine the classes or styles to apply, which is useful when using utility CSS libraries like [Tailwind](https://tailwindcss.com/).
328+
329+
```jsx
330+
<Link className={({isCurrent}) => isCurrent ? 'bg-gray-700' : 'bg-gray-600'} />
331+
```
332+
333+
The states, selectors, and render props for all components used in `Breadcrumbs` are documented below.
334+
335+
### Breadcrumbs
336+
337+
`Breadcrumbs` can be targed with the `.react-aria-Breadcrumbs` CSS selector, or by overriding with a custom `className`. It is rendered as a `<nav>` element, and contains an `<ol>` element representing the list of items. This additional element can be targed with the `ol` selector.
338+
339+
```css render=false
340+
.react-aria-Breadcrumbs {
341+
& ol {
342+
/* ... */
343+
}
344+
}
345+
```
346+
347+
### Item
348+
349+
An `Item` can be targeted with the `.react-aria-Item` CSS selector, or by overriding with a custom `className`. It is rendered as an `<li>` element, and should contain a `<Link>` or `<Heading>`. It may also include another element such as a [separator icon](#separator-icons).
350+
351+
### Link
352+
353+
A `Link` can be targeted with the `.react-aria-Link` CSS selector, or by overriding with a custom `className`. It clones its only child element (e.g. `<a>`) and adds additional props, which should be passed through to the underlying DOM node. If only text is provided, it is rendered as a `<span>`. Links support the following states and render props:
354+
355+
<StateTable properties={docs.exports.LinkRenderProps.properties} />
356+
340357
## Advanced customization
341358

342359
### Contexts

0 commit comments

Comments
 (0)