bbgo_origin/frontend/components/RunningTime.tsx

35 lines
922 B
TypeScript
Raw Normal View History

2022-06-16 08:47:35 +00:00
import { styled } from '@mui/styles';
2022-06-16 14:30:05 +00:00
import { Description } from './Detail';
2022-06-16 08:47:35 +00:00
const RunningTimeSection = styled('div')(() => ({
display: 'flex',
alignItems: 'center',
}));
const StatusSign = styled('span')(() => ({
width: '10px',
height: '10px',
display: 'block',
backgroundColor: 'rgb(113, 218, 113)',
borderRadius: '50%',
marginRight: '5px',
}));
2022-06-16 14:30:05 +00:00
export default function RunningTime({ seconds }: { seconds: number }) {
2022-06-16 08:47:35 +00:00
const day = Math.floor(seconds / (60 * 60 * 24));
const hour = Math.floor((seconds % (60 * 60 * 24)) / 3600);
const min = Math.floor(((seconds % (60 * 60 * 24)) % 3600) / 60);
2022-06-16 14:30:05 +00:00
2022-06-16 08:47:35 +00:00
return (
<RunningTimeSection>
2022-06-16 14:30:05 +00:00
<StatusSign />
<Description>
Running for
<span className="duration">{day}</span>D
<span className="duration">{hour}</span>H
<span className="duration">{min}</span>M
</Description>
</RunningTimeSection>
2022-06-16 08:47:35 +00:00
);
2022-06-16 14:30:05 +00:00
}