Skip to content

Commit b6aec75

Browse files
committed
imp: add badge at pagination and remove unused variables
1 parent 87eb7b6 commit b6aec75

File tree

6 files changed

+65
-54
lines changed

6 files changed

+65
-54
lines changed

components/common/Badge.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import styled from "@emotion/styled";
2+
import type { ReactNode } from "react";
3+
type BadgeProps = {
4+
children: ReactNode;
5+
};
6+
export default function Badge({ children }: BadgeProps) {
7+
return <Wrapper>{children}</Wrapper>;
8+
}
9+
10+
const Wrapper = styled.div`
11+
background-color: ${(props) => props.theme.colors.lightOrange};
12+
color: ${(props) => props.theme.colors.orange};
13+
display: flex;
14+
justify-content: center;
15+
align-items: center;
16+
width: 8rem;
17+
height: 1.8rem;
18+
font-size: 1rem;
19+
border-radius: 0.5rem;
20+
`;

components/events/Days.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type ComponentProps = {
1414
currentAttendee: string;
1515
attendees: Attendees;
1616
startWeekOfMonday: Date;
17-
endWeekOfSunday: Date;
1817
};
1918

2019
type CheckMarkWrapperProps = {
@@ -71,7 +70,6 @@ const Days: FC<ComponentProps> = ({
7170
attendees,
7271
currentAttendee,
7372
startWeekOfMonday,
74-
endWeekOfSunday,
7573
}) => {
7674
const id = useUrlEventId();
7775
const [checkStatusArrayState, dispatch] = useReducer(

components/events/Pagination.tsx

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1+
import Badge from "@components/common/Badge";
12
import { Arrow } from "@components/icons";
23
import styled from "@emotion/styled";
3-
import {
4-
addDateAndTime,
5-
dateToPattern,
6-
getDayOfWeek,
7-
getDiffDays,
8-
parseStringDateAndCombine,
9-
} from "@lib/days";
104
import type { FC } from "react";
115

126
type ComponentProps = {
13-
startDate: Date;
14-
endDate: Date;
157
currentPageIndex: number;
168
startWeekOfMonday: Date;
17-
endWeekOfSunday: Date;
189
onClickPageUp: () => void;
1910
onClickPageDown: () => void;
11+
totalNumberOfTableDays: number;
2012
};
2113

2214
type ArrowProps = {
@@ -25,37 +17,17 @@ type ArrowProps = {
2517
};
2618

2719
const Pagination: FC<ComponentProps> = ({
28-
startDate,
29-
endDate,
3020
currentPageIndex,
3121
onClickPageDown,
3222
onClickPageUp,
33-
endWeekOfSunday,
3423
startWeekOfMonday,
24+
totalNumberOfTableDays,
3525
}) => {
36-
const diffDays = getDiffDays(endWeekOfSunday, startWeekOfMonday);
3726
const firstPageIndex = 0;
38-
const lastPageIndex = Math.floor(diffDays / 7);
27+
const lastPageIndex = Math.floor(totalNumberOfTableDays / 7);
3928

4029
const isFirstPage = currentPageIndex === firstPageIndex;
4130
const isLastPage = currentPageIndex === lastPageIndex;
42-
const currentStartDate = addDateAndTime(startDate, {
43-
days: currentPageIndex * 7,
44-
});
45-
46-
const currentLastDate =
47-
endDate.getTime() > addDateAndTime(currentStartDate, { days: 6 }).getTime()
48-
? addDateAndTime(currentStartDate, { days: 6 })
49-
: endDate;
50-
51-
const parsedCurrentStartDate = parseStringDateAndCombine(
52-
dateToPattern(currentStartDate),
53-
"-"
54-
);
55-
const parsedCurrentLastDate = parseStringDateAndCombine(
56-
dateToPattern(currentLastDate),
57-
"-"
58-
);
5931

6032
return (
6133
<Container>
@@ -68,29 +40,34 @@ const Pagination: FC<ComponentProps> = ({
6840
</ArrowWrapper>
6941
<TextWrapper>
7042
<span>
71-
{parsedCurrentStartDate} {getDayOfWeek(currentStartDate)}요일
43+
{startWeekOfMonday.getFullYear()}{startWeekOfMonday.getMonth() + 1}
44+
7245
</span>
73-
{parsedCurrentStartDate !== parsedCurrentLastDate && (
74-
<span>
75-
{" - "}
76-
{parsedCurrentLastDate} {getDayOfWeek(currentLastDate)}요일
77-
</span>
78-
)}
7946
</TextWrapper>
80-
<ArrowWrapper
81-
isShown={!isLastPage}
82-
direction={"right"}
83-
onClick={onClickPageUp}
84-
>
85-
<Arrow />
86-
</ArrowWrapper>
47+
<BadgeRightArrowWrapper>
48+
{!isLastPage && (
49+
<BadgeWrapper>
50+
<Badge>다음주도 있어요!</Badge>
51+
</BadgeWrapper>
52+
)}
53+
<ArrowWrapper
54+
isShown={!isLastPage}
55+
direction={"right"}
56+
onClick={onClickPageUp}
57+
>
58+
<Arrow />
59+
</ArrowWrapper>
60+
</BadgeRightArrowWrapper>
8761
</Container>
8862
);
8963
};
9064

9165
export default Pagination;
9266

9367
const ArrowWrapper = styled.div<ArrowProps>`
68+
display: flex;
69+
align-items: center;
70+
justify-content: center;
9471
visibility: ${(props) => (props.isShown ? "visible" : "hidden")};
9572
transform: ${(props) =>
9673
props.direction === "left" ? "rotate(-180deg)" : ""};
@@ -107,6 +84,12 @@ const ArrowWrapper = styled.div<ArrowProps>`
10784
}
10885
`;
10986

87+
const BadgeRightArrowWrapper = styled.div`
88+
position: relative;
89+
align-items: center;
90+
display: flex;
91+
`;
92+
11093
const Container = styled.div`
11194
display: flex;
11295
justify-content: space-between;
@@ -118,3 +101,9 @@ const Container = styled.div`
118101
const TextWrapper = styled.div`
119102
font-size: 1.1rem;
120103
`;
104+
105+
const BadgeWrapper = styled.div`
106+
position: absolute;
107+
right: 2rem;
108+
font-size: 1.2rem;
109+
`;

components/events/TimetableTemplate.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,19 @@ const TimetableTemplate: FC<Props> = ({
4949
const toastMessage = isEraseMode
5050
? "지우개 모드 활성화!"
5151
: "지우개 모드 해제!";
52-
const diffDays = getDiffDays(startWeekOfMonday, endWeekOfSunday);
53-
const lastPageIndex = Math.floor(diffDays / 7);
52+
const totalNumberOfTableDays = getDiffDays(
53+
startWeekOfMonday,
54+
endWeekOfSunday
55+
);
56+
const lastPageIndex = Math.floor(totalNumberOfTableDays / 7);
5457
return (
5558
<Container>
5659
<Pagination
57-
endWeekOfSunday={endWeekOfSunday}
5860
startWeekOfMonday={startWeekOfMonday}
59-
startDate={startDate}
60-
endDate={endDate}
6161
onClickPageUp={handleClickPageUp}
6262
onClickPageDown={handleClickPageDown}
6363
currentPageIndex={currentPageIndex}
64+
totalNumberOfTableDays={totalNumberOfTableDays}
6465
/>
6566
<Wrapper>
6667
<EraserWrapper>
@@ -76,7 +77,6 @@ const TimetableTemplate: FC<Props> = ({
7677
</EraserWrapper>
7778
{isToastOpen && <Toast message={toastMessage} key={toastKeyVal} />}
7879
<Days
79-
endWeekOfSunday={endWeekOfSunday}
8080
startWeekOfMonday={startWeekOfMonday}
8181
startDate={startDate}
8282
endDate={endDate}

styles/theme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const theme: Theme = {
1414
buttonHoverPrimary: "#896300",
1515
buttonHoverSecondary: "#B8B8B8",
1616
header: "#EDAC00",
17+
orange: "#E5A600",
18+
lightOrange: "#FFEDBD",
1719
},
1820
};
1921

types/emotion.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ declare module "@emotion/react" {
1515
buttonHoverPrimary: string;
1616
buttonHoverSecondary: string;
1717
header: string;
18+
orange: string;
19+
lightOrange: string;
1820
};
1921
}
2022
}

0 commit comments

Comments
 (0)