Skip to content

Commit 241dde6

Browse files
committed
feat(web): add ArrowButton component for task navigation
- Introduced ArrowButton component to encapsulate left and right navigation buttons with icons. - Updated Task and TaskListHeader components to utilize ArrowButton for migrating tasks and navigating days. - Removed direct icon usage in favor of the new ArrowButton for cleaner code and improved reusability.
1 parent 60a5906 commit 241dde6

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ChevronLeftIcon } from "@web/views/Day/components/Icons/ChevronLeftIcon";
2+
import { ChevronRightIcon } from "@web/views/Day/components/Icons/ChevronRightIcon";
3+
4+
export const ArrowButton = ({
5+
direction,
6+
label,
7+
onClick,
8+
}: {
9+
direction: "left" | "right";
10+
label: string;
11+
onClick: () => void;
12+
}) => {
13+
const hoverColor = "bg-white/20";
14+
15+
return (
16+
<button
17+
className={`flex h-6 w-6 items-center justify-center rounded-full text-white transition-colors hover:${hoverColor} focus:${hoverColor} focus:ring-2 focus:ring-white/50 focus:outline-none`}
18+
aria-label={label}
19+
onClick={onClick}
20+
>
21+
{direction === "left" ? <ChevronLeftIcon /> : <ChevronRightIcon />}
22+
</button>
23+
);
24+
};

packages/web/src/views/Day/components/Icons/ChevronLeftIcon.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
31
export const ChevronLeftIcon = () => {
42
return (
53
<svg

packages/web/src/views/Day/components/Icons/ChevronRightIcon.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
31
export const ChevronRightIcon = () => {
42
return (
53
<svg

packages/web/src/views/Day/components/Task/Task.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from "react";
22
import { DATA_TASK_ELEMENT_ID } from "@web/common/constants/web.constants";
3+
import { ArrowButton } from "@web/components/Button/ArrowButton";
34
import { Task as TaskType } from "../../task.types";
4-
import { ChevronLeftIcon } from "../Icons/ChevronLeftIcon";
5-
import { ChevronRightIcon } from "../Icons/ChevronRightIcon";
65
import { TaskCircleIcon } from "../Icons/TaskCircleIcon";
76

87
export interface TaskProps {
@@ -86,23 +85,17 @@ export const Task = ({
8685
onChange={(e) => onTitleChange(e.target.value)}
8786
/>
8887
</div>
89-
{/* Migration buttons */}
9088
<div className="ml-auto flex gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100">
91-
<button
92-
aria-label="Move task to previous day"
93-
className="flex h-6 w-6 items-center justify-center rounded-full text-white transition-colors hover:bg-white/10 hover:text-white focus:bg-white/10 focus:text-white focus:ring-2 focus:ring-white/50 focus:outline-none"
89+
<ArrowButton
90+
direction="left"
91+
label="Move task to previous day"
9492
onClick={() => onMigrate(task.id, "backward")}
95-
>
96-
<ChevronLeftIcon />
97-
</button>
98-
99-
<button
100-
aria-label="Move task to next day"
101-
className="flex h-6 w-6 items-center justify-center rounded-full text-white transition-colors hover:bg-white/10 hover:text-white focus:bg-white/10 focus:text-white focus:ring-2 focus:ring-white/50 focus:outline-none"
93+
/>
94+
<ArrowButton
95+
direction="right"
96+
label="Move task to next day"
10297
onClick={() => onMigrate(task.id, "forward")}
103-
>
104-
<ChevronRightIcon />
105-
</button>
98+
/>
10699
</div>
107100
</div>
108101
);

packages/web/src/views/Day/components/TaskList/TaskListHeader.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import dayjs from "@core/util/date/dayjs";
2+
import { ArrowButton } from "@web/components/Button/ArrowButton";
23
import { TooltipWrapper } from "@web/components/Tooltip/TooltipWrapper";
34
import { useDateInView } from "../../hooks/navigation/useDateInView";
45
import { useDateNavigation } from "../../hooks/navigation/useDateNavigation";
5-
import { ChevronLeftIcon } from "../Icons/ChevronLeftIcon";
6-
import { ChevronRightIcon } from "../Icons/ChevronRightIcon";
76
import { CircleIcon } from "../Icons/CircleIcon";
87

98
export const DAY_HEADING_FORMAT = "dddd";
@@ -14,8 +13,6 @@ export const TaskListHeader = () => {
1413
useDateNavigation();
1514

1615
const dateInView = useDateInView();
17-
// Display the date components directly from UTC to avoid timezone conversion issues
18-
// The UTC date represents the calendar date, so we can format it directly
1916
const header = dateInView.locale("en").format(DAY_HEADING_FORMAT);
2017
const subheader = dateInView.locale("en").format(DAY_SUBHEADING_FORMAT);
2118
const isToday =
@@ -51,20 +48,18 @@ export const TaskListHeader = () => {
5148
</TooltipWrapper>
5249
</div>
5350
<TooltipWrapper onClick={navigateToPreviousDay} shortcut="J">
54-
<button
55-
className="flex h-6 w-6 items-center justify-center rounded-full text-white transition-colors hover:bg-white/20 focus:bg-white/20 focus:ring-2 focus:ring-white/50 focus:outline-none"
56-
aria-label="Previous day"
57-
>
58-
<ChevronLeftIcon />
59-
</button>
51+
<ArrowButton
52+
direction="left"
53+
label="Previous day"
54+
onClick={navigateToPreviousDay}
55+
/>
6056
</TooltipWrapper>
6157
<TooltipWrapper onClick={navigateToNextDay} shortcut="K">
62-
<button
63-
className="flex h-6 w-6 items-center justify-center rounded-full text-white transition-colors hover:bg-white/20 focus:bg-white/20 focus:ring-2 focus:ring-white/50 focus:outline-none"
64-
aria-label="Next day"
65-
>
66-
<ChevronRightIcon />
67-
</button>
58+
<ArrowButton
59+
direction="right"
60+
label="Next day"
61+
onClick={navigateToNextDay}
62+
/>
6863
</TooltipWrapper>
6964
</div>
7065
</div>

0 commit comments

Comments
 (0)