Skip to content

Commit cd54558

Browse files
authored
Merge pull request #119 from part3-4team-Taskify/feature/Gnb
[Feat, Style] mydashboard: 관리 모드 추가 / CardButton: 대시보드 탈퇴 기능 추가
2 parents 65239d2 + 13ffbdf commit cd54558

File tree

9 files changed

+203
-43
lines changed

9 files changed

+203
-43
lines changed

src/components/button/CardButton.tsx

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { useRouter } from "next/router";
23
import clsx from "clsx";
34
import Image from "next/image";
45

@@ -8,6 +9,11 @@ interface CardButtonProps
89
title?: string;
910
showCrown?: boolean;
1011
color?: string;
12+
isEditMode?: boolean;
13+
dashboardId: number;
14+
createdByMe?: boolean;
15+
onDeleteClick?: (id: number) => void;
16+
onLeaveClick?: (id: number) => void;
1117
}
1218

1319
const CardButton: React.FC<CardButtonProps> = ({
@@ -16,21 +22,59 @@ const CardButton: React.FC<CardButtonProps> = ({
1622
title = "비브리지",
1723
showCrown = true,
1824
color = "#7ac555", // 기본 색상
25+
isEditMode = false,
26+
dashboardId,
27+
createdByMe,
28+
onDeleteClick,
29+
onLeaveClick,
1930
...props
2031
}) => {
32+
const router = useRouter();
33+
34+
const handleCardClick = (e: React.MouseEvent<HTMLButtonElement>) => {
35+
// 관리 상태에서 카드 클릭 이벤트 차단
36+
if (isEditMode) {
37+
e.preventDefault();
38+
return;
39+
}
40+
// 카드 클릭 시 해당 대시보드로 이동
41+
router.push(`/dashboard/${dashboardId}`);
42+
};
43+
44+
const handleEdit = (e: React.MouseEvent) => {
45+
e.stopPropagation();
46+
router.push(`/dashboard/${dashboardId}/edit`);
47+
};
48+
49+
const handleDelete = (e: React.MouseEvent) => {
50+
e.stopPropagation();
51+
if (createdByMe) {
52+
// 실제 삭제 API 요청
53+
if (onDeleteClick) onDeleteClick(dashboardId);
54+
} else {
55+
// 나만 탈퇴
56+
if (onLeaveClick) onLeaveClick(dashboardId);
57+
}
58+
};
59+
2160
return (
2261
<button
62+
{...props}
63+
onClick={handleCardClick}
2364
className={clsx(
2465
"flex justify-between items-center bg-white transition-all",
25-
"rounded-lg px-4 py-3 font-semibold",
26-
"border border-gray-300 hover:border-purple-500",
66+
"rounded-lg px-4 py-3 font-16sb",
67+
"border border-gray-300",
2768
fullWidth ? "w-full" : "w-[260px] md:w-[247px] lg:w-[332px]",
2869
"h-[58px] md:h-[68px] lg:h-[70px]",
2970
"mt-[10px] md:mt-[16px] lg:mt-[20px]",
3071
"text-lg md:text-2lg lg:text-2lg",
72+
"transition-all",
73+
isEditMode
74+
? "cursor-default hover:border-gray-300"
75+
: "cursor-pointer hover:border-purple-500",
3176
className
3277
)}
33-
{...props}
3478
>
3579
{/* 왼쪽: 색상 도트 + 제목 + 왕관 */}
3680
<div className="flex items-center gap-[10px] overflow-hidden">
@@ -40,7 +84,7 @@ const CardButton: React.FC<CardButtonProps> = ({
4084
</svg>
4185

4286
{/* 제목 */}
43-
<span className="font-semibold truncate">{title}</span>
87+
<span className="font-16sb truncate">{title}</span>
4488

4589
{/* 왕관 */}
4690
{showCrown && (
@@ -54,14 +98,33 @@ const CardButton: React.FC<CardButtonProps> = ({
5498
)}
5599
</div>
56100

57-
{/* 오른쪽: 화살표 아이콘 */}
58-
<Image
59-
src="/svgs/arrow-forward-black.svg"
60-
alt="arrow icon"
61-
width={16}
62-
height={16}
63-
className="ml-2"
64-
/>
101+
{/* 오른쪽: 화살표 아이콘 or 수정/삭제 버튼 */}
102+
{isEditMode ? (
103+
<div className="flex flex-col gap-2">
104+
{createdByMe && (
105+
<button
106+
onClick={handleEdit}
107+
className="font-12m text-gray1 border border-[var(--color-gray3)] px-2 rounded hover:bg-gray-100 cursor-pointer"
108+
>
109+
수정
110+
</button>
111+
)}
112+
<button
113+
onClick={handleDelete}
114+
className="font-12m text-red-400 border border-red-400 px-2 rounded hover:bg-red-100 cursor-pointer"
115+
>
116+
삭제
117+
</button>
118+
</div>
119+
) : (
120+
<Image
121+
src="/svgs/arrow-forward-black.svg"
122+
alt="arrow icon"
123+
width={16}
124+
height={16}
125+
className="ml-2"
126+
/>
127+
)}
65128
</button>
66129
);
67130
};

src/components/button/DashboardAddButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ const DashboardAddButton: React.FC<DashboardAddButtonProps> = ({
1717
<button
1818
className={clsx(
1919
"flex justify-center items-center gap-[10px] bg-white transition-all",
20-
"rounded-lg px-4 py-3 font-semibold",
20+
"rounded-lg px-4 py-3 font-16sb",
2121
"border border-gray-300 hover:border-purple-500",
2222
fullWidth ? "w-full" : "w-[260px] md:w-[247px] lg:w-[332px]", // 반응형 너비
2323
"h-[58px] md:h-[68px] lg:h-[70px]", // 반응형 높이
2424
"mt-[10px] md:mt-[16px] lg:mt-[20px]", // 여백
2525
"text-lg md:text-2lg lg:text-2lg",
26+
"cursor-pointer",
2627
className
2728
)}
2829
{...props}

src/components/button/PaginationButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const PaginationButton: React.FC<PaginationButtonProps> = ({
1414
const baseStyle =
1515
"w-[40px] h-[40px] flex justify-center items-center border border-[var(--color-gray3)] rounded-md text-[16px] font-medium cursor-pointer transition";
1616

17-
const enabledTextColor = "text-[var(--color-gray1)] hover:bg-gray-100";
17+
const enabledTextColor =
18+
"text-[var(--color-gray1)] bg-white hover:bg-[var(--color-gray5)]";
1819
const disabledTextColor = "text-[var(--color-gray3)] ";
1920

2021
const finalStyle = `${baseStyle} ${disabled ? disabledTextColor : enabledTextColor}`;

src/components/gnb/HeaderDashboard.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ interface HeaderDashboardProps {
1818
variant?: "mydashboard" | "dashboard" | "mypage";
1919
dashboardTitle?: string;
2020
dashboardId?: string | string[];
21+
isEditMode?: boolean;
22+
onToggleEditMode?: () => void;
2123
}
2224

2325
const HeaderDashboard: React.FC<HeaderDashboardProps> = ({
2426
variant,
2527
dashboardId,
28+
isEditMode,
29+
onToggleEditMode,
2630
}) => {
2731
const router = useRouter();
2832
const [isLoading, setIsLoading] = useState(true);
@@ -113,7 +117,7 @@ const HeaderDashboard: React.FC<HeaderDashboardProps> = ({
113117
})();
114118

115119
return (
116-
<header className="w-full h-[60px] md:h-[70px] flex items-center justify-center bg-white border-b-[1px] border-b-[#D9D9D9]">
120+
<header className="w-full h-[60px] md:h-[70px] flex items-center justify-center bg-white border-b-[1px] border-b-[var(--color-gray3)]">
117121
<ToastContainer position="top-center" />
118122
<div className="w-full flex items-center justify-between pl-[4vw]">
119123
{errorMessage && (
@@ -148,6 +152,7 @@ const HeaderDashboard: React.FC<HeaderDashboardProps> = ({
148152
<div
149153
className={`flex gap-[6px] md:gap-[16px] ${variant === "mydashboard" ? "pr-[22px] md:pr-[32px]" : ""}`}
150154
>
155+
{/*관리 버튼*/}
151156
<button
152157
onClick={() => {
153158
if (dashboardId) {
@@ -157,10 +162,12 @@ const HeaderDashboard: React.FC<HeaderDashboardProps> = ({
157162
toast.error("대시보드 수정 권한이 없습니다.");
158163
}
159164
} else {
160-
router.push("/mypage");
165+
if (onToggleEditMode) {
166+
onToggleEditMode();
167+
}
161168
}
162169
}}
163-
className="flex items-center justify-center w-[49px] h-[30px] md:w-[85px] md:h-[36px] lg:w-[88px] lg:h-[40px] rounded-[8px] border border-[#D9D9D9] gap-[10px] cursor-pointer"
170+
className="flex items-center justify-center w-[49px] h-[30px] md:w-[85px] md:h-[36px] lg:w-[88px] lg:h-[40px] rounded-[8px] border border-[var(--color-gray3)] gap-[10px] cursor-pointer"
164171
>
165172
<Image
166173
src="/svgs/settings.svg"
@@ -169,14 +176,16 @@ const HeaderDashboard: React.FC<HeaderDashboardProps> = ({
169176
height={20}
170177
className="hidden md:block"
171178
/>
172-
<span className="text-sm md:text-base text-gray1">관리</span>
179+
<span className="text-sm md:text-base text-gray1">
180+
{isEditMode ? "완료" : "관리"}
181+
</span>
173182
</button>
174183

175184
{/*초대하기 버튼*/}
176185
{variant !== "mydashboard" && (
177186
<button
178187
onClick={openInviteModal}
179-
className="flex items-center justify-center w-[73px] h-[30px] md:w-[109px] md:h-[36px] lg:w-[116px] lg:h-[40px] rounded-[8px] border border-[#D9D9D9] gap-[10px] cursor-pointer"
188+
className="flex items-center justify-center w-[73px] h-[30px] md:w-[109px] md:h-[36px] lg:w-[116px] lg:h-[40px] rounded-[8px] border border-[var(--color-gray3)] gap-[10px] cursor-pointer"
180189
>
181190
<Image
182191
src="/svgs/add-box.svg"

src/components/gnb/HeaderDefault.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const HeaderDefault: React.FC<HeaderDefaultProps> = ({ variant = "white" }) => {
2828
return (
2929
<header
3030
className={`w-full h-[60px] md:h-[70px] flex items-center justify-center
31-
${isWhite ? "bg-white border-b-[1px] border-b-[#D9D9D9]" : "bg-black"} `}
31+
${isWhite ? "bg-white border-b-[1px] border-b-[var(--color-gray3)]" : "bg-black"} `}
3232
>
3333
<div className="w-full flex items-center justify-between px-[24px] md:px-[40px] lg:px-[70px]">
3434
<div className="flex items-center cursor-pointer">

src/components/gnb/MemberListMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const MemberListMenu: React.FC<MemberListMenuProps> = ({
2222
<div
2323
ref={ref}
2424
className={`absolute top-full right-0 w-full z-50
25-
bg-white border border-[#D9D9D9] shadow
25+
bg-white border border-[var(--color-gray3)] shadow
2626
transition-all duration-200 ease-out
2727
${isListOpen ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-2 pointer-events-none"}`}
2828
>

src/components/gnb/UserMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const UserMenu: React.FC<UserMenuProps> = ({ isMenuOpen, setIsMenuOpen }) => {
3232
<div
3333
ref={ref}
3434
className={`absolute top-full right-0 w-full
35-
bg-white border border-[#D9D9D9] shadow z-50
35+
bg-white border border-[var(--color-gray3)] shadow z-50
3636
transition-all duration-200 ease-out
3737
${isMenuOpen ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-2 pointer-events-none"}`}
3838
>

src/pages/dashboard/[dashboardId]/edit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default function EditDashboard() {
103103
<div className="flex mt-15 sm:mt-0 ml-8">
104104
<button
105105
onClick={handleDelete}
106-
className="text-base sm:text-lg cursor-pointer w-[320px] h-[62px] text-[var(--color-black3)] rounded-[8px] border-[1px] border-[#D9D9D9] hover:scale-105 transition-transform duration-200"
106+
className="text-base sm:text-lg cursor-pointer w-[320px] h-[62px] text-black3 rounded-[8px] border-[1px] border-[var(--color-gray3)] hover:scale-105 transition-transform duration-200"
107107
>
108108
대시보드 삭제하기
109109
</button>

0 commit comments

Comments
 (0)