Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 4af999d

Browse files
committed
Dont hide paused task, remove less
1 parent 01820b9 commit 4af999d

File tree

11 files changed

+91
-90
lines changed

11 files changed

+91
-90
lines changed

src/App.global.less

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@font-face {
2-
font-family: "Material Icons";
3-
src: url("~material-icons/iconfont/material-icons.woff2") format("woff2"),
4-
url("~material-icons/iconfont/material-icons.woff2") format("woff");
2+
font-family: 'Material Icons';
3+
src: url('~material-icons/iconfont/material-icons.woff2') format('woff2'),
4+
url('~material-icons/iconfont/material-icons.woff2') format('woff');
55
}
66

77
@import '~material-icons/css/material-icons.min.css';
@@ -16,9 +16,3 @@
1616
display: flex;
1717
align-items: center;
1818
}
19-
20-
.flex-1 {
21-
flex: 1
22-
}
23-
24-
@purple: #713A91;

src/components/Header/Header.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
33
import { Layout } from 'antd';
44
import { observer } from 'mobx-react';
55
import useMediaQuery from 'react-hook-media-query';
6+
import { createUseStyles } from 'react-jss';
67

78
import HeaderLink from '../HeaderLink/HeaderLink';
89
import Profile from '../Profile/Profile';
@@ -13,6 +14,7 @@ const { Header: HeaderBase } = Layout;
1314

1415
const query = '(min-width: 950px)';
1516
function Header() {
17+
const style = useStyle();
1618
const isBigScreen = useMediaQuery(query);
1719

1820
return (
@@ -26,11 +28,17 @@ function Header() {
2628
<HeaderLink>
2729
<Link to="/dashboard">Dashboard</Link>
2830
</HeaderLink>
29-
<span className="flex-1">{isBigScreen && <ProgressBar />}</span>
31+
<span className={style.flex1}>{isBigScreen && <ProgressBar />}</span>
3032
<TaskControl />
3133
<Profile />
3234
</HeaderBase>
3335
);
3436
}
3537

3638
export default observer(Header);
39+
40+
const useStyle = createUseStyles({
41+
flex1: {
42+
flex: 1,
43+
},
44+
});

src/components/PlayStopButton/PlayStopButton.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React, { SyntheticEvent } from 'react';
1+
import React, { SyntheticEvent, useCallback } from 'react';
22
import { CaretRightFilled, PauseOutlined } from '@ant-design/icons';
33
import { observer } from 'mobx-react';
4-
import clsx from 'clsx';
54
import { createUseStyles } from 'react-jss';
65

76
import CircleButton from '../CircleButton/CircleButton';
@@ -15,36 +14,35 @@ interface PlayStopButtonProps {
1514
className?: string;
1615
}
1716

18-
export default observer(function PlayStopButton({
19-
task,
20-
className,
21-
}: PlayStopButtonProps) {
17+
function PlayStopButton({ task, className }: PlayStopButtonProps) {
2218
const classes = useStyles();
2319

24-
function handleClick(e: SyntheticEvent) {
25-
e.stopPropagation();
26-
if (task) {
27-
if (!task?.active) {
28-
tasksStore.startTimer(task);
29-
} else {
30-
tasksStore.stopTimer();
20+
const toggleTask = useCallback(
21+
(e: SyntheticEvent) => {
22+
e.stopPropagation();
23+
if (task) {
24+
if (!task?.active) {
25+
tasksStore.startTimer(task);
26+
} else {
27+
tasksStore.stopTimer();
28+
}
3129
}
32-
}
33-
}
30+
},
31+
[task]
32+
);
3433

3534
return (
36-
<CircleButton
37-
onClick={handleClick}
38-
className={clsx('play-stop-button', className)}
39-
>
35+
<CircleButton onClick={toggleTask} className={className}>
4036
{!task?.active ? (
4137
<CaretRightFilled className={classes.icon} />
4238
) : (
4339
<PauseOutlined className={classes.icon} />
4440
)}
4541
</CircleButton>
4642
);
47-
});
43+
}
44+
45+
export default observer(PlayStopButton);
4846

4947
const useStyles = createUseStyles({
5048
icon: {

src/components/TaskControl/TaskControl.less

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, { useMemo } from 'react';
22
import { observer } from 'mobx-react';
3-
import { PauseOutlined } from '@ant-design/icons';
4-
5-
import './TaskControl.less';
3+
import { createUseStyles } from 'react-jss';
64

75
import rootStore from '../../modules/RootStore';
86
import * as TaskHooks from '../../hooks/TaskHooks';
9-
import CircleButton from '../CircleButton/CircleButton';
7+
import PlayStopButton from '../PlayStopButton/PlayStopButton';
8+
import { PURPLE_COLOR } from '../../consts';
109

1110
const { tasksStore, projectStore } = rootStore;
1211

13-
export default observer(function TaskControl() {
12+
function TaskControl() {
13+
const styles = useStyles();
1414
const task = tasksStore.activeTask;
1515
const duration = TaskHooks.useTaskDuration(task);
1616

@@ -20,17 +20,49 @@ export default observer(function TaskControl() {
2020

2121
if (task) {
2222
return (
23-
<span className="task-control">
24-
<div className="task-control__info">
25-
<span className="task-control__project">{project?.title}</span>
23+
<span className={styles.root}>
24+
<div className={styles.info}>
25+
<span className={styles.project}>{project?.title}</span>
2626
<span>{task.title}</span>
2727
</div>
28-
<span className="task-control__duration">{duration}</span>
29-
<CircleButton onClick={() => tasksStore.stopTimer()}>
30-
<PauseOutlined />
31-
</CircleButton>
28+
<span className={styles.duration}>{duration}</span>
29+
<PlayStopButton task={task} />
3230
</span>
3331
);
3432
}
35-
return <span className="task-control">No active tasks</span>;
33+
return <span className={styles.root}>No active tasks</span>;
34+
}
35+
36+
export default observer(TaskControl);
37+
38+
const useStyles = createUseStyles({
39+
root: {
40+
display: 'inline-flex',
41+
alignItems: 'center',
42+
height: '44px',
43+
marginLeft: '20px',
44+
padding: '8px',
45+
borderRadius: '5px',
46+
lineHeight: '16px',
47+
color: 'white',
48+
backgroundColor: PURPLE_COLOR,
49+
},
50+
project: {
51+
fontSize: '12px',
52+
},
53+
info: {
54+
display: 'inline-flex',
55+
flex: 1,
56+
flexDirection: 'column',
57+
marginRight: '8px',
58+
width: '140px',
59+
'& span': {
60+
whiteSpace: 'nowrap',
61+
textOverflow: 'ellipsis',
62+
overflow: 'hidden',
63+
},
64+
},
65+
duration: {
66+
marginRight: '8px',
67+
},
3668
});

src/components/TimeRangeModal/TimeRangeModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const TimeRangeModal = observer(
7474

7575
function handleDelete() {
7676
if (taskTime) {
77-
tasksStore.deleteTime(taskTime.task, taskTime.index);
77+
tasksStore.removeTime(taskTime.task, taskTime.index);
7878
}
7979
onClose();
8080
}

src/consts/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const PURPLE_COLOR = '#713A91';

src/helpers/TaskHelper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ export function getTimeItems(
3535
});
3636
taskTime.sort((a, b) => compareAsc(a.time.start, b.time.start));
3737

38-
console.log('getTimeItems', taskTime.length);
39-
4038
return taskTime;
4139
}
4240

src/modules/tasks/TaskStore.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class TaskStore {
4646
GaService.event(EEventCategory.TimeRange, ETimeRangeEvents.Update);
4747
}
4848

49-
deleteTime(task: TaskModel, timeIndex: number) {
49+
removeTime(task: TaskModel, timeIndex: number) {
5050
if (task.active) {
5151
this.stopTimer();
5252
}
@@ -85,7 +85,6 @@ export default class TaskStore {
8585
for (const tasks of Object.values(this.tasks)) {
8686
TreeModelHelper.getFlatItemsRecursiveBase(tasks, condition, result);
8787
}
88-
console.log('getTasksByDate', result.length);
8988
return result;
9089
}
9190

@@ -154,7 +153,7 @@ export default class TaskStore {
154153
stopTimer(silent?: boolean) {
155154
if (this.activeTask) {
156155
this.activeTask.stop();
157-
this.activeTask = undefined;
156+
// this.activeTask = undefined;
158157
}
159158

160159
if (!silent) {

src/screens/projects/components/DrawerTask/DrawerTask.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import TimeRangeModal from '../../../../components/TimeRangeModal/TimeRangeModal
1313
import { Undefined } from '../../../../types/CommonTypes';
1414
import TaskTimeItemModel from '../../../../modules/tasks/models/TaskTimeItemModel';
1515
import IModalProps from '../../../../types/IModalProps';
16+
import { PURPLE_COLOR } from '../../../../consts';
1617

1718
const { TextArea } = Input;
1819

@@ -56,7 +57,7 @@ export default observer(function DrawerTask({
5657
Mark as done
5758
</Checkbox>
5859
<div className={classes.iconWithValue}>
59-
<IconTile backgroundColor="#713A91">
60+
<IconTile backgroundColor={PURPLE_COLOR}>
6061
<ProjectOutlined style={{ color: 'white ' }} />
6162
</IconTile>
6263
<span className={classes.projectTitle}>{project?.title}</span>

0 commit comments

Comments
 (0)