-
-
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 #38739
Closed
Closed
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3947c8c
logo refinement
danilo-leal 5e1ea40
https://github.com/mui/material-ui/issues/38682
xcode-it 2432c5f
following @danilo-leal suggestions
xcode-it 04d3626
Merge branch 'master' of https://github.com/mui/material-ui into coun…
xcode-it 7598189
undo-prettier-edits
xcode-it 82f4fdb
Merge branch 'master' of https://github.com/mui/material-ui into coun…
xcode-it dbda4d5
follow-@siriwatknp-review
xcode-it 026da55
fix-function-name
xcode-it 3afe116
Merge branch 'mui:master' into count-up-feature
xcode-it 3e2df8f
Reorder doc page
zanivan 0afea82
Visual and UX tweaks to the demo
zanivan 5082859
Run yarn docs:typescript:formatted
zanivan 9e23972
Merge remote-tracking branch 'origin/master' into pr/38739
danilo-leal c636580
format documentation
danilo-leal cee9195
demos simplifications
danilo-leal dfbb8de
Merge branch 'master' into circular-progress-count-up-feature
danilo-leal 4dbf9ab
Merge branch 'mui:master' into circular-progress-count-up-feature
xcode-it cabde8f
undo remote-tracking branch 'origin/master' into pr/38739
xcode-it 2a98c2b
Merge branch 'master' of github.com:mui/material-ui into HEAD
xcode-it 683699c
undo-logo-refinement
xcode-it 73cc492
Merge branch 'master' of github.com:mui/material-ui into circular-pro…
xcode-it d22c32b
Merge branch 'circular-progress-count-up-feature' of github.com:anon-…
xcode-it 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
66 changes: 66 additions & 0 deletions
66
docs/data/joy/components/circular-progress/CircularProgressCountUp.js
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,66 @@ | ||
import * as React from 'react'; | ||
import Stack from '@mui/joy/Stack'; | ||
import Button from '@mui/joy/Button'; | ||
import Typography from '@mui/joy/Typography'; | ||
import CircularProgress from '@mui/joy/CircularProgress'; | ||
import { useCountUp } from 'use-count-up'; | ||
|
||
export default function CircularProgressCountUp() { | ||
const [isLoading, setIsLoading] = React.useState(false); | ||
const [buttonLabel, setButtonLabel] = React.useState('Start'); // Track button label | ||
|
||
const { value: value1, reset: resetValue1 } = useCountUp({ | ||
isCounting: isLoading, | ||
duration: 1, | ||
start: 0, | ||
end: 25, | ||
onEnd: () => { | ||
setIsLoading(false); | ||
setButtonLabel('Reset'); // Change the button label when loading is complete | ||
}, | ||
}); | ||
|
||
const { value: value2, reset } = useCountUp({ | ||
isCounting: true, | ||
duration: 1, | ||
start: 0, | ||
end: 75, | ||
}); | ||
|
||
const handleButtonClick = () => { | ||
if (isLoading) { | ||
setIsLoading(false); | ||
setButtonLabel('Start'); | ||
resetValue1(); // Reset the value | ||
} else { | ||
setIsLoading(true); | ||
setButtonLabel('Reset'); | ||
} | ||
}; | ||
|
||
return ( | ||
<Stack direction="row" alignItems="center" flexWrap="wrap" spacing={8}> | ||
<Stack spacing={2}> | ||
<CircularProgress size="lg" determinate value={value1}> | ||
<Typography>{value1}%</Typography> | ||
</CircularProgress> | ||
<Button | ||
size="sm" | ||
variant="outlined" | ||
color="neutral" | ||
onClick={handleButtonClick} // Use a single click handler | ||
> | ||
{buttonLabel} | ||
</Button> | ||
</Stack> | ||
<Stack spacing={2}> | ||
<CircularProgress size="lg" determinate value={value2}> | ||
<Typography>{value2}%</Typography> | ||
</CircularProgress> | ||
<Button size="sm" variant="outlined" color="neutral" onClick={reset}> | ||
Reload | ||
</Button> | ||
</Stack> | ||
</Stack> | ||
); | ||
} |
66 changes: 66 additions & 0 deletions
66
docs/data/joy/components/circular-progress/CircularProgressCountUp.tsx
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,66 @@ | ||
import * as React from 'react'; | ||
import Stack from '@mui/joy/Stack'; | ||
import Button from '@mui/joy/Button'; | ||
import Typography from '@mui/joy/Typography'; | ||
import CircularProgress from '@mui/joy/CircularProgress'; | ||
import { useCountUp } from 'use-count-up'; | ||
|
||
export default function CircularProgressCountUp() { | ||
const [isLoading, setIsLoading] = React.useState(false); | ||
const [buttonLabel, setButtonLabel] = React.useState('Start'); // Track button label | ||
|
||
const { value: value1, reset: resetValue1 } = useCountUp({ | ||
isCounting: isLoading, | ||
duration: 1, | ||
start: 0, | ||
end: 25, | ||
onEnd: () => { | ||
setIsLoading(false); | ||
setButtonLabel('Reset'); // Change the button label when loading is complete | ||
}, | ||
}); | ||
|
||
const { value: value2, reset } = useCountUp({ | ||
isCounting: true, | ||
duration: 1, | ||
start: 0, | ||
end: 75, | ||
}); | ||
|
||
const handleButtonClick = () => { | ||
if (isLoading) { | ||
setIsLoading(false); | ||
setButtonLabel('Start'); | ||
resetValue1(); // Reset the value | ||
} else { | ||
setIsLoading(true); | ||
setButtonLabel('Reset'); | ||
} | ||
}; | ||
|
||
return ( | ||
<Stack direction="row" alignItems="center" flexWrap="wrap" spacing={8}> | ||
<Stack spacing={2}> | ||
<CircularProgress size="lg" determinate value={value1}> | ||
<Typography>{value1}%</Typography> | ||
</CircularProgress> | ||
<Button | ||
size="sm" | ||
variant="outlined" | ||
color="neutral" | ||
onClick={handleButtonClick} // Use a single click handler | ||
> | ||
{buttonLabel} | ||
</Button> | ||
</Stack> | ||
<Stack spacing={2}> | ||
<CircularProgress size="lg" determinate value={value2}> | ||
<Typography>{value2}%</Typography> | ||
</CircularProgress> | ||
<Button size="sm" variant="outlined" color="neutral" onClick={reset}> | ||
Reload | ||
</Button> | ||
</Stack> | ||
</Stack> | ||
); | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.
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.
This, and the file below, shouldn't be here. 🤔 Don't know how they got picked up.
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.
it's an old commit, from this PR
strange though...
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 we remove it?
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.
removed...
undo-logo-refinement