-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[circularprogress][linearprogress] Improve accessibility #48172
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
Open
silviuaavram
wants to merge
31
commits into
mui:master
Choose a base branch
from
silviuaavram:feat/progress-accessibility
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
04cb761
[circularprogress][linearprogress] Improve accessibility
silviuaavram ad2fc09
add linear query
silviuaavram c5e47c2
also add visible label to linear
silviuaavram 00a4465
update proptypes
silviuaavram 7a8564d
linear with aria-valuetext
silviuaavram a0fcd30
docs add example
silviuaavram f35eec5
prettier
silviuaavram 1f9f030
circular progress add props
silviuaavram d6868d9
add circular with different scale
silviuaavram 0ddb2bb
pnpm docs:typescript:formatted
silviuaavram 2588f49
no need for proptypes in ts demo
silviuaavram 6c0f534
align examples
silviuaavram 7e254ea
update docs
silviuaavram a069ed7
improve description
silviuaavram 077eed7
correct grammar
silviuaavram 797350f
docs typecript formatted
silviuaavram e90e758
code review integration
silviuaavram 4b3da8e
docs changes
silviuaavram bf5a670
remove default
silviuaavram bfd8f22
fix prop names
silviuaavram e7653f2
improve circularprogress test
silviuaavram 51d7654
guard against division by 0
silviuaavram 409a3ea
warn when providing min/max with incorrect variant
silviuaavram fac9022
improve demos
silviuaavram 3dff108
update values in docs
silviuaavram 1411193
provide better examples in docs
silviuaavram 0fa34ce
prettier
silviuaavram a042d9a
docs:typescript:formatted
silviuaavram d99727b
accept both values in test
silviuaavram 489d488
only warn when min or max are provided with wrong variant
silviuaavram ac8c332
regex for dashoffset too
silviuaavram 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
26 changes: 26 additions & 0 deletions
26
docs/data/material/components/progress/CircularCustomScale.js
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,26 @@ | ||
| import * as React from 'react'; | ||
| import CircularProgress from '@mui/material/CircularProgress'; | ||
|
|
||
| export default function CircularCustomScale() { | ||
| const [progress, setProgress] = React.useState(10); | ||
|
|
||
| React.useEffect(() => { | ||
| const timer = setInterval(() => { | ||
| setProgress((prevProgress) => (prevProgress >= 20 ? 10 : prevProgress + 2)); | ||
| }, 800); | ||
|
|
||
| return () => { | ||
| clearInterval(timer); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <CircularProgress | ||
| variant="determinate" | ||
| min={10} | ||
| max={20} | ||
| value={progress} | ||
| aria-label="Loading" | ||
| /> | ||
| ); | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
docs/data/material/components/progress/CircularCustomScale.tsx
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,26 @@ | ||
| import * as React from 'react'; | ||
| import CircularProgress from '@mui/material/CircularProgress'; | ||
|
|
||
| export default function CircularCustomScale() { | ||
| const [progress, setProgress] = React.useState(10); | ||
|
|
||
| React.useEffect(() => { | ||
| const timer = setInterval(() => { | ||
| setProgress((prevProgress) => (prevProgress >= 20 ? 10 : prevProgress + 2)); | ||
| }, 800); | ||
|
|
||
| return () => { | ||
| clearInterval(timer); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <CircularProgress | ||
| variant="determinate" | ||
| min={10} | ||
| max={20} | ||
| value={progress} | ||
| aria-label="Loading" | ||
| /> | ||
| ); | ||
| } |
7 changes: 7 additions & 0 deletions
7
docs/data/material/components/progress/CircularCustomScale.tsx.preview
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,7 @@ | ||
| <CircularProgress | ||
| variant="determinate" | ||
| min={10} | ||
| max={20} | ||
| value={progress} | ||
| aria-label="Loading" | ||
| /> |
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,10 @@ | ||
| import Box from '@mui/material/Box'; | ||
| import LinearProgress from '@mui/material/LinearProgress'; | ||
|
|
||
| export default function LinearQuery() { | ||
| return ( | ||
| <Box sx={{ width: '100%' }}> | ||
| <LinearProgress aria-label="Loading…" variant="query" /> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import Box from '@mui/material/Box'; | ||
| import LinearProgress from '@mui/material/LinearProgress'; | ||
|
|
||
| export default function LinearQuery() { | ||
| return ( | ||
| <Box sx={{ width: '100%' }}> | ||
| <LinearProgress aria-label="Loading…" variant="query" /> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <LinearProgress aria-label="Loading…" variant="query" /> |
77 changes: 77 additions & 0 deletions
77
docs/data/material/components/progress/LinearWithAriaValueText.js
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,77 @@ | ||
| import * as React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import LinearProgress from '@mui/material/LinearProgress'; | ||
| import Typography from '@mui/material/Typography'; | ||
| import Box from '@mui/material/Box'; | ||
|
|
||
| function LinearProgressWithLabelAndValue({ max, min, value, ...rest }) { | ||
siriwatknp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const progressText = `Elevator at floor ${value} out of ${max}.`; | ||
| const progressId = React.useId(); | ||
| return ( | ||
| <div> | ||
| <Typography | ||
| id={progressId} | ||
| variant="body2" | ||
| color="text.secondary" | ||
| sx={{ mr: 1 }} | ||
| > | ||
| Elevator status | ||
| </Typography> | ||
| <Box sx={{ display: 'flex', alignItems: 'center' }}> | ||
| <Box sx={{ width: '100%', mr: 1 }}> | ||
| <LinearProgress | ||
| variant="determinate" | ||
| aria-labelledby={progressId} | ||
| aria-valuetext={progressText} | ||
| min={min} | ||
| max={max} | ||
| value={value} | ||
| {...rest} | ||
| /> | ||
| </Box> | ||
| <Box sx={{ whiteSpace: 'nowrap' }}> | ||
| <Typography variant="body2" sx={{ color: 'text.secondary' }}> | ||
| {progressText} | ||
| </Typography> | ||
| </Box> | ||
| </Box> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| LinearProgressWithLabelAndValue.propTypes = { | ||
| /** | ||
| * The maximum value for the progress indicator for the determinate and buffer variants. | ||
| * @default 100 | ||
| */ | ||
| max: PropTypes.number.isRequired, | ||
| /** | ||
| * The minimum value for the progress indicator for the determinate and buffer variants. | ||
| * @default 0 | ||
| */ | ||
| min: PropTypes.number.isRequired, | ||
| /** | ||
| * The value of the progress indicator for the determinate and buffer variants. | ||
| * Value between `min` and `max`. | ||
| */ | ||
| value: PropTypes.number.isRequired, | ||
| }; | ||
|
|
||
| export default function LinearWithAriaValueText() { | ||
| const [progress, setProgress] = React.useState(1); | ||
|
|
||
| React.useEffect(() => { | ||
| const timer = setInterval(() => { | ||
| setProgress((prevProgress) => (prevProgress >= 10 ? 1 : prevProgress + 1)); | ||
| }, 800); | ||
| return () => { | ||
| clearInterval(timer); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Box sx={{ width: '100%' }}> | ||
| <LinearProgressWithLabelAndValue value={progress} min={1} max={10} /> | ||
| </Box> | ||
| ); | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
docs/data/material/components/progress/LinearWithAriaValueText.tsx
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,69 @@ | ||
| import * as React from 'react'; | ||
| import LinearProgress, { LinearProgressProps } from '@mui/material/LinearProgress'; | ||
| import Typography from '@mui/material/Typography'; | ||
| import Box from '@mui/material/Box'; | ||
|
|
||
| type LinearProgressWithLabelAndValueProps = LinearProgressProps & { | ||
| min: number; | ||
| max: number; | ||
| value: number; | ||
| }; | ||
|
|
||
| function LinearProgressWithLabelAndValue({ | ||
| max, | ||
| min, | ||
| value, | ||
| ...rest | ||
| }: LinearProgressWithLabelAndValueProps) { | ||
| const progressText = `Elevator at floor ${value} out of ${max}.`; | ||
| const progressId = React.useId(); | ||
| return ( | ||
| <div> | ||
| <Typography | ||
| id={progressId} | ||
| variant="body2" | ||
| color="text.secondary" | ||
| sx={{ mr: 1 }} | ||
| > | ||
| Elevator status | ||
| </Typography> | ||
| <Box sx={{ display: 'flex', alignItems: 'center' }}> | ||
| <Box sx={{ width: '100%', mr: 1 }}> | ||
| <LinearProgress | ||
| variant="determinate" | ||
| aria-labelledby={progressId} | ||
| aria-valuetext={progressText} | ||
| min={min} | ||
| max={max} | ||
| value={value} | ||
| {...rest} | ||
| /> | ||
| </Box> | ||
| <Box sx={{ whiteSpace: 'nowrap' }}> | ||
| <Typography variant="body2" sx={{ color: 'text.secondary' }}> | ||
| {progressText} | ||
| </Typography> | ||
| </Box> | ||
| </Box> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default function LinearWithAriaValueText() { | ||
| const [progress, setProgress] = React.useState(1); | ||
|
|
||
| React.useEffect(() => { | ||
| const timer = setInterval(() => { | ||
| setProgress((prevProgress) => (prevProgress >= 10 ? 1 : prevProgress + 1)); | ||
| }, 800); | ||
| return () => { | ||
| clearInterval(timer); | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Box sx={{ width: '100%' }}> | ||
| <LinearProgressWithLabelAndValue value={progress} min={1} max={10} /> | ||
| </Box> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
docs/data/material/components/progress/LinearWithAriaValueText.tsx.preview
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 @@ | ||
| <LinearProgressWithLabelAndValue value={progress} min={1} max={10} /> |
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
2 changes: 1 addition & 1 deletion
2
docs/data/material/components/progress/LinearWithValueLabel.tsx.preview
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| <LinearProgressWithLabel value={progress} /> | ||
| <LinearProgressWithLabelAndValue value={progress} /> |
Oops, something went wrong.
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.