Skip to content

Commit 554fa26

Browse files
Fix pending animation docs safari (#7073)
* Fix pending animation docs safari * Extract code for progress circle into a collapsed component --------- Co-authored-by: Devon Govett <[email protected]>
1 parent 5ae2346 commit 554fa26

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ Make sure to internationalize the `aria-label` you pass to the [ProgressBar](Pro
170170

171171
```tsx example
172172
import {useState} from 'react';
173-
import {ProgressBar, Text} from 'react-aria-components';
174173

175174
function PendingButton(props) {
176175
let [isPending, setPending] = useState(false);
@@ -189,13 +188,10 @@ function PendingButton(props) {
189188
onPress={handlePress}>
190189
{({isPending}) => (
191190
<>
192-
{!isPending && <Text>Save</Text>}
191+
{!isPending && <span>Save</span>}
193192
{isPending && (
194-
<ProgressBar aria-label="Saving..." isIndeterminate>
195-
<svg width="16" height="16" style={{display: 'block'}}>
196-
<use href="#spinner" />
197-
</svg>
198-
</ProgressBar>
193+
// See below
194+
<MyProgressCircle aria-label="Saving..." isIndeterminate />
199195
)}
200196
</>
201197
)}
@@ -204,19 +200,29 @@ function PendingButton(props) {
204200
}
205201
```
206202

207-
```tsx snippet hidden
208-
<svg>
209-
<defs>
210-
<g id="spinner" transform="scale(0.66)">
211-
<path fill="currentColor" d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25" />
212-
<path fill="currentColor" d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z">
213-
<animateTransform attributeName="transform" type="rotate" dur="0.75s" values="0 12 12;360 12 12" repeatCount="indefinite"/>
214-
</path>
215-
</g>
216-
</defs>
217-
</svg>
203+
<details>
204+
<summary style={{fontWeight: 'bold'}}><ChevronRight size="S" /> MyProgressCircle</summary>
205+
206+
```tsx example render=false export=true
207+
import {ProgressBar} from 'react-aria-components';
208+
import type {ProgressBarProps} from 'react-aria-components';
209+
210+
function MyProgressCircle(props: ProgressBarProps) {
211+
return (
212+
<ProgressBar {...props}>
213+
<svg width="16" height="16" viewBox="0 0 24 24" style={{display: 'block'}}>
214+
<path fill="currentColor" d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25" />
215+
<path fill="currentColor" d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z">
216+
<animateTransform attributeName="transform" type="rotate" dur="0.75s" values="0 12 12;360 12 12" repeatCount="indefinite"/>
217+
</path>
218+
</svg>
219+
</ProgressBar>
220+
);
221+
}
218222
```
219223

224+
</details>
225+
220226
### Accessibility
221227

222228
**Note:**
@@ -252,13 +258,9 @@ function PendingDelayed(props) {
252258
style={{position: 'relative'}}>
253259
{({isPending}) => (
254260
<>
255-
<Text className={isPending ? 'pending' : undefined}>Save</Text>
261+
<span className={isPending ? 'pending' : undefined}>Save</span>
256262
{isPending && (
257-
<ProgressBar aria-label="in progress" isIndeterminate className="spinner">
258-
<svg width="16" height="16" style={{display: 'block'}}>
259-
<use href="#spinner" />
260-
</svg>
261-
</ProgressBar>
263+
<MyProgressCircle aria-label="in progress" isIndeterminate className="spinner" />
262264
)}
263265
</>
264266
)}

0 commit comments

Comments
 (0)