-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs][joy-ui] Integrate a count-up feature to the Circular Progress #38724
Changes from 4 commits
5e1ea40
2432c5f
04d3626
7598189
82f4fdb
dbda4d5
026da55
3afe116
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Box from '@mui/joy/Box'; | ||
import Button from '@mui/joy/Button'; | ||
import CircularProgress from '@mui/joy/CircularProgress'; | ||
import Stack from '@mui/joy/Stack'; | ||
import Typography from '@mui/joy/Typography'; | ||
import * as React from 'react'; | ||
import { useCountUp } from 'use-count-up'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add |
||
|
||
export default function CircularProgressDeterminate() { | ||
const [isLoading, setIsLoading] = React.useState(false); | ||
|
||
const { value: value1 } = useCountUp({ | ||
isCounting: isLoading, | ||
duration: 1, | ||
start: 0, | ||
end: 25, | ||
}); | ||
|
||
const { value: value2, reset } = useCountUp({ | ||
isCounting: true, | ||
duration: 1, | ||
start: 0, | ||
end: 75, | ||
}); | ||
|
||
return ( | ||
<Box sx={{ display: 'flex', gap: 2, alignItems: 'center', flexWrap: 'wrap' }}> | ||
<Stack sx={{ gap: 2 }}> | ||
<CircularProgress size="lg" determinate value={value1}> | ||
<Typography>{value1}%</Typography> | ||
</CircularProgress> | ||
<Button size="sm" onClick={() => setIsLoading(true)}> | ||
Start | ||
</Button> | ||
</Stack> | ||
<Stack sx={{ gap: 2 }}> | ||
<CircularProgress size="lg" determinate value={value2}> | ||
<Typography>{value2}%</Typography> | ||
</CircularProgress> | ||
<Button size="sm" onClick={reset}> | ||
Reset | ||
</Button> | ||
</Stack> | ||
</Box> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Box from '@mui/joy/Box'; | ||
import Button from '@mui/joy/Button'; | ||
import CircularProgress from '@mui/joy/CircularProgress'; | ||
import Stack from '@mui/joy/Stack'; | ||
import Typography from '@mui/joy/Typography'; | ||
import * as React from 'react'; | ||
import { useCountUp } from 'use-count-up'; | ||
|
||
export default function CircularProgressDeterminate() { | ||
const [isLoading, setIsLoading] = React.useState(false); | ||
|
||
const { value: value1 } = useCountUp({ | ||
isCounting: isLoading, | ||
duration: 1, | ||
start: 0, | ||
end: 25, | ||
}); | ||
|
||
const { value: value2, reset } = useCountUp({ | ||
isCounting: true, | ||
duration: 1, | ||
start: 0, | ||
end: 75, | ||
}); | ||
|
||
return ( | ||
<Box sx={{ display: 'flex', gap: 2, alignItems: 'center', flexWrap: 'wrap' }}> | ||
<Stack sx={{ gap: 2 }}> | ||
<CircularProgress size="lg" determinate value={value1}> | ||
<Typography>{value1}%</Typography> | ||
</CircularProgress> | ||
<Button size="sm" onClick={() => setIsLoading(true)}> | ||
Start | ||
</Button> | ||
</Stack> | ||
<Stack sx={{ gap: 2 }}> | ||
<CircularProgress size="lg" determinate value={value2}> | ||
<Typography>{value2}%</Typography> | ||
</CircularProgress> | ||
<Button size="sm" onClick={reset}> | ||
Reset | ||
</Button> | ||
</Stack> | ||
</Box> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<CircularProgress size="lg" determinate value={value1}> | ||
<Typography>{value1}%</Typography> | ||
</CircularProgress> | ||
<CircularProgress size="lg" determinate value={value2}> | ||
<Typography>{value2}%</Typography> | ||
</CircularProgress> |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -93,6 +93,14 @@ You can use these to customize the component with both the `sx` prop and the the | |||||||||||||
|
||||||||||||||
{{"demo": "CircularProgressVariables.js", "hideToolbar": true, "bg": "gradient"}} | ||||||||||||||
|
||||||||||||||
## Common examples | ||||||||||||||
|
||||||||||||||
### Count up feature | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
@danilo-leal What do you think about grouping 3rd-party libraries in We have a similar thing on input but it is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd still leave it in the Common examples, as it would be more consistent with the Input. Maybe the "Third-party integration" title works but it isn't immediately clear when compared to "Third-party formatting" (Input's case). 🤔 |
||||||||||||||
|
||||||||||||||
Using the [use-count-up](https://www.npmjs.com/package/use-count-up) package, you can create a counting animation by providing `start`, `end`, and `duration` values. | ||||||||||||||
|
||||||||||||||
{{"demo": "CircularProgressCountUp.js"}} | ||||||||||||||
|
||||||||||||||
## Accessibility | ||||||||||||||
|
||||||||||||||
Out of the box, the `aria-valuenow` attribute will indicate the current value of the progress bar only when the value is not indeterminate. | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move React import to the top for codebase consistency?