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

Commit 4f4a227

Browse files
author
Dmitry Yadrikhinsky
committed
Play/Stop button
1 parent faa5711 commit 4f4a227

File tree

5 files changed

+59
-37
lines changed

5 files changed

+59
-37
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.play-stop-button__icon {
2+
color: white;
3+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { CaretRightFilled, PauseOutlined } from '@ant-design/icons';
3+
4+
import './PlayStopButton.less';
5+
6+
import CircleButton from '../CircleButton/CircleButton';
7+
import rootStore from '../../services/RootStore';
8+
import TaskModel from '../../models/TaskModel';
9+
10+
const { tasksStore } = rootStore;
11+
12+
interface PlayStopButtonProps {
13+
task: TaskModel | undefined;
14+
}
15+
16+
export default function PlayStopButton({ task }: PlayStopButtonProps) {
17+
function handleClick() {
18+
if (task) {
19+
if (!task?.active) {
20+
tasksStore.startTimer(task);
21+
} else {
22+
tasksStore.endTimer(task);
23+
}
24+
}
25+
}
26+
27+
return (
28+
<CircleButton onClick={handleClick} className="play-stop-button">
29+
{!task?.active ? (
30+
<CaretRightFilled className="play-stop-button__icon" />
31+
) : (
32+
<PauseOutlined className="play-stop-button__icon" />
33+
)}
34+
</CircleButton>
35+
);
36+
}
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
.hours-card {
22
width: 300px;
3-
}
4-
5-
.hours-card .ant-card-body {
6-
display: flex;
7-
flex-direction: row;
8-
}
93

10-
.hours-card__info {
11-
flex: 1;
12-
}
4+
.ant-card-body {
5+
display: flex;
6+
flex-direction: row;
7+
}
138

14-
.hours-card__button {
15-
display: none;
16-
}
9+
.hours-card__info {
10+
flex: 1;
11+
}
1712

18-
.hours-card:hover .hours-card__button {
19-
display: inline-flex;
20-
}
13+
.play-stop-button {
14+
display: none;
15+
}
2116

22-
.anticon.hours-card__icon {
23-
color: white;
17+
&:hover .play-stop-button {
18+
display: inline-flex;
19+
}
2420
}

src/screens/hours/components/HoursCard/HoursCard.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import { observer } from 'mobx-react';
66
import './HoursCard.less';
77

88
import TaskTimeModel from '../../../../models/TaskTimeModel';
9-
import CircleButton from '../../../../components/CircleButton/CircleButton';
10-
import { CaretRightFilled, PauseOutlined } from '@ant-design/icons';
11-
import rootStore from '../../../../services/RootStore';
9+
import PlayStopButton from '../../../../components/PlayStopButton/PlayStopButton';
1210

1311
const formatStr = 'HH:mm';
1412
function timeFormat(date: Date | undefined) {
@@ -18,36 +16,20 @@ function timeFormat(date: Date | undefined) {
1816
return '';
1917
}
2018

21-
const { tasksStore } = rootStore;
22-
2319
interface HoursCardProps {
2420
taskTime: TaskTimeModel;
2521
}
2622

2723
export default observer(function HoursCard({ taskTime }: HoursCardProps) {
2824
const { task, time } = taskTime;
2925

30-
function handleClick() {
31-
if (!task.active) {
32-
tasksStore.startTimer(task);
33-
} else {
34-
tasksStore.endTimer(task);
35-
}
36-
}
37-
3826
return (
3927
<Card className="hours-card">
4028
<div className="hours-card__info">
4129
<div>{task.title}</div>
4230
<div>{`${timeFormat(time[0])} - ${timeFormat(time[1])}`}</div>
4331
</div>
44-
<CircleButton onClick={handleClick} className="hours-card__button">
45-
{!task.active ? (
46-
<CaretRightFilled className="hours-card__icon" />
47-
) : (
48-
<PauseOutlined className="hours-card__icon" />
49-
)}
50-
</CircleButton>
32+
<PlayStopButton task={task} />
5133
</Card>
5234
);
5335
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import rootStore from '../../../../services/RootStore';
1010
import { useTaskDuration } from '../../../../hooks/TaskHooks';
1111
import HoursByTask from '../HoursByTask/HoursByTask';
1212
import IconTile from '../../../../components/IconTile/IconTile';
13+
import CircleButton from '../../../../components/CircleButton/CircleButton';
14+
import PlayStopButton from '../../../../components/PlayStopButton/PlayStopButton';
1315

1416
const { projectStore } = rootStore;
1517

@@ -56,6 +58,7 @@ export default observer(function DrawerTask({
5658
</div>
5759
<Input
5860
value={task?.title}
61+
placeholder="Task description"
5962
onChange={(e) => {
6063
const title = e.target.value;
6164
if (task) {
@@ -78,6 +81,8 @@ export default observer(function DrawerTask({
7881
<ClockCircleOutlined style={{ color: 'white ' }} />
7982
</IconTile>
8083
<span className="value">{duration}</span>
84+
<span className="flex-1" />
85+
<PlayStopButton task={task} />
8186
</div>
8287

8388
<HoursByTask task={task} />

0 commit comments

Comments
 (0)