Skip to content

Commit 1d14dbf

Browse files
authored
Moving aria hook imports into first doc example (#2677)
1 parent a2e8a13 commit 1d14dbf

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

+88
-175
lines changed

packages/@react-aria/breadcrumbs/docs/useBreadcrumbs.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import {Keyboard} from '@react-spectrum/text';
1616
import packageData from '@react-aria/breadcrumbs/package.json';
1717
import Anatomy from './anatomy.svg';
1818

19-
```jsx import
20-
import {useBreadcrumbs, useBreadcrumbItem} from '@react-aria/breadcrumbs';
21-
```
22-
2319
---
2420
category: Navigation
2521
keywords: [breadcrumbs, aria]
@@ -92,6 +88,8 @@ passed to the last breadcrumb item by cloning the element and adding the `isCurr
9288
prop.
9389

9490
```tsx example
91+
import {useBreadcrumbs, useBreadcrumbItem} from '@react-aria/breadcrumbs';
92+
9593
function Breadcrumbs(props) {
9694
let {navProps} = useBreadcrumbs(props);
9795
let children = React.Children.toArray(props.children);

packages/@react-aria/button/docs/useButton.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ import {HeaderInfo, FunctionAPI, PageDescription} from '@react-spectrum/docs';
1515
import {Keyboard} from '@react-spectrum/text';
1616
import packageData from '@react-aria/button/package.json';
1717

18-
```jsx import
19-
import {useButton} from '@react-aria/button';
20-
import {useRef} from 'react';
21-
```
22-
2318
---
2419
category: Buttons
2520
keywords: [button, aria, form]
@@ -66,6 +61,9 @@ If a visual label is not provided (e.g. an icon only button), then an `aria-labe
6661
By default, `useButton` assumes that you are using it with a native `<button>` element.
6762

6863
```tsx example
64+
import {useButton} from '@react-aria/button';
65+
import {useRef} from 'react';
66+
6967
function Button(props) {
7068
let ref = useRef();
7169
let {buttonProps} = useButton(props, ref);

packages/@react-aria/button/docs/useToggleButton.mdx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink, PageDescr
1616
import {Keyboard} from '@react-spectrum/text';
1717
import packageData from '@react-aria/button/package.json';
1818

19-
```jsx import
20-
import {useToggleButton} from '@react-aria/button';
21-
import {useRef} from 'react';
22-
```
23-
2419
---
2520
category: Buttons
2621
keywords: [button, toggle button, aria, form]
@@ -83,6 +78,8 @@ The toggle state is used to switch between a green and blue background when unse
8378
In addition, the `isPressed` state is used to adjust the background to be darker when the user presses down on the button.
8479

8580
```tsx example
81+
import {useRef} from 'react';
82+
import {useToggleButton} from '@react-aria/button';
8683
import {useToggleState} from '@react-stately/toggle';
8784

8885
function ToggleButton(props) {

packages/@react-aria/checkbox/docs/useCheckbox.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ import {Keyboard} from '@react-spectrum/text';
1919
import packageData from '@react-aria/checkbox/package.json';
2020
import Anatomy from './checkbox-anatomy.svg';
2121

22-
```jsx import
23-
import {useCheckbox} from '@react-aria/checkbox';
24-
```
25-
2622
---
2723
category: Forms
2824
keywords: [checkbox, input, aria]
@@ -80,6 +76,7 @@ technology.
8076
## Example
8177

8278
```tsx example
79+
import {useCheckbox} from '@react-aria/checkbox';
8380
import {useToggleState} from '@react-stately/toggle';
8481

8582
function Checkbox(props) {

packages/@react-aria/checkbox/docs/useCheckboxGroup.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ import {Keyboard} from '@react-spectrum/text';
1919
import packageData from '@react-aria/checkbox/package.json';
2020
import Anatomy from './checkboxgroup-anatomy.svg';
2121

22-
```jsx import
23-
import {useCheckboxGroup, useCheckboxGroupItem} from '@react-aria/checkbox';
24-
```
25-
2622
---
2723
category: Forms
2824
keywords: [checkbox, input, aria]
@@ -101,6 +97,7 @@ to each checkbox. An HTML `<label>` element wraps the native input and the text
10197
for the radio.
10298

10399
```tsx example
100+
import {useCheckboxGroup, useCheckboxGroupItem} from '@react-aria/checkbox';
104101
import {useCheckboxGroupState} from '@react-stately/checkbox';
105102

106103
let CheckboxGroupContext = React.createContext(null);

packages/@react-aria/color/docs/useColorField.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink, PageDescr
1616
import packageData from '@react-aria/color/package.json';
1717
import Anatomy from './ColorFieldAnatomy.svg';
1818

19-
```jsx import
20-
import {useColorField} from '@react-aria/color';
21-
```
22-
2319
---
2420
category: Color
2521
keywords: [color, input, color picker, aria]
@@ -80,6 +76,7 @@ to identify the element to screen readers.
8076
## Example
8177

8278
```tsx example export=true
79+
import {useColorField} from '@react-aria/color';
8380
import {useColorFieldState} from '@react-stately/color';
8481

8582
function ColorField(props) {

packages/@react-aria/color/docs/useColorSlider.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink, PageDescr
1717
import packageData from '@react-aria/color/package.json';
1818
import Anatomy from './ColorSliderAnatomy.svg';
1919

20-
```jsx import
21-
import {useColorSlider} from '@react-aria/color';
22-
```
23-
2420
---
2521
category: Color
2622
keywords: [color slider, color picker, aria]
@@ -100,6 +96,7 @@ using the [VisuallyHidden](VisuallyHidden.html) component. The thumb also uses t
10096
grow in size when it is keyboard focused (try tabbing to it).
10197

10298
```tsx example export=true
99+
import {useColorSlider} from '@react-aria/color';
103100
import {useColorSliderState} from '@react-stately/color';
104101
import {VisuallyHidden} from '@react-aria/visually-hidden';
105102
import {useLocale} from '@react-aria/i18n';

packages/@react-aria/color/docs/useColorWheel.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import {HeaderInfo, FunctionAPI, TypeContext, InterfaceType, TypeLink, PageDescr
1616
import packageData from '@react-aria/color/package.json';
1717
import Anatomy from './ColorWheelAnatomy.svg';
1818

19-
```jsx import
20-
import {useColorWheel} from '@react-aria/color';
21-
```
22-
2319
---
2420
category: Color
2521
keywords: [color wheel, color picker, aria]
@@ -88,6 +84,7 @@ using the [VisuallyHidden](VisuallyHidden.html) component. The thumb also uses t
8884
grow in size when it is keyboard focused (try tabbing to it).
8985

9086
```tsx example export=true
87+
import {useColorWheel} from '@react-aria/color';
9188
import {useColorWheelState} from '@react-stately/color';
9289
import {VisuallyHidden} from '@react-aria/visually-hidden';
9390
import {useFocusRing} from '@react-aria/focus';

packages/@react-aria/focus/docs/FocusRing.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import docs from 'docs:@react-aria/focus';
1414
import {HeaderInfo, PropTable, PageDescription} from '@react-spectrum/docs';
1515
import packageData from '@react-aria/focus/package.json';
1616

17-
```tsx import
18-
import {FocusRing} from '@react-aria/focus';
19-
```
20-
2117
---
2218
category: Focus
2319
keywords: [focus, keyboard focus, focus management, aria]
@@ -67,6 +63,8 @@ This example shows how to use `<FocusRing>` to apply a CSS class when keyboard f
6763
```
6864

6965
```tsx example
66+
import {FocusRing} from '@react-aria/focus';
67+
7068
<FocusRing focusRingClass="focus-ring">
7169
<button className="button">Test</button>
7270
</FocusRing>

packages/@react-aria/focus/docs/FocusScope.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ import {HeaderInfo, PropTable, FunctionAPI, TypeLink, ClassAPI, PageDescription}
1515
import {Keyboard} from '@react-spectrum/text';
1616
import packageData from '@react-aria/focus/package.json';
1717

18-
```tsx import
19-
import {FocusScope, useFocusManager} from '@react-aria/focus';
20-
```
21-
2218
---
2319
category: Focus
2420
keywords: [focus scope, keyboard focus, focus management, aria]
@@ -68,6 +64,8 @@ button unmounts the focus scope, which restores focus back to the button.
6864
For a full example of building a modal dialog, see [useDialog](useDialog.html).
6965

7066
```tsx example
67+
import {FocusScope} from '@react-aria/focus';
68+
7169
function Example() {
7270
let [isOpen, setOpen] = React.useState(false);
7371
return (
@@ -93,6 +91,8 @@ right arrow keys to move focus to the previous and next buttons. The `wrap` opti
9391
used to make focus wrap around when it reaches the first or last button.
9492

9593
```tsx example
94+
import {useFocusManager} from '@react-aria/focus';
95+
9696
function Toolbar(props) {
9797
return (
9898
<div role="toolbar">

0 commit comments

Comments
 (0)