Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { cn } from "@repo/timo-design-system/utils";
import { useState } from "react";

import {
TIME_SIDEBAR_COLLAPSED_MARGIN_CLASS_NAME,
Expand All @@ -11,6 +10,7 @@ import {
import { TimeSidebar } from "@/components/layout/sidebar/time/TimeSidebar";
import { ROUTES } from "@/constants/routes";
import { usePathname } from "@/i18n/navigation";
import { useTimeSidebarStore } from "@/stores/time-sidebar/useTimeSidebarStore";

interface WithTimeSidebarContainerProps {
children: React.ReactNode;
Expand All @@ -19,7 +19,8 @@ interface WithTimeSidebarContainerProps {
export const WithTimeSidebarContainer = ({
children,
}: WithTimeSidebarContainerProps) => {
const [isOpen, setIsOpen] = useState<boolean>(true);
const isOpen = useTimeSidebarStore((state) => state.isOpen);
const toggleOpen = useTimeSidebarStore((state) => state.toggleOpen);

const pathname = usePathname();

Expand All @@ -29,7 +30,7 @@ export const WithTimeSidebarContainer = ({
<>
<div
className={cn(
"transition-[margin-right] duration-200 ease-in-out",
"h-full transition-[margin-right] duration-200 ease-in-out",
isOpen
? TIME_SIDEBAR_MARGIN_CLASS_NAME[size]
: TIME_SIDEBAR_COLLAPSED_MARGIN_CLASS_NAME,
Expand All @@ -38,11 +39,7 @@ export const WithTimeSidebarContainer = ({
{children}
</div>

<TimeSidebar
size={size}
isOpen={isOpen}
onToggleCollapse={() => setIsOpen((prev) => !prev)}
/>
<TimeSidebar size={size} isOpen={isOpen} onToggleCollapse={toggleOpen} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import {
MemoDisableIcon,
MemoOnIcon,
Expand All @@ -14,6 +16,7 @@ import {
TagIcon,
} from "@repo/timo-design-system/ui";
import { cn } from "@repo/timo-design-system/utils";
import { useTranslations } from "next-intl";

import type {
TodoPriorityTypes,
Expand All @@ -33,11 +36,11 @@ const PRIORITY_MAP: Record<
};

export interface HomeTodoCardProps {
todoId: number;
title: string;
isCompleted: boolean;
durationSeconds: number;
priority: TodoPriorityTypes;
priorityLabel?: string;
tagName?: string;
hasMemo: boolean;
isRepeated: boolean;
Expand All @@ -50,11 +53,11 @@ export interface HomeTodoCardProps {
}

export const HomeTodoCard = ({
todoId,
title,
isCompleted,
durationSeconds,
priority,
priorityLabel,
tagName,
hasMemo,
isRepeated,
Expand All @@ -65,19 +68,32 @@ export const HomeTodoCard = ({
onTogglePlay,
onToggleSubtaskCompleted,
}: HomeTodoCardProps) => {
const tCommon = useTranslations("Common");

const { attributes, listeners, setNodeRef, transform, transition } =
useSortable({ id: todoId, disabled: isCompleted });

const sortableStyle = {
transform: CSS.Transform.toString(transform),
transition,
touchAction: "none",
};

const isRunning = timerStatus === "RUNNING";

const priorityLabel = tCommon(`priority.${PRIORITY_MAP[priority]}`);

const titleRow = (
<div className="flex w-full items-center justify-between gap-2">
<div className="flex w-[165px] items-center gap-1">
<div className="flex min-w-0 flex-1 items-center gap-1">
<Checkbox
checked={isCompleted}
onChange={onToggleCompleted}
disabled={isCompleted}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo 완료되면 체크박스도 잠기는 걸로 보이는데 화면설계서에서 [Home-Default 4-4]에 완료 투두에서 체크 박스는 수정할 수가 있어서 확인부탁드립니다!
(TodayTodoCard처럼 완료되어도 hover시에 체크박스 수정가능한걸로 알고있습니다.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

체크박스 수정 시 완료 토글 API를 호출하고, 재정렬된 데이터를 받아와야 해서 지금 프론트 로직에서 추가할 건 없어보입니다. 추후에 수정해 둘게요~!!

/>
<p
className={cn(
"typo-body-sb-12 w-[137px] truncate",
"typo-body-sb-12 min-w-0 flex-1 truncate",
isCompleted ? "text-timo-gray-700" : "text-timo-black",
)}
>
Expand All @@ -103,21 +119,27 @@ export const HomeTodoCard = ({

return (
<article
ref={setNodeRef}
style={sortableStyle}
{...attributes}
{...listeners}
className={cn(
"border-timo-gray-500 flex size-full flex-col items-start gap-2 overflow-hidden rounded-[4px] border border-solid px-3.5 py-3",
"border-timo-gray-500 flex w-full shrink-0 flex-col items-start gap-2 overflow-hidden rounded-[4px] border border-solid px-3.5 py-3",
isCompleted ? "bg-timo-gray-200" : "bg-white",
)}
>
Comment on lines 121 to 130

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

체크박스나 재생 버튼 클릭할 때도 드래그가 시작될 수 있어보여요. distance: 8 제약으로 어느 정도 방어는 되지만 완전하지 않다고 생각이 들어요. 별도 드래그 핸들 아이콘을 만들고 거기에만 {...listeners}를 붙이는 게 안전할것 같은데 어떤가요?

{subtaskTitle ? (
<div className="flex w-full flex-col items-start gap-1">
{titleRow}
<div className="flex items-center gap-2">
<div className="flex w-full min-w-0 items-center gap-2">
<Checkbox
checked={isSubtaskCompleted}
onChange={(checked) => onToggleSubtaskCompleted?.(checked)}
disabled={isCompleted}
/>
<p className="typo-body-r-12 text-timo-gray-700">{subtaskTitle}</p>
<p className="typo-body-r-12 text-timo-gray-700 min-w-0 flex-1 truncate">
{subtaskTitle}
</p>
</div>
</div>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"use client";

import { AddTaskButton } from "@repo/timo-design-system/ui";
import { useTranslations } from "next-intl";

import type { ApiDayOfWeek } from "@/app/[locale]/(main)/(with-time-sidebar)/home/_types/home-view-type";

import { HomeDateInformation } from "@/app/[locale]/(main)/(with-time-sidebar)/home/_components/HomeDateInformation";
import {
convertDateToDateText,
getToday,
parseDateKey,
} from "@/app/[locale]/(main)/(with-time-sidebar)/home/_utils/date";

export interface HomeDayHeaderContainerProps {
dateKey: string;
dayOfWeek: ApiDayOfWeek;
isHoliday: boolean;
isToday: boolean;
totalCount: number;
completedCount: number;
}

export const HomeDayHeaderContainer = ({
dateKey,
dayOfWeek,
isHoliday,
isToday,
totalCount,
completedCount,
}: HomeDayHeaderContainerProps) => {
const t = useTranslations("Home");
const tCommon = useTranslations("Common");
const date = parseDateKey(dateKey) ?? getToday();

return (
<div className="flex flex-col gap-3 pb-2">
<HomeDateInformation
date={convertDateToDateText(date)}
dayOfWeek={tCommon(`weekday.${dayOfWeek}`)}
isHoliday={isHoliday}
isToday={isToday}
totalCount={totalCount}
completedCount={completedCount}
/>
<AddTaskButton text={t("addTask")} />
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
"use client";

import { useTranslations } from "next-intl";
import { useState } from "react";

import { triggerScrollToToday } from "@/app/[locale]/(main)/(with-time-sidebar)/home/_hooks/useHomeTodayScroll";
import { useHomeViewMode } from "@/app/[locale]/(main)/(with-time-sidebar)/home/_hooks/useHomeViewMode";
import { Header } from "@/components/layout/header/Header";
import { useNavigationSidebar } from "@/components/layout/sidebar/navigation/NavigationSidebarContext";

export const HomeHeaderContainer = () => {
const t = useTranslations("Home");
const basicLabel = t("viewBasic");
const weekLabel = t("viewWeek");

const viewOptions = [basicLabel, weekLabel];
const [isWeekView, setIsWeekView] = useState<boolean>(false);

const { isOpen, toggle } = useNavigationSidebar();
const { isWeekView, setViewMode, goToNextWeek, goToPrevWeek, goToToday } =
useHomeViewMode();

const handleChangeView = (value: string) => {
if (value === basicLabel || value === weekLabel) {
setIsWeekView(value === weekLabel);
if (value === basicLabel) {
setViewMode("basic");
} else if (value === weekLabel) {
setViewMode("week");
}
};

const handleGoToToday = () => {
goToToday();
triggerScrollToToday();
};

return (
<Header
left={
<>
<Header.SidebarButton isOpen={isOpen} onClick={toggle} />
<Header.TodayButton label={t("today")} />
{isWeekView ? (
<Header.WeeklyNav onPrev={goToPrevWeek} onNext={goToNextWeek} />
) : (
<Header.TodayButton label={t("today")} onClick={handleGoToToday} />
)}
</>
}
right={
Expand Down
Loading
Loading