* Fix useSmoothAnimation enablement not working properly by getting rid of it
Passing duration=0 is more logical and less superfluous
* Refactor UploadBar to handle state more correctly
* Change ProgressBar to new useSmoothAnimation signature and default animated to true for consistency
* Add type guard
* Make types stricter
* Write tests for the ProgressBar component
* Make the new test conform to tsc --strict
* Update UploadBar.tsx
* Update UploadBar.tsx
* Update UploadBar.tsx
(cherry picked from commit 9b99c967f4
)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
0a0a46c131
commit
877fa9c5c4
5 changed files with 105 additions and 37 deletions
|
@ -25,10 +25,10 @@ interface IProps {
|
|||
}
|
||||
|
||||
const PROGRESS_BAR_ANIMATION_DURATION = 300;
|
||||
const ProgressBar: React.FC<IProps> = ({ value, max, animated }) => {
|
||||
const ProgressBar: React.FC<IProps> = ({ value, max, animated = true }) => {
|
||||
// Animating progress bars via CSS transition isn’t possible in all of our supported browsers yet.
|
||||
// As workaround, we’re using animations through JS requestAnimationFrame
|
||||
const currentValue = useSmoothAnimation(0, value, PROGRESS_BAR_ANIMATION_DURATION, animated);
|
||||
const currentValue = useSmoothAnimation(0, value, animated ? PROGRESS_BAR_ANIMATION_DURATION : 0);
|
||||
return <progress className="mx_ProgressBar" max={max} value={currentValue} />;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue