Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TripList 페이지 구현 #51

Merged
merged 49 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
27839f7
feat: Trips 페이지 라우팅, TripsHeader 추가
dladncks1217 Jul 13, 2023
af96177
feat: TripsItem 컴포넌트 마크업 추가
dladncks1217 Jul 15, 2023
42fe382
feat: TripsItemList 컴포넌트 마크업 추가
dladncks1217 Jul 15, 2023
9aabca8
feat: TripsHeader 컴포넌트 마크업 추가
dladncks1217 Jul 15, 2023
fb77f22
feat: Trips페이지 마크업 추가
dladncks1217 Jul 15, 2023
20add0c
feat: 여행 목록 조회 API MSW 모킹 코드 추가
dladncks1217 Jul 15, 2023
0b06edd
fix: 화면 확대 시 Badge가 사라지는 문제 해결
dladncks1217 Jul 15, 2023
2f850f5
feat: Trips 가져오기 위한 useGetTrips Hook 추가
dladncks1217 Jul 15, 2023
fb79a83
refactor: TripsItem badgeName Props 타입 수정
dladncks1217 Jul 15, 2023
bc306a3
feat: TripsType, Cities 타입 추가
dladncks1217 Jul 15, 2023
ae0326f
feat: useGetTrips훅 사용을 통한 fetch 코드 반영
dladncks1217 Jul 15, 2023
ef5da4a
refactor: Trips item이 grid template에서 높이가 깨지는 문제 수정
dladncks1217 Jul 16, 2023
e0665d5
refactor: Trips Header svg 위치 조정
dladncks1217 Jul 16, 2023
e5d3f4f
feat: trips 데이터 수에 따른 다른 화면 전환 추가
dladncks1217 Jul 16, 2023
7666458
feat: trips 없을 경우 보여주는 화면 마크업 추가 (TripsItemNone)
dladncks1217 Jul 16, 2023
806289f
feat: 튜토리얼 모달 컴포넌트 추가
dladncks1217 Jul 16, 2023
d5dd860
refactor: msw 목데이터 수정
dladncks1217 Jul 16, 2023
bd7200f
refactor: useGetTrips Hook refetch메서드 추가
dladncks1217 Jul 16, 2023
2da3286
feat: 날짜 정렬 유틸함수 추가
dladncks1217 Jul 16, 2023
6b7a753
feat: Trips 페이지 추가
dladncks1217 Jul 16, 2023
ea75f81
feat: trips 카테고리 정렬 기능 추가
dladncks1217 Jul 16, 2023
4c52e04
chore: 컴포넌트 네이밍 오타 수정
dladncks1217 Jul 16, 2023
64a3709
refactor: TripsItemList 컴포넌트 key props 누락 문제 수정
dladncks1217 Jul 16, 2023
f2b9841
chore: hanglog-design-system 버전 수정
dladncks1217 Jul 16, 2023
5d1e16f
refactor: flex 사용 가능 컴포넌트에서 box컴포넌트 사용 코드 수정
dladncks1217 Jul 16, 2023
6d9473a
refactor: msw 모킹 데이터 시안에 맞게 수정
dladncks1217 Jul 16, 2023
42b8c5a
refactor: 시안에 맞도록 텍스트 크기 변경 및 margin 수정
dladncks1217 Jul 16, 2023
4e31cb7
refactor: css 순서 수정
dladncks1217 Jul 16, 2023
8d907a5
refactor: 디자인시스템 버전업에 따른 헤더 컴포넌트 코드 수정
dladncks1217 Jul 17, 2023
7fd5620
refactor: badgeName tripsItem으로 수정
dladncks1217 Jul 17, 2023
4a6f3e5
feat: 등록순 날짜순 상수화
dladncks1217 Jul 17, 2023
ddee112
refactor: TutorialModal 모달 오픈 useOverlay훅으로 수정, 피그마에 맞게 모달 사이즈 수정
dladncks1217 Jul 17, 2023
fa40eb5
refactor: trips 요청 쿼리, 훅 분리 리팩토링
dladncks1217 Jul 17, 2023
22657bb
refactor: TripsItemListProps 내부 타입들 네이밍 수정
dladncks1217 Jul 17, 2023
72df8ab
refactor: 피그마에 맞는 스타일 수정
dladncks1217 Jul 17, 2023
1a59583
refactor: 정렬 기능에서 refetch대신 invalidate queries 사용하도록 수정
dladncks1217 Jul 17, 2023
d72d266
refactor: imageUrls -> imageUrl 타입 수정
dladncks1217 Jul 17, 2023
7e351f8
refactor: 시작일 백엔드 데이터 타입 수정
dladncks1217 Jul 17, 2023
0d306a6
refactor: msw mock data 분리
dladncks1217 Jul 17, 2023
fb05a9b
chore: 디자인시스템 버전 변경
dladncks1217 Jul 17, 2023
562a06e
refactor: 상대경로 절대경로로 컨벤션에 맞게 수정
dladncks1217 Jul 17, 2023
52a47ef
refactor: selected -> sortSelected로 네이밍 수정
dladncks1217 Jul 17, 2023
434c7d2
refactor: css 순서 수정
dladncks1217 Jul 17, 2023
d447229
refactor: trips description null 케이스 대응 코드 추가
dladncks1217 Jul 17, 2023
88b6a17
refactor: TripsPage 불필요한 refetch 제거
dladncks1217 Jul 18, 2023
c5791d8
refactor: TutorialModal 디자인 시안에 맞게 픽셀 수정
dladncks1217 Jul 18, 2023
46c5c1b
refactor: 불필요한 handleModalClose 코드 제거
dladncks1217 Jul 18, 2023
d2ac553
refactor: Header컴포넌트 모달 오픈 시 보이는 문제로 인한 zIndex 수정
dladncks1217 Jul 18, 2023
bc423a3
Merge branch 'develop' into feature/#36
ashleysyheo Jul 18, 2023
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
14 changes: 7 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@emotion/styled": "^11.11.0",
"@tanstack/react-query": "^4.29.19",
"axios": "^1.4.0",
"hang-log-design-system": "^1.1.1",
"hang-log-design-system": "^1.1.16",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.1",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/axiosInstance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BASE_URL } from '@/constants/api';
import { BASE_URL } from '@constants/api';
import axios from 'axios';

export const axiosInstance = axios.create({
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/api/trips/trips.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { END_POINTS } from '@constants/api';
import type { TripsType } from '@type/trips';

import { axiosInstance } from '@api/axiosInstance';

export const getTrips = async () => {
const { data } = await axiosInstance.get<{ trips: TripsType[] }>(END_POINTS.TRIPS);

return data?.trips;
};
122 changes: 122 additions & 0 deletions frontend/src/assets/svg/TripsHeader.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions frontend/src/assets/svg/tutorial1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions frontend/src/assets/svg/tutorial2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions frontend/src/assets/svg/tutorial3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions frontend/src/assets/svg/tutorial4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions frontend/src/components/Trips/TripsHeader/TripsHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import TripsHeaderSVG from '@assets/svg/TripsHeader.svg';
import { Box, Flex, Heading } from 'hang-log-design-system';

const TripsHeader = () => {
return (
<>
<Flex styles={{ justify: 'space-between', width: '100%', gap: '200px' }}>
<Box>
<Box
style={{ height: '200px', paddingLeft: '50px', display: 'flex', alignItems: 'center' }}
>
<Heading size="large">라곤의 여행</Heading>
</Box>
</Box>
<Flex styles={{ width: '70%', height: '18%', paddingRight: '50px', justify: 'right' }}>
<TripsHeaderSVG style={{ width: '854px' }} />
</Flex>
</Flex>
</>
);
};

export default TripsHeader;
68 changes: 68 additions & 0 deletions frontend/src/components/Trips/TripsItem/TripsItem.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { css } from '@emotion/react';
import { Theme } from 'hang-log-design-system';

dladncks1217 marked this conversation as resolved.
Show resolved Hide resolved
export const tripsBoxStyling = css({
alignSelf: 'start',
dladncks1217 marked this conversation as resolved.
Show resolved Hide resolved

width: `calc((100vw - 196px) / 5)`,
margin: 0,
padding: 0,
});

export const tripsItemImageBoxStyling = css({
width: '100%',
height: '176px',
});

export const tripsItemImageStyling = css({
objectFit: 'cover',

width: '100%',
height: '100%',
minHeight: '176px',
maxHeight: '176px',
borderRadius: Theme.borderRadius.medium,
});

export const tripsItemNameStying = css({
marginBottom: Theme.spacer.spacing1,
dladncks1217 marked this conversation as resolved.
Show resolved Hide resolved

fontWeight: '600',
});

export const tripsItemBadgeBoxStyling = css({
width: `calc((100vw - 196px) / 5)`,
minHeight: '22px',
marginTop: Theme.spacer.spacing3,
marginBottom: Theme.spacer.spacing2,

overflowX: 'scroll',
whiteSpace: 'nowrap',
'-ms-overflow-style': 'none',
scrollbarWidth: 'none',

'& > span': {
marginRight: Theme.spacer.spacing2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

😱 css 순서.....

Copy link
Member Author

Choose a reason for hiding this comment

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

'& > span' 내부 속성들도 위 속성들 내부로 순서가 적용되는거였나요..?
'& > span' 같은건 css순서 별개로 밑에 몰아두는게 보는데 좋을 것 같은데 어떤가요?🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

이 파일 전체적인 css 순서를 말하는 거였어요!

밑에도...

export const tripsDurationTextStyling = css({
  marginTop: '4px',
  width: '100%',
  textOverflow: 'ellipsis',
  overflow: 'hidden',
  wordBreak: 'break-word',
  display: '-webkit-box',
  '-webkit-line-clamp': '2',
  '-webkit-box-orient': 'vertical',
});

순서... (저희 진짜 style-lint 도입하시죠...!)

Copy link
Member Author

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋ 진짜 도입 해야할거같습니다...😂

},

'::-webkit-scrollbar': {
display: 'none',
},
});

export const tripsTiemDurationStyling = css({
marginBottom: Theme.spacer.spacing1,
});

export const tripsDurationTextStyling = css({
display: '-webkit-box',
'-webkit-line-clamp': '2',
'-webkit-box-orient': 'vertical',

marginTop: '4px',
width: '100%',

textOverflow: 'ellipsis',
overflow: 'hidden',
wordBreak: 'break-word',
});
43 changes: 43 additions & 0 deletions frontend/src/components/Trips/TripsItem/TripsItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Cities } from '@type/trips';
dladncks1217 marked this conversation as resolved.
Show resolved Hide resolved
import { Badge, Box, Flex, Text } from 'hang-log-design-system';

import {
tripsBoxStyling,
tripsDurationTextStyling,
tripsItemBadgeBoxStyling,
tripsItemImageBoxStyling,
tripsItemImageStyling,
tripsItemNameStying,
} from '@components/trips/TripsItem/TripsItem.style';

interface TripItemProps {
coverImage: string;
cityTags: Cities[];
itemName: string;
duration: string;
description?: string | null;
}

const TripsItem = ({ coverImage, cityTags, itemName, duration, description }: TripItemProps) => {
return (
<Flex styles={{ direction: 'column' }} css={tripsBoxStyling}>
<Box css={tripsItemImageBoxStyling}>
<img src={coverImage} css={tripsItemImageStyling} />
</Box>
<Box css={tripsItemBadgeBoxStyling}>
{cityTags.map((badge) => {
return <Badge key={badge.id}>{badge.name}</Badge>;
})}
</Box>
<Text size="large" css={tripsItemNameStying}>
{itemName}
</Text>
<Text size="medium">{duration}</Text>
<Text size="small" css={tripsDurationTextStyling}>
{description}
</Text>
</Flex>
);
};

export default TripsItem;
15 changes: 15 additions & 0 deletions frontend/src/components/Trips/TripsItemList/TripsItemList.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { css } from '@emotion/react';
import { Theme } from 'hang-log-design-system';

export const TripsItemGridBoxStyling = css({
margin: `${Theme.spacer.spacing4} 50px ${Theme.spacer.spacing7}`,
display: 'grid',
gridTemplateColumns: 'repeat(5, 1fr)',
rowGap: Theme.spacer.spacing5,
columnGap: Theme.spacer.spacing4,
placeItems: 'center',
});

export const TripsToggleGroupStyling = css({
marginTop: Theme.spacer.spacing3,
});
58 changes: 58 additions & 0 deletions frontend/src/components/Trips/TripsItemList/TripsItemList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { ORDER_BY_DATE, ORDER_BY_REGISTRATION } from '@constants/order';
import { TripsType } from '@type/trips';
dladncks1217 marked this conversation as resolved.
Show resolved Hide resolved
import { Box, Flex, Toggle, ToggleGroup } from 'hang-log-design-system';

import { formatDate } from '@utils/formatter';

import TripsItem from '@components/trips/TripsItem/TripsItem';
import {
TripsItemGridBoxStyling,
TripsToggleGroupStyling,
} from '@components/trips/TripsItemList/TripsItemList.style';
dladncks1217 marked this conversation as resolved.
Show resolved Hide resolved

interface TripsItemListProps {
trips: TripsType[];
order: string | number;
changeSelect: (selectedId: string | number) => void;
}

const TripsItemList = ({ trips, order, changeSelect }: TripsItemListProps) => {
return (
trips && (
<>
<Flex styles={{ justify: 'right', paddingRight: '50px' }} css={TripsToggleGroupStyling}>
<ToggleGroup>
<Toggle
text={ORDER_BY_REGISTRATION}
toggleId={ORDER_BY_REGISTRATION}
selectedId={order}
changeSelect={changeSelect}
/>
<Toggle
text={ORDER_BY_DATE}
toggleId={ORDER_BY_DATE}
selectedId={order}
changeSelect={changeSelect}
/>
</ToggleGroup>
</Flex>
<Box css={TripsItemGridBoxStyling}>
{trips.map((trip) => {
return (
<TripsItem
key={trip.id}
coverImage={trip.imageUrl}
cityTags={trip.cities}
itemName={trip.title}
duration={`${formatDate(trip.startDate)}~${formatDate(trip.endDate)}`}
description={trip.description}
/>
);
})}
</Box>
</>
)
);
};

export default TripsItemList;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { css } from '@emotion/react';

export const TripsItemNoneBoxStyling = css({
marginLeft: '50px',
});
21 changes: 21 additions & 0 deletions frontend/src/components/Trips/TripsItemNone/TripsItemNone.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Box, Button, Heading, Text } from 'hang-log-design-system';

import { TripsItemNoneBoxStyling } from '@components/trips/TripsItemNone/TripsItemNone.style';
import TutorialModal from '@components/trips/TutorialModal/TutorialModal';

const TripsItemNone = () => {
return (
<Box css={TripsItemNoneBoxStyling}>
<Heading size="xSmall">아직 기록된 여행이 없습니다!</Heading>
<Text style={{ padding: '8px 0 16px' }}>
여행 가방에 쌓인 먼지를 털어내고 여행을 기록해 보세요.
</Text>
<Button variant="primary" size="medium">
여행 기록하기
</Button>
<TutorialModal />
</Box>
);
};

export default TripsItemNone;
16 changes: 16 additions & 0 deletions frontend/src/components/Trips/TutorialModal/TutorialModal.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { css } from '@emotion/react';

export const ModalCarouselBoxStyling = css({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',

width: '450px',
height: '581px',
marginTop: '30px',
});

export const ModalCloseButtonStyling = css({
width: '100%',
marginTop: 'auto',
});
36 changes: 36 additions & 0 deletions frontend/src/components/Trips/TutorialModal/TutorialModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Tutorial1SVG from '@assets/svg/tutorial1.svg';
import Tutorial2SVG from '@assets/svg/tutorial2.svg';
import Tutorial3SVG from '@assets/svg/tutorial3.svg';
import Tutorial4SVG from '@assets/svg/tutorial4.svg';
import { Button, Flex, Modal, SVGCarousel, useOverlay } from 'hang-log-design-system';
import { useCallback, useEffect } from 'react';

import {
ModalCarouselBoxStyling,
ModalCloseButtonStyling,
} from '@components/trips/TutorialModal/TutorialModal.style';

const TutorialModal = () => {
const { isOpen, open, close } = useOverlay();

useEffect(() => {
open();
}, []);

return (
<Modal isOpen={isOpen} closeModal={close} hasCloseButton={true}>
<Flex css={ModalCarouselBoxStyling}>
<SVGCarousel
width={385}
height={412}
images={[Tutorial1SVG, Tutorial2SVG, Tutorial3SVG, Tutorial4SVG]}
/>
<Button variant="primary" css={ModalCloseButtonStyling} onClick={close}>
닫기
</Button>
</Flex>
</Modal>
);
};

export default TutorialModal;
2 changes: 1 addition & 1 deletion frontend/src/components/layout/Header/Header.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const headerStyling = css({
position: 'sticky',
top: 0,

zIndex: Theme.zIndex.overlayTop,
zIndex: Theme.zIndex.overlayMiddle,

backgroundColor: Theme.color.white,
padding: `${Theme.spacer.spacing4} 50px`,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/layout/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const Header = () => {
<div css={imageStyling} onClick={open}></div>
{isOpen && (
<MenuList>
<MenuItem name="마이페이지" onClick={() => navigate(PATH.ROOT)} />
<MenuItem name="로그아웃" onClick={() => navigate(PATH.ROOT)} />
<MenuItem onClick={() => navigate(PATH.ROOT)}>마이페이지</MenuItem>
<MenuItem onClick={() => navigate(PATH.ROOT)}>로그아웃</MenuItem>
</MenuList>
)}
</Menu>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/constants/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ export const END_POINTS = {
CREATE_TRIP_ITEM: (tripId: number) => `/trips/${tripId}/items`,
CHANGE_TRIP_ITEM: (tripId: number, itemId: number) => `/trips/${tripId}/items/${itemId}`,
} as const;

export const NETWORK = {
RETRY_COUNT: 3,
} as const;
2 changes: 2 additions & 0 deletions frontend/src/constants/order.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const ORDER_BY_REGISTRATION = '등록순';
export const ORDER_BY_DATE = '날짜순';
Loading