From 22a836d0b565288dc963adbc3fbdcf2bdcf43a49 Mon Sep 17 00:00:00 2001 From: Jeremy <102432453+shackstack@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:50:38 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20YoutubeEmbed=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=EB=A1=9C=20iframe=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - key props 적용 --- .../components/YoutubeEmbed/YoutubeEmbed.tsx | 26 +++++++++++++++++++ .../src/components/YoutubeEmbed/index.tsx | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx create mode 100644 frontend/src/components/YoutubeEmbed/index.tsx diff --git a/frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx b/frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx new file mode 100644 index 000000000..19f78f7e2 --- /dev/null +++ b/frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx @@ -0,0 +1,26 @@ +import styled from 'styled-components'; +import { BORDER_RADIUS, paintSkeleton } from '~/styles/common'; + +interface YoutubeEmbedProps { + title: string; + pathParam: string; +} + +function YoutubeEmbed({ title, pathParam }: YoutubeEmbedProps) { + return ( + + ); +} + +export default YoutubeEmbed; + +const StyledVideo = styled.iframe` + ${paintSkeleton} + border-radius: ${BORDER_RADIUS.md}; +`; diff --git a/frontend/src/components/YoutubeEmbed/index.tsx b/frontend/src/components/YoutubeEmbed/index.tsx new file mode 100644 index 000000000..52a4a4af9 --- /dev/null +++ b/frontend/src/components/YoutubeEmbed/index.tsx @@ -0,0 +1,3 @@ +import YoutubeEmbed from './YoutubeEmbed'; + +export default YoutubeEmbed; From e7ed2f952920d5dd276031439f14ac061b886f29 Mon Sep 17 00:00:00 2001 From: Jeremy <102432453+shackstack@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:50:57 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20YoutubeEmbed=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../@common/VideoCarousel/VideoCarousel.tsx | 28 ++++--------------- .../DetailInformation.tsx | 12 +++----- .../RestaurantVideoList.tsx | 6 ++++ 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx b/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx index 56d5359d0..07931c692 100644 --- a/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx +++ b/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx @@ -1,9 +1,10 @@ import { styled } from 'styled-components'; import Slider from 'react-slick'; -import { BORDER_RADIUS, hideScrollBar, paintSkeleton } from '~/styles/common'; +import { hideScrollBar } from '~/styles/common'; import type { Video } from '~/@types/api.types'; import { VideoCarouselSettings } from '~/constants/carouselSettings'; import useMediaQuery from '~/hooks/useMediaQuery'; +import YoutubeEmbed from '~/components/YoutubeEmbed'; interface VideoCarouselProps { title: string; @@ -18,25 +19,15 @@ function VideoCarousel({ title, videos }: VideoCarouselProps) { {isMobile || videos.length <= 2 ? ( {videos.map(({ name, youtubeVideoKey }) => ( - + ))} ) : ( {videos.map(({ name, youtubeVideoKey }) => ( - - + + ))} @@ -59,15 +50,6 @@ const StyledVideoWrapper = styled.div` width: 100%; `; -const StyledVideo = styled.iframe` - ${paintSkeleton} - width: 352px; - max-width: 352px; - height: 196px; - - border-radius: ${BORDER_RADIUS.md}; -`; - const StyledVideoContainer = styled.div` display: flex; gap: 2rem; diff --git a/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx b/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx index 910d95a32..4f3cc8f35 100644 --- a/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx +++ b/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx @@ -10,6 +10,7 @@ import { getRestaurantDetail, getRestaurantVideo } from '~/api/restaurant'; import SuggestionButton from '~/components/SuggestionButton'; import Naver from '~/assets/icons/naver-place.svg'; +import YoutubeEmbed from '~/components/YoutubeEmbed'; interface DetailInformationProps { restaurantId: string; @@ -23,13 +24,13 @@ function DetailInformation({ restaurantId, celebId }: DetailInformationProps) { data: { celebs, category, phoneNumber, roadAddress, naverMapUrl }, } = useQuery({ queryKey: ['restaurantDetail', restaurantId, celebId], - queryFn: async () => getRestaurantDetail(restaurantId, celebId), + queryFn: () => getRestaurantDetail(restaurantId, celebId), suspense: true, }); const { data: restaurantVideo } = useQuery({ queryKey: ['restaurantVideo', restaurantId], - queryFn: async () => getRestaurantVideo(restaurantId), + queryFn: () => getRestaurantVideo(restaurantId), suspense: true, }); @@ -93,12 +94,7 @@ function DetailInformation({ restaurantId, celebId }: DetailInformationProps) {
영상으로 보기
-