forked from Yadro/time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskControl.tsx
More file actions
68 lines (61 loc) · 1.61 KB
/
TaskControl.tsx
File metadata and controls
68 lines (61 loc) · 1.61 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useMemo } from 'react';
import { observer } from 'mobx-react';
import { createUseStyles } from 'react-jss';
import rootStore from '../modules/RootStore';
import * as TaskHooks from '../hooks/TaskHooks';
import PlayStopButton from './PlayStopButton';
import { PURPLE_COLOR } from '../consts';
const { tasksStore, projectStore } = rootStore;
function TaskControl() {
const styles = useStyles();
const task = tasksStore.activeTask;
const duration = TaskHooks.useTaskDuration(task);
const project = useMemo(() => {
return projectStore.get(task?.projectId || '');
}, [task]);
if (task) {
return (
<span className={styles.root}>
<div className={styles.info}>
<span className={styles.project}>{project?.title}</span>
<span>{task.title}</span>
</div>
<span className={styles.duration}>{duration}</span>
<PlayStopButton task={task} />
</span>
);
}
return <span className={styles.root}>No active tasks</span>;
}
export default observer(TaskControl);
const useStyles = createUseStyles({
root: {
display: 'inline-flex',
alignItems: 'center',
height: '44px',
marginLeft: '20px',
padding: '8px',
borderRadius: '5px',
lineHeight: '16px',
color: 'white',
backgroundColor: PURPLE_COLOR,
},
project: {
fontSize: '12px',
},
info: {
display: 'inline-flex',
flex: 1,
flexDirection: 'column',
marginRight: '8px',
width: '140px',
'& span': {
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
overflow: 'hidden',
},
},
duration: {
marginRight: '8px',
},
});