-
Notifications
You must be signed in to change notification settings - Fork 615
Add loading
prop for Button
and IconButton
#3582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 56 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
a1c03e2
draft loading state
langermank cfd0944
cleanup
langermank 9408220
add story to trigger loading
langermank 18d7954
Merge branch 'main' into button-loading-state
langermank 1cc0465
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti a9a7771
merge
langermank 5c901d4
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti fae28dd
Merge branch 'main' into button-loading-state
langermank 72a0247
icon button
langermank 71b747d
Create lazy-jobs-pump.md
langermank 556aff9
add prop for loading message
langermank 03ce69f
Merge branch 'button-loading-state' of https://github.com/primer/reac…
langermank f7b316d
Merge branch 'button-loading-state' of github.com:primer/react into b…
mperrotti 6f98511
handle no visuals loading state
langermank 5080989
Merge branch 'button-loading-state' of github.com:primer/react into b…
mperrotti f3e6d07
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti ee21a63
updates snapshots after merging from main
mperrotti 5956393
Merge branch 'main' into button-loading-state
mperrotti 9687486
uses unique ID for loading messages, preserves aria-describedby passe…
mperrotti 2fc7c4d
adds Storybook examples for btn loading error message
mperrotti 7f981b0
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti 49d8853
reverts unintentional default link underlining
mperrotti 3aa7225
changes loadingMessage to loadingAnnouncement
mperrotti 7f7f326
updates draft Button component with loading prop
mperrotti 73b59c7
updates legacy button counter behavior when loading
mperrotti fc15b72
Merge branch 'main' into button-loading-state
mperrotti c277957
Revert "updates draft Button component with loading prop"
mperrotti d556bc9
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti ccaa4ae
moves error behavior stories to 'Examples' section
mperrotti 30fb01d
screenreader fixes
mperrotti 22c7c65
adds and updates unit tests
mperrotti 787bfaa
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti 6dcf5b3
re-updates snapshots after using correct VisuallyHidden
mperrotti 09a3199
Merge branch 'main' into button-loading-state
mperrotti 0e276de
documents loading props
mperrotti e8fcd21
adds VRTs, updates loading feature stories
mperrotti 3eee19a
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti e63e61c
simplifies inner visual/spinner rendering logic
mperrotti 8a901da
removes example stories (we can put them back when Flash supports foc…
mperrotti 39f2d4e
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti 24abbcd
Merge branch 'main' into button-loading-state
mperrotti ffdff03
excludes loading buttons from axe contrast check
mperrotti 9d133a0
fixes visual regression: button counter vertical alignment
mperrotti e069e04
Merge branch 'main' into button-loading-state
mperrotti 611eea0
prevents double spinners when leading and trailing visuals are passed
mperrotti 7cf14ca
test(e2e): update story ids
joshblack 1a4a08d
test(vrt): update snapshots
joshblack a091125
test(e2e): disable animations in screenshots
joshblack e4a6f41
Merge branch 'button-loading-state' of github.com:primer/react into b…
joshblack c9a0743
test(vrt): update snapshots
joshblack 4d9128e
preserves rest state styles when button is loading
mperrotti 3c38084
adds story for success and error announcement
mperrotti 9408882
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti ceb5ba2
test(vrt): update snapshots
langermank c7501e2
Merge branch 'main' into button-loading-state
mperrotti ad02496
Merge branch 'main' into button-loading-state
mperrotti db094c5
fixes ButtonGroup regression
mperrotti fe2dcee
Merge branch 'main' into button-loading-state
mperrotti e300738
Merge branch 'main' into button-loading-state
mperrotti fb6d639
Merge branch 'main' into button-loading-state
mperrotti 0911586
delete broken snapshots
langermank 1416fcb
also targets anchor tags in ButtonGroup styles
mperrotti e245fe9
Merge branch 'main' into button-loading-state
mperrotti 5e8877e
add conditional wrapper
langermank f2ccc8e
Merge branch 'button-loading-state' of https://github.com/primer/reac…
langermank f301ffe
fix group
langermank e7a25ef
test(vrt): update snapshots
langermank 71de776
Merge branch 'main' into button-loading-state
langermank 2e5ed47
lint
mperrotti 6c425f9
Merge branch 'button-loading-state' of github.com:primer/react into b…
mperrotti 01e07a1
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti 20d81f4
fixes unit tests, updates snapshots
mperrotti b3cdce6
Update src/Button/Button.docs.json
mperrotti c38523c
Merge branch 'main' into button-loading-state
mperrotti 9ad96f2
fixes 'block' layout for loading buttons
mperrotti 7e5bc66
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti f781434
uses new internal Status component for loading announcement
mperrotti 6f9f6ed
updates Tooltip V2 tests to account for loading messageID in button's…
mperrotti 8809ba5
fixes BoxProps type import to new preferred syntax
mperrotti 9649e4e
appease the linter
mperrotti 87fa84b
rms ConditionalWrapper
mperrotti 5acdcb9
revert back to using ConditionalWrapper with aria-describedby
mperrotti c0e2a3d
Merge branch 'main' of github.com:primer/react into button-loading-state
mperrotti a7b114b
test(vrt): update snapshots
mperrotti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 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
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.96 KB
...t.ts-snapshots/Button-Loading-With-Leading-Visual-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
+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
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-Trailing-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
...ton.test.ts-snapshots/Button-Loading-With-Trailing-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
...t.ts-snapshots/Button-Loading-With-Trailing-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
...nts/Button.test.ts-snapshots/Button-Loading-With-Trailing-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-Trailing-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
...est.ts-snapshots/Button-Loading-With-Trailing-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.96 KB
....ts-snapshots/Button-Loading-With-Trailing-Visual-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
+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
-230 Bytes
(97%)
.../ButtonGroup.test.ts-snapshots/ButtonGroup-Default-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-231 Bytes
(97%)
...ButtonGroup.test.ts-snapshots/ButtonGroup-Default-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-195 Bytes
(96%)
...onGroup.test.ts-snapshots/ButtonGroup-Icon-Buttons-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-162 Bytes
(97%)
...nGroup.test.ts-snapshots/ButtonGroup-Icon-Buttons-light-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-230 Bytes
(97%)
...ttonGroup.test.ts-snapshots/ButtonGroup-Playground-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file modified
BIN
-231 Bytes
(97%)
...tonGroup.test.ts-snapshots/ButtonGroup-Playground-light-high-contrast-linux.png
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,56 @@ | ||
import React from 'react' | ||
import type {Meta} from '@storybook/react' | ||
import {Button} from '.' | ||
import {DownloadIcon} from '@primer/octicons-react' | ||
import Box from '../Box' | ||
import {VisuallyHidden} from '../internal/components/VisuallyHidden' | ||
|
||
const meta: Meta<typeof Button> = { | ||
title: 'Components/Button/Examples', | ||
} as Meta<typeof Button> | ||
|
||
export default meta | ||
|
||
export const LoadingStatusAnnouncements = () => { | ||
const [loading, setLoading] = React.useState(false) | ||
const [success, setSuccess] = 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) | ||
setSuccess(!actionResult) | ||
return | ||
} | ||
|
||
setSuccess(actionResult) | ||
setError(!actionResult) | ||
} | ||
|
||
return ( | ||
<> | ||
<VisuallyHidden aria-live="polite"> | ||
{!loading && success ? 'Export completed' : null} | ||
{!loading && error ? 'Export failed' : null} | ||
</VisuallyHidden> | ||
<Box sx={{display: 'flex', gap: 3}}> | ||
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('success')}> | ||
Export (success) | ||
</Button> | ||
<Button loading={loading} leadingVisual={DownloadIcon} onClick={onClick('error')}> | ||
Export (error) | ||
</Button> | ||
</Box> | ||
</> | ||
) | ||
} |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.