해결된 질문
작성
·
98
0
안녕하세요 선생님 ㅎ
channel쪽 진행하고 있었는데 앨범 밑에 PlayListCarousel이
크기가 이상하게 나오네여 ㅠㅠ 코드를 다똑같이 써도 안되서 질문드립니다!
channel/[id]/page.tsx
import HeaderBgChanger from "@/components/HeaderBgChanger";
import PagePadding from "@/components/PagePadding";
import PlayListCarousel from "@/components/PlayListCarousel";
import SongCardRowExpand from "@/components/SongCardRowExpand";
import DarkButton from "@/components/elements/DarkButton";
import WhiteButton from "@/components/elements/WhiteButton";
import { getChannelById } from "@/lib/dummyData";
import { getRandomElementFromArray } from "@/lib/utils";
import { permanentRedirect } from "next/navigation";
import React from "react";
import { FiMusic, FiShuffle } from "react-icons/fi";
interface ChannelPageProps {
params: {
id: string;
};
}
const page = async (props: ChannelPageProps) => {
const channel = await getChannelById(Number(props.params.id));
if (!channel) permanentRedirect("/");
const imageSrc = getRandomElementFromArray(channel.songList)?.imageSrc;
return (
<PagePadding>
<HeaderBgChanger imageSrc={imageSrc} />
<div className="mt-[150px]"></div>
<section>
<div className=" text-[28px] font-bold">{channel.name}</div>
<article className="mt-4 lg:hidden">
<div>
<DarkButton
className={"w-[230px] flex justify-center"}
label={"구독중 99만"}
/>
</div>
<div className="flex flex-row gap-4 mt-4">
<WhiteButton
label={"셔플"}
icon={<FiShuffle size={16}></FiShuffle>}
/>
<WhiteButton label={"뮤직 스테이션"} icon={<FiMusic size={16} />} />
</div>
</article>
<div className="hidden lg:flex flex-row items-center gap-4 text-[14px] mt-4">
<WhiteButton
label={"셔플"}
icon={<FiShuffle size={16}></FiShuffle>}
/>
<WhiteButton label={"뮤직 스테이션"} icon={<FiMusic size={16} />} />
<DarkButton
className={"w-[230px] flex justify-center"}
label={"구독중 99만"}
/>
</div>
</section>
<section className="mt-[80px]">
<div className=" text-[28px] font-bold">노래</div>
<div className="mt-[20px]">
<ul className="flex flex-col gap-2">
{channel.songList.map((song, key) => {
return <SongCardRowExpand song={song} key={key} />;
})}
</ul>
</div>
</section>
<section className="mt-[80px]">
<div className=" text-[28px] font-bold">앨범</div>
<PlayListCarousel playlistArray={channel.playlistArray} />
</section>
<section className="mt-[80px]"></section>
</PagePadding>
);
};
export default page;
PlayListCarousel.tsx
import { Playlist } from "@/types";
import React from "react";
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel";
import PlayListCard from "./PlayListCard";
interface PlayListCarouselProps {
title?: string;
subTitle?: string;
Thumbnail?: React.ReactNode;
playlistArray?: Playlist[];
}
const PlayListCarousel: React.FC<PlayListCarouselProps> = ({
title,
subTitle,
Thumbnail,
playlistArray,
}) => {
return (
<div className="w-full">
<Carousel>
<div className="flex flex-row justify-between items-end my-2">
<article className="flex flex-row gap-3">
{Thumbnail}
<div className="flex flex-col justify-center">
<div>
{subTitle && (
<div className=" text-neutral-500">{subTitle}</div>
)}
</div>
<div className="text-[34px] font-bold leading-[34px] ">
{title}
</div>
</div>
</article>
<div className="relative left-[-45px]">
<div className="absolute bottom-[20px]">
<CarouselPrevious className="right-2" />
<CarouselNext className=" left-2" />
</div>
</div>
</div>
<CarouselContent className="mt-4">
{playlistArray?.map((playlist, index) => {
return (
<CarouselItem
key={index}
className="basis-1/2 md:basis-1/3 lg:basis-1/4 xl:basis-1/5"
>
<PlayListCard playlist={playlist} />
</CarouselItem>
);
})}
</CarouselContent>
</Carousel>
</div>
);
};
export default PlayListCarousel;
답변 1
1
안녕하세요.!
UI화면을 보니, 상위 컴포넌트의 너비값에 문제가 있는것 같습니다.
1.아래 컴포넌트를 살펴보면서 디버깅을 해주세요.!
https://github.com/dodokyo/yt-music-clone/blob/main/components/PagePadding.jsx
https://github.com/dodokyo/yt-music-clone/blob/main/app/channel/%5Bid%5D/layout.tsx
높은 확률로 layout 컴포넌트에서 w-full 이 빠졌을까 예측해봅니다.
2.크롬 개발자 도구를 통해서 어떤 요소에서 너비가 줄어들었는지 알면 좋습니다.
확인 결과
layout
pagepadding
코드에서 이상은 없는데
2.지금 개발자 도구를 통해서 보고있는데 테일윈드라 가독성이 좀 떨어져서 오래걸리네여 ㅠㅠ