prettify, sorry for the big ass commit

This commit is contained in:
Olivier Gagnon
2021-09-04 19:09:30 -04:00
parent 3d7cdb4ef9
commit a18bdd6afc
554 changed files with 91615 additions and 66138 deletions
+26 -25
View File
@@ -1,7 +1,7 @@
import LinearProgress from '@material-ui/core/LinearProgress';
import React, { useState, useEffect } from 'react';
import LinearProgress from "@material-ui/core/LinearProgress";
import React, { useState, useEffect } from "react";
import { withStyles } from "@material-ui/core/styles";
import Grid from '@material-ui/core/Grid';
import Grid from "@material-ui/core/Grid";
const TimerProgress = withStyles(() => ({
bar: {
@@ -11,31 +11,32 @@ const TimerProgress = withStyles(() => ({
}))(LinearProgress);
interface IProps {
millis: number;
onExpire: () => void;
millis: number;
onExpire: () => void;
}
export function GameTimer(props: IProps): React.ReactElement {
const [v, setV] = useState(100);
const [v, setV] = useState(100);
const tick = 200;
useEffect(() => {
const intervalId = setInterval(() => {
setV(old => {
if(old <= 0) props.onExpire();
return old - tick / props.millis * 100;
});
}, tick);
return () => {
clearInterval(intervalId);
}
}, []);
const tick = 200;
useEffect(() => {
const intervalId = setInterval(() => {
setV((old) => {
if (old <= 0) props.onExpire();
return old - (tick / props.millis) * 100;
});
}, tick);
return () => {
clearInterval(intervalId);
};
}, []);
// https://stackoverflow.com/questions/55593367/disable-material-uis-linearprogress-animation
// TODO(hydroflame): there's like a bug where it triggers the end before the
// bar physically reaches the end
return (<Grid item xs={12}>
<TimerProgress variant="determinate" value={v} />
</Grid>);
// https://stackoverflow.com/questions/55593367/disable-material-uis-linearprogress-animation
// TODO(hydroflame): there's like a bug where it triggers the end before the
// bar physically reaches the end
return (
<Grid item xs={12}>
<TimerProgress variant="determinate" value={v} />
</Grid>
);
}