forked from Yadro/time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayStopButton.tsx
More file actions
53 lines (46 loc) · 1.21 KB
/
PlayStopButton.tsx
File metadata and controls
53 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React, { SyntheticEvent } from 'react';
import { CaretRightFilled, PauseOutlined } from '@ant-design/icons';
import { observer } from 'mobx-react';
import clsx from 'clsx';
import { createUseStyles } from 'react-jss';
import CircleButton from '../CircleButton/CircleButton';
import rootStore from '../../modules/RootStore';
import TaskModel from '../../modules/tasks/models/TaskModel';
const { tasksStore } = rootStore;
interface PlayStopButtonProps {
task: TaskModel | undefined;
className?: string;
}
export default observer(function PlayStopButton({
task,
className,
}: PlayStopButtonProps) {
const classes = useStyles();
function handleClick(e: SyntheticEvent) {
e.stopPropagation();
if (task) {
if (!task?.active) {
tasksStore.startTimer(task);
} else {
tasksStore.stopTimer();
}
}
}
return (
<CircleButton
onClick={handleClick}
className={clsx('play-stop-button', className)}
>
{!task?.active ? (
<CaretRightFilled className={classes.icon} />
) : (
<PauseOutlined className={classes.icon} />
)}
</CircleButton>
);
});
const useStyles = createUseStyles({
icon: {
color: 'white',
},
});