Skip to content

Commit

Permalink
Merge pull request #197 from SOPT-all/develop
Browse files Browse the repository at this point in the history
[DEPLOY] dev to main
  • Loading branch information
seong-hui authored Jan 23, 2025
2 parents 7e180f1 + a8d4ca7 commit 667f370
Show file tree
Hide file tree
Showing 28 changed files with 240 additions and 53 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<script type="module" src="/src/main.tsx"></script>
<script
type="text/javascript"
src="https://oapi.map.naver.com/openapi/v3/maps.js?ncpClientId=xflkwfbdso"></script>
src="https://oapi.map.naver.com/openapi/v3/maps.js?ncpClientId=%VITE_NAVER_API_KEY%"></script>
</body>
</html>
Binary file added src/assets/images/img_gray_light_leaf_medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/img_gray_light_leaf_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/components/card/popularCard/PopularCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ const PopularCard = ({

const handleLikeClick = (e: React.MouseEvent) => {
e.stopPropagation();

const userId = Number(localStorage.getItem('userId'));
if (!userId) {
onLikeToggle(liked);
return;
}

setLiked((prev) => !prev);
onLikeToggle(liked);
};
Expand Down
6 changes: 4 additions & 2 deletions src/components/card/reviewCard/reviewCard/ReviewCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Icon from '@assets/svgs';
import emptyMediumImage from '@assets/images/img_gray_light_leaf_medium.png';
import emptySmallImage from '@assets/images/img_gray_light_leaf_small.png';

import * as styles from './reviewCard.css';
import CardInfo from '../cardInfo/CardInfo';
Expand All @@ -25,14 +26,15 @@ const ReviewCard = ({
const handleButtonClick = () => {
window.open(reviewLink, '_blank');
};
const emptyImage = size === 'small' ? emptyMediumImage : emptySmallImage;

return (
<button className={styles.cardContainer({ size })} onClick={handleButtonClick}>
{blogImage ? (
<img className={styles.cardImage({ size })} src={blogImage} alt="thumbnail" />
) : (
<div className={styles.emptyImage({ size })}>
<Icon.IcnEmptyImage />
<img src={emptyImage} alt="빈 이미지"></img>
</div>
)}
<div className={styles.cardContent({ size })}>
Expand Down
41 changes: 30 additions & 11 deletions src/components/card/templeStayCard/TempleStayCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import errorImage from '@assets/images/img_gray_light_leaf_medium.png';
import InfoSection from '@components/card/templeStayCard/InfoSection';
import FlowerIcon from '@components/common/icon/flowerIcon/FlowerIcon';
import { useState } from 'react';
Expand All @@ -11,11 +12,12 @@ interface TempleStayCardProps {
tag: string;
region: string;
type: string;
imgUrl: string;
imgUrl?: string;
liked: boolean;
layout: 'vertical' | 'horizontal';
onToggleWishlist: (templestayId: number, liked: boolean) => void;
onClick?: () => void;
onRequireLogin?: () => void;
}

const TempleStayCard = ({
Expand All @@ -30,12 +32,20 @@ const TempleStayCard = ({
layout,
onToggleWishlist,
onClick,
onRequireLogin,
}: TempleStayCardProps) => {
const [isWished, setIsWished] = useState(liked);
const isHorizontal = layout === 'horizontal';

const onClickWishBtn = (e: React.MouseEvent) => {
e.stopPropagation();

const userId = Number(localStorage.getItem('userId'));
if (!userId) {
onRequireLogin?.();
return;
}

setIsWished((prev) => !prev);
onToggleWishlist(templestayId, isWished);
};
Expand All @@ -45,16 +55,25 @@ const TempleStayCard = ({
className={isHorizontal ? styles.horizontalContainer : styles.verticalContainer}
onClick={onClick}
role="presentation">
<section className={isHorizontal ? styles.horizontalImgSection : styles.verticalImgSection}>
<img
className={isHorizontal ? styles.horizontalImage : styles.verticalImage}
src={imgUrl}
alt={templeName + ' 대표사진'}
/>
<button className={styles.wishBtn} onClick={onClickWishBtn}>
<FlowerIcon isActive={isWished} />
</button>
</section>
{imgUrl ? (
<section className={isHorizontal ? styles.horizontalImgSection : styles.verticalImgSection}>
<img
className={isHorizontal ? styles.horizontalImage : styles.verticalImage}
src={imgUrl}
alt={templeName + ' 대표사진'}
/>
<button className={styles.wishBtn} onClick={onClickWishBtn}>
<FlowerIcon isActive={isWished} />
</button>
</section>
) : (
<div
className={
isHorizontal ? styles.horizontalEmptyImgSection : styles.verticalEmptyImgSection
}>
<img src={errorImage} alt="빈이미지"></img>
</div>
)}

<InfoSection
templeName={templeName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ interface SearchCardListProps {
}[];
layout: 'vertical' | 'horizontal';
onToggleWishlist: (templestayId: number, liked: boolean) => void;
onRequireLogin?: () => void;
}

const SearchCardList = ({ data, layout = 'horizontal', onToggleWishlist }: SearchCardListProps) => {
const SearchCardList = ({
data,
layout = 'horizontal',
onToggleWishlist,
onRequireLogin,
}: SearchCardListProps) => {
const navigate = useNavigate();

const handleCardClick = (templestayId: number) => {
Expand All @@ -42,6 +48,7 @@ const SearchCardList = ({ data, layout = 'horizontal', onToggleWishlist }: Searc
layout={layout}
onToggleWishlist={onToggleWishlist}
onClick={() => handleCardClick(temple.templestayId)}
onRequireLogin={onRequireLogin}
/>
))}
</section>
Expand Down
38 changes: 38 additions & 0 deletions src/components/card/templeStayCard/templeStayCard.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,41 @@ export const wishBtn = style({

zIndex: '2',
});

export const verticalEmptyImgSection = style({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
height: '100%',
objectFit: 'cover',
borderRadius: '4px',
backgroundColor: theme.COLORS.gray2,

transition: '0.15s ease-out',

selectors: {
[`${verticalContainer}:hover &`]: {
filter: 'brightness(88%)',
},
},
});

export const horizontalEmptyImgSection = style({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
height: '100%',
objectFit: 'cover',
borderRadius: '4px 0 0 4px',
backgroundColor: theme.COLORS.gray2,

transition: '0.15s ease-out',

selectors: {
[`${horizontalContainer}:hover &`]: {
filter: 'brightness(88%)',
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface WishCardListProps {
tag: string;
region: string;
type: string;
imgUrl: string;
imgUrl?: string;
liked: boolean;
}[];
layout: 'vertical' | 'horizontal';
Expand Down
5 changes: 3 additions & 2 deletions src/components/carousel/detailCarousel/DetailCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import useGetTempleImages from '@apis/templeImages';
import ExceptLayout from '@components/except/exceptLayout/ExceptLayout';
import useCarousel from '@hooks/useCarousel';
import registDragEvent from '@utils/registDragEvent';
import { useParams } from 'react-router-dom';
Expand All @@ -16,11 +17,11 @@ const DetailCarousel = () => {
});

if (isLoading) {
return <p>Loading...</p>;
return <ExceptLayout type="loading" />;
}

if (isError) {
return <p>Error</p>;
return <ExceptLayout type="networkError" />;
}

if (!data) {
Expand Down
12 changes: 8 additions & 4 deletions src/components/carousel/detailCarousel/DetailImage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import LargeEmptyImage from '@assets/images/img_gray_light_leaf_large.png';
import useNavigateTo from '@hooks/useNavigateTo';
import { useParams } from 'react-router-dom';

Expand All @@ -6,17 +7,16 @@ import NumberTag from './numberTag/NumberTag';

interface ImageItemProps {
id: number;
imgUrl: string;
imgUrl?: string;
currentNum: number;
totalNum: number;
totalNum?: number;
}

const ImageItem = ({ id, imgUrl, currentNum, totalNum }: ImageItemProps) => {
const { templestayId } = useParams();

const navigateToPhoto = useNavigateTo(`/detail/${templestayId}/photo`);

return (
return totalNum ? (
<div
role="button"
tabIndex={0}
Expand All @@ -33,6 +33,10 @@ const ImageItem = ({ id, imgUrl, currentNum, totalNum }: ImageItemProps) => {
<NumberTag currentNum={currentNum} totalNum={totalNum} />
</div>
</div>
) : (
<div className={styles.emptyImageContainer}>
<img src={LargeEmptyImage} alt="빈 이미지"></img>
</div>
);
};

Expand Down
11 changes: 11 additions & 0 deletions src/components/carousel/detailCarousel/detailCarousel.css.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import theme from '@styles/theme.css';
import { style } from '@vanilla-extract/css';

export const imageWrapper = style({
Expand Down Expand Up @@ -35,3 +36,13 @@ export const numberStyle = style({
right: '0.8rem',
zIndex: 2,
});

export const emptyImageContainer = style({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '21rem',
width: '33.5rem',
backgroundColor: theme.COLORS.gray2,
borderRadius: 4,
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Tag from '@components/common/tag/Tag';

interface numberTagProps {
currentNum: number;
totalNum: number;
currentNum?: number;
totalNum?: number;
}

const NumberTag = ({ currentNum, totalNum }: numberTagProps) => {
Expand Down
17 changes: 13 additions & 4 deletions src/components/carousel/popularCarousel/PopularCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import useGetRanking from '@apis/ranking';
import { useAddWishlist, useRemoveWishlist } from '@apis/wish';
import PopularCard from '@components/card/popularCard/PopularCard';
import CarouselIndex from '@components/carousel/popularCarousel/CarouselIndex';
import ExceptLayout from '@components/except/exceptLayout/ExceptLayout';
import useCarousel from '@hooks/useCarousel';
import { useQueryClient } from '@tanstack/react-query';
import registDragEvent from '@utils/registDragEvent';
Expand All @@ -10,7 +11,11 @@ import { useNavigate } from 'react-router-dom';

import * as styles from './popularCarousel.css';

const PopularCarousel = () => {
interface PopularCarouselProps {
onRequireLogin: () => void;
}

const PopularCarousel = ({ onRequireLogin }: PopularCarouselProps) => {
const userId = Number(localStorage.getItem('userId'));
const queryClient = useQueryClient();

Expand All @@ -28,16 +33,20 @@ const PopularCarousel = () => {
const navigate = useNavigate();

if (isLoading) {
return <p>Loading...</p>;
return <ExceptLayout type="loading" />;
}

if (isError) {
return <p>Error</p>;
return <ExceptLayout type="networkError" />;
}

const handleLikeToggle = (templestayId: number, liked: boolean) => {
const mutation = liked ? removeWishlistMutation : addWishlistMutation;
if (!userId) {
onRequireLogin();
return;
}

const mutation = liked ? removeWishlistMutation : addWishlistMutation;
mutation.mutate(
{ userId, templestayId },
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/button/buttonBar/buttonBar.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const buttonBarContainer = style({
bottom: 0,
left: '50%',
transform: 'translateX(-50%)',
zIndex: 999,
zIndex: 1,

display: 'flex',
alignItems: 'center',
Expand Down
8 changes: 7 additions & 1 deletion src/components/common/modal/modal.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const modalContainer = style({
alignItems: 'center',
gap: '2.8rem',
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',

width: '33.1rem',
height: '18.1rem',
Expand All @@ -21,10 +24,13 @@ export const modalBackdrop = style({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
top: 0,
left: 0,

zIndex: 3,
width: '100%',
height: '100vh',
height: 'calc(100% + 1.2rem)',
background: theme.COLORS.black60,

marginTop: '-1.2rem',
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/pageName/PageName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface PageNameProps {
isLiked?: boolean;
}

const PageName = ({ title, onRightClick, isLikeBtn = true, isLiked = false }: PageNameProps) => {
const PageName = ({ title, onRightClick, isLikeBtn = true, isLiked = true }: PageNameProps) => {
const handleToBack = useNavigateTo('/');

return (
Expand Down
1 change: 1 addition & 0 deletions src/components/templeDetail/naverMap/smallMap/SmallMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface MapDataProps {
const SmallMap = ({ detailAddress, latitude, longitude }: MapDataProps) => {
const copyToClipboard = () => {
navigator.clipboard.writeText(detailAddress);
alert('주소가 복사되었습니다.');
};

const { templestayId } = useParams();
Expand Down
Loading

0 comments on commit 667f370

Please sign in to comment.