-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* draft loading state * cleanup * add story to trigger loading * merge * icon button * Create lazy-jobs-pump.md * add prop for loading message * handle no visuals loading state * updates snapshots after merging from main * uses unique ID for loading messages, preserves aria-describedby passed to button, rms aria-busy * adds Storybook examples for btn loading error message * reverts unintentional default link underlining * changes loadingMessage to loadingAnnouncement * updates draft Button component with loading prop * updates legacy button counter behavior when loading * Revert "updates draft Button component with loading prop" This reverts commit 7f7f326. * moves error behavior stories to 'Examples' section * screenreader fixes * adds and updates unit tests * re-updates snapshots after using correct VisuallyHidden * documents loading props * adds VRTs, updates loading feature stories * simplifies inner visual/spinner rendering logic * removes example stories (we can put them back when Flash supports focusing its heading) * excludes loading buttons from axe contrast check * fixes visual regression: button counter vertical alignment * prevents double spinners when leading and trailing visuals are passed * test(e2e): update story ids * test(vrt): update snapshots * test(e2e): disable animations in screenshots * test(vrt): update snapshots * preserves rest state styles when button is loading * adds story for success and error announcement * test(vrt): update snapshots * fixes ButtonGroup regression * delete broken snapshots * also targets anchor tags in ButtonGroup styles * add conditional wrapper * fix group * test(vrt): update snapshots * lint * fixes unit tests, updates snapshots * Update src/Button/Button.docs.json Co-authored-by: Pavithra Kodmad <pksjce@github.com> * fixes 'block' layout for loading buttons * uses new internal Status component for loading announcement * updates Tooltip V2 tests to account for loading messageID in button's aria-describedby * fixes BoxProps type import to new preferred syntax * appease the linter * rms ConditionalWrapper * revert back to using ConditionalWrapper with aria-describedby * test(vrt): update snapshots --------- Co-authored-by: Mike Perrotti <mperrotti@github.com> Co-authored-by: Josh Black <joshblack@users.noreply.github.com> Co-authored-by: langermank <langermank@users.noreply.github.com> Co-authored-by: Pavithra Kodmad <pksjce@github.com> Co-authored-by: mperrotti <mperrotti@users.noreply.github.com>
- Loading branch information
1 parent
9f7e873
commit b596859
Showing
100 changed files
with
1,118 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": minor | ||
--- | ||
|
||
Add `loading` state to `Button` and `IconButton` |
Binary file modified
BIN
-16 Bytes
(100%)
....test.ts-snapshots/ActionMenu-Groups-And-Descriptions-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-17 Bytes
(100%)
...Menu.test.ts-snapshots/ActionMenu-Groups-And-Descriptions-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11 Bytes
(100%)
...st.ts-snapshots/ActionMenu-Groups-And-Descriptions-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-16 Bytes
(100%)
.../ActionMenu.test.ts-snapshots/ActionMenu-Groups-And-Descriptions-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-16 Bytes
(100%)
....test.ts-snapshots/ActionMenu-Groups-And-Descriptions-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-14 Bytes
(100%)
...test.ts-snapshots/ActionMenu-Groups-And-Descriptions-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-19 Bytes
(100%)
...t.ts-snapshots/ActionMenu-Groups-And-Descriptions-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-17 Bytes
(100%)
...ActionMenu.test.ts-snapshots/ActionMenu-Groups-And-Descriptions-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-14 Bytes
(100%)
...test.ts-snapshots/ActionMenu-Groups-And-Descriptions-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 Bytes
(100%)
...ActionMenu.test.ts-snapshots/ActionMenu-Single-Select-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-153 Bytes
(98%)
...nts/ActionMenu.test.ts-snapshots/ActionMenu-Single-Select-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+216 Bytes
(100%)
...ionMenu.test.ts-snapshots/ActionMenu-Single-Select-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3 Bytes
(100%)
...components/ActionMenu.test.ts-snapshots/ActionMenu-Single-Select-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 Bytes
(100%)
...ActionMenu.test.ts-snapshots/ActionMenu-Single-Select-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...ctionMenu.test.ts-snapshots/ActionMenu-Single-Select-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+211 Bytes
(100%)
...onMenu.test.ts-snapshots/ActionMenu-Single-Select-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+7 Bytes
(100%)
...omponents/ActionMenu.test.ts-snapshots/ActionMenu-Single-Select-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...ctionMenu.test.ts-snapshots/ActionMenu-Single-Select-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
....test.ts-snapshots/Button-Loading-Custom-Announcement-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.8 KB
...tton.test.ts-snapshots/Button-Loading-Custom-Announcement-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.85 KB
...st.ts-snapshots/Button-Loading-Custom-Announcement-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
...ents/Button.test.ts-snapshots/Button-Loading-Custom-Announcement-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.86 KB
....test.ts-snapshots/Button-Loading-Custom-Announcement-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.9 KB
...test.ts-snapshots/Button-Loading-Custom-Announcement-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.98 KB
...t.ts-snapshots/Button-Loading-Custom-Announcement-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.9 KB
...nts/Button.test.ts-snapshots/Button-Loading-Custom-Announcement-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.9 KB
...test.ts-snapshots/Button-Loading-Custom-Announcement-light-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.86 KB
....test.ts-snapshots/Button-Loading-With-Leading-Visual-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.76 KB
...tton.test.ts-snapshots/Button-Loading-With-Leading-Visual-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.86 KB
...st.ts-snapshots/Button-Loading-With-Leading-Visual-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.81 KB
...ents/Button.test.ts-snapshots/Button-Loading-With-Leading-Visual-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.86 KB
....test.ts-snapshots/Button-Loading-With-Leading-Visual-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.9 KB
...test.ts-snapshots/Button-Loading-With-Leading-Visual-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.96 KB
...t.ts-snapshots/Button-Loading-With-Leading-Visual-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.89 KB
...nts/Button.test.ts-snapshots/Button-Loading-With-Leading-Visual-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.9 KB
...test.ts-snapshots/Button-Loading-With-Leading-Visual-light-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.86 KB
...test.ts-snapshots/Button-Loading-With-Trailing-Visual-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.76 KB
...ton.test.ts-snapshots/Button-Loading-With-Trailing-Visual-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.86 KB
...t.ts-snapshots/Button-Loading-With-Trailing-Visual-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.81 KB
...nts/Button.test.ts-snapshots/Button-Loading-With-Trailing-Visual-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.86 KB
...test.ts-snapshots/Button-Loading-With-Trailing-Visual-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.9 KB
...est.ts-snapshots/Button-Loading-With-Trailing-Visual-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.96 KB
....ts-snapshots/Button-Loading-With-Trailing-Visual-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.88 KB
...ts/Button.test.ts-snapshots/Button-Loading-With-Trailing-Visual-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+6.9 KB
...est.ts-snapshots/Button-Loading-With-Trailing-Visual-light-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.86 KB
...ts/components/Button.test.ts-snapshots/Button-Loading-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.8 KB
...pshots/components/Button.test.ts-snapshots/Button-Loading-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.85 KB
...components/Button.test.ts-snapshots/Button-Loading-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.86 KB
...ght/snapshots/components/Button.test.ts-snapshots/Button-Loading-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.86 KB
...ts/components/Button.test.ts-snapshots/Button-Loading-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.9 KB
...s/components/Button.test.ts-snapshots/Button-Loading-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.98 KB
...omponents/Button.test.ts-snapshots/Button-Loading-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.9 KB
...ht/snapshots/components/Button.test.ts-snapshots/Button-Loading-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+5.9 KB
...s/components/Button.test.ts-snapshots/Button-Loading-light-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
-13 Bytes
(100%)
.../ButtonGroup.test.ts-snapshots/ButtonGroup-Default-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+13 Bytes
(100%)
...ButtonGroup.test.ts-snapshots/ButtonGroup-Default-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+24 Bytes
(100%)
...onGroup.test.ts-snapshots/ButtonGroup-Icon-Buttons-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+93 Bytes
(100%)
...nGroup.test.ts-snapshots/ButtonGroup-Icon-Buttons-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-13 Bytes
(100%)
...ttonGroup.test.ts-snapshots/ButtonGroup-Playground-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+13 Bytes
(100%)
...tonGroup.test.ts-snapshots/ButtonGroup-Playground-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+261 Bytes
(100%)
...ts/components/Dialog.test.ts-snapshots/Dialog-Default-dark-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
+251 Bytes
(100%)
...pshots/components/Dialog.test.ts-snapshots/Dialog-Default-dark-dimmed-linux.png
Oops, something went wrong.
Binary file modified
BIN
+111 Bytes
(100%)
...components/Dialog.test.ts-snapshots/Dialog-Default-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+300 Bytes
(100%)
...ght/snapshots/components/Dialog.test.ts-snapshots/Dialog-Default-dark-linux.png
Oops, something went wrong.
Binary file modified
BIN
+267 Bytes
(100%)
...ts/components/Dialog.test.ts-snapshots/Dialog-Default-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
+137 Bytes
(100%)
...s/components/Dialog.test.ts-snapshots/Dialog-Default-light-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
+127 Bytes
(100%)
...omponents/Dialog.test.ts-snapshots/Dialog-Default-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+178 Bytes
(100%)
...ht/snapshots/components/Dialog.test.ts-snapshots/Dialog-Default-light-linux.png
Oops, something went wrong.
Binary file modified
BIN
+140 Bytes
(100%)
...s/components/Dialog.test.ts-snapshots/Dialog-Default-light-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
+263 Bytes
(100%)
...omponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
+320 Bytes
(100%)
...ts/components/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-dimmed-linux.png
Oops, something went wrong.
Binary file modified
BIN
+113 Bytes
(100%)
...onents/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+277 Bytes
(100%)
...snapshots/components/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-linux.png
Oops, something went wrong.
Binary file modified
BIN
+262 Bytes
(100%)
...omponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
+135 Bytes
(100%)
...mponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
+145 Bytes
(100%)
...nents/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
+226 Bytes
(100%)
...napshots/components/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-linux.png
Oops, something went wrong.
Binary file modified
BIN
+139 Bytes
(100%)
...mponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-tritanopia-linux.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react' | ||
import type {Meta} from '@storybook/react' | ||
import {Button} from '.' | ||
import {DownloadIcon} from '@primer/octicons-react' | ||
import {VisuallyHidden} from '../internal/components/VisuallyHidden' | ||
|
||
const meta: Meta<typeof Button> = { | ||
title: 'Components/Button/Examples', | ||
} as Meta<typeof Button> | ||
|
||
export default meta | ||
|
||
export const LoadingStatusAnnouncementSuccessful = () => { | ||
const [loading, setLoading] = React.useState(false) | ||
const [success, setSuccess] = React.useState(false) | ||
|
||
const resolveAction = async () => { | ||
setLoading(true) | ||
await new Promise(resolve => setTimeout(resolve, 1500)) | ||
setLoading(false) | ||
|
||
return await true | ||
} | ||
|
||
const onClick = (resolveType: 'error' | 'success') => async () => { | ||
const actionResult = await resolveAction() | ||
|
||
if (resolveType === 'error') { | ||
setSuccess(!actionResult) | ||
return | ||
} | ||
|
||
setSuccess(actionResult) | ||
} | ||
|
||
return ( | ||
<> | ||
<VisuallyHidden aria-live="polite">{!loading && success ? 'Export completed' : null}</VisuallyHidden> | ||
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('error')}> | ||
Export (success) | ||
</Button> | ||
</> | ||
) | ||
} | ||
|
||
export const LoadingStatusAnnouncementError = () => { | ||
const [loading, setLoading] = React.useState(false) | ||
const [error, setError] = React.useState(false) | ||
|
||
const resolveAction = async () => { | ||
setLoading(true) | ||
await new Promise(resolve => setTimeout(resolve, 1500)) | ||
setLoading(false) | ||
|
||
return await true | ||
} | ||
|
||
const onClick = (resolveType: 'error' | 'success') => async () => { | ||
const actionResult = await resolveAction() | ||
|
||
if (resolveType === 'error') { | ||
setError(actionResult) | ||
return | ||
} | ||
|
||
setError(!actionResult) | ||
} | ||
|
||
return ( | ||
<> | ||
<VisuallyHidden aria-live="polite">{!loading && error ? 'Export failed' : null}</VisuallyHidden> | ||
|
||
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('error')}> | ||
Export (error) | ||
</Button> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.