-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…4485) * Revert "Revert "Add `loading` prop for `Button` and `IconButton` (#3582)" (#4…" This reverts commit c01901f. * only overrides btn label when loading * update tooltip tests to accomodate loading message aria-describedby * import missing modules in IconButton stories * makes aria-labelledby prop remain set when when button is in a loading state * Update packages/react/src/Button/Button.examples.stories.tsx Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com> * Update packages/react/src/Button/Button.examples.stories.tsx Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com> * updates textinput snapshots * addresses remaining PR feedback * appeases the linter, updates snaps * leaves loading prop undefined so we do not always render the wrapper * test(vrt): update snapshots * trying again without changing colors on faux-disabled buttons * replaces Status with AriaStatus * replaces one more Status with AriaStatus * rms added aria-disabled styles * test(vrt): update snapshots * Update icon button tests to make it work with the loading state * add story with leading visual and count * misc bugfixes: - ensures counter stays rendered even when no children are passed - preserves space between elements that are children of span[data-component=text] - adds story and VRT for buttons with a trailing action but no leading/trailing visuals * test(vrt): update snapshots --------- Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com> Co-authored-by: Kate Higa <16447748+khiga8@users.noreply.github.com> Co-authored-by: mperrotti <mperrotti@users.noreply.github.com> Co-authored-by: Armagan Ersoz <broccolinisoup@github.com>
- Loading branch information
1 parent
8574027
commit 991839c
Showing
91 changed files
with
1,063 additions
and
304 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
-61 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
-150 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
-91 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
-61 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
-61 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
-640 Bytes
(98%)
...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
-28 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
-631 Bytes
(98%)
...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
-640 Bytes
(98%)
...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
-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 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.9 KB
...nts/Button.test.ts-snapshots/Button-Loading-Custom-Announcement-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 added
BIN
+5.9 KB
...test.ts-snapshots/Button-Loading-Custom-Announcement-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
+6.86 KB
....test.ts-snapshots/Button-Loading-With-Leading-Visual-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
+6.76 KB
...tton.test.ts-snapshots/Button-Loading-With-Leading-Visual-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
+6.86 KB
...st.ts-snapshots/Button-Loading-With-Leading-Visual-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
+6.81 KB
...ents/Button.test.ts-snapshots/Button-Loading-With-Leading-Visual-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
+6.86 KB
....test.ts-snapshots/Button-Loading-With-Leading-Visual-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
+6.9 KB
...test.ts-snapshots/Button-Loading-With-Leading-Visual-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
+6.89 KB
...nts/Button.test.ts-snapshots/Button-Loading-With-Leading-Visual-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 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
+8.01 KB
...test.ts-snapshots/Button-Loading-With-Trailing-Action-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+7.92 KB
...ton.test.ts-snapshots/Button-Loading-With-Trailing-Action-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.11 KB
...t.ts-snapshots/Button-Loading-With-Trailing-Action-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.01 KB
...nts/Button.test.ts-snapshots/Button-Loading-With-Trailing-Action-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.01 KB
...test.ts-snapshots/Button-Loading-With-Trailing-Action-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.1 KB
...est.ts-snapshots/Button-Loading-With-Trailing-Action-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.19 KB
....ts-snapshots/Button-Loading-With-Trailing-Action-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.1 KB
...ts/Button.test.ts-snapshots/Button-Loading-With-Trailing-Action-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.1 KB
...est.ts-snapshots/Button-Loading-With-Trailing-Action-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.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.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
-292 Bytes
(100%)
...ts/components/Dialog.test.ts-snapshots/Dialog-Default-dark-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
-465 Bytes
(100%)
...pshots/components/Dialog.test.ts-snapshots/Dialog-Default-dark-dimmed-linux.png
Oops, something went wrong.
Binary file modified
BIN
-78 Bytes
(100%)
...components/Dialog.test.ts-snapshots/Dialog-Default-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-314 Bytes
(100%)
...ght/snapshots/components/Dialog.test.ts-snapshots/Dialog-Default-dark-linux.png
Oops, something went wrong.
Binary file modified
BIN
-303 Bytes
(100%)
...ts/components/Dialog.test.ts-snapshots/Dialog-Default-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
-211 Bytes
(100%)
...s/components/Dialog.test.ts-snapshots/Dialog-Default-light-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
-269 Bytes
(100%)
...omponents/Dialog.test.ts-snapshots/Dialog-Default-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-204 Bytes
(100%)
...ht/snapshots/components/Dialog.test.ts-snapshots/Dialog-Default-light-linux.png
Oops, something went wrong.
Binary file modified
BIN
-203 Bytes
(100%)
...s/components/Dialog.test.ts-snapshots/Dialog-Default-light-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
-326 Bytes
(100%)
...omponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
-390 Bytes
(100%)
...ts/components/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-dimmed-linux.png
Oops, something went wrong.
Binary file modified
BIN
-20 Bytes
(100%)
...onents/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-282 Bytes
(100%)
...snapshots/components/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-linux.png
Oops, something went wrong.
Binary file modified
BIN
-338 Bytes
(100%)
...omponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file modified
BIN
-179 Bytes
(100%)
...mponents/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-colorblind-linux.png
Oops, something went wrong.
Binary file modified
BIN
-297 Bytes
(100%)
...nents/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-175 Bytes
(100%)
...napshots/components/Dialog.test.ts-snapshots/Dialog-Stress-Test-light-linux.png
Oops, something went wrong.
Binary file modified
BIN
-170 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,79 @@ | ||
import React from 'react' | ||
import type {Meta} from '@storybook/react' | ||
import {Button} from '.' | ||
import {DownloadIcon} from '@primer/octicons-react' | ||
import {Banner} from '../drafts' | ||
import {AriaStatus} from '../live-region' | ||
|
||
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 ( | ||
<> | ||
<AriaStatus>{!loading && success ? 'Export completed' : null}</AriaStatus> | ||
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('success')}> | ||
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 ( | ||
<> | ||
{!loading && error ? <Banner title="Export failed" variant="critical" /> : null} | ||
|
||
<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.