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

[FE] refactor: 레이아웃 스타일 수정 #640

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 12 additions & 8 deletions frontend/src/components/Common/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ interface CarouselProps {
carouselList: CarouselChildren[];
}

const CAROUSEL_WIDTH = window.innerWidth;

const Carousel = ({ carouselList }: CarouselProps) => {
const extendedCarouselList = [...carouselList, carouselList[0]];
const [currentIndex, setCurrentIndex] = useState(0);

const CAROUSEL_WIDTH = window.innerWidth;

const showNextSlide = () => {
setCurrentIndex((prev) => (prev === carouselList.length ? 0 : prev + 1));
};
Expand All @@ -25,9 +25,16 @@ const Carousel = ({ carouselList }: CarouselProps) => {

return (
<CarouselContainer>
<CarouselWrapper currentIndex={currentIndex}>
<CarouselWrapper
style={{
transform: 'translateX(-' + currentIndex * CAROUSEL_WIDTH + 'px)',
transition: currentIndex === length - 1 ? '' : 'all 0.5s ease-in-out',
}}
>
{extendedCarouselList.map(({ id, children }) => (
<CarouselItem key={id}>{children}</CarouselItem>
<CarouselItem key={id} style={{ width: `${CAROUSEL_WIDTH}px` }}>
{children}
</CarouselItem>
))}
</CarouselWrapper>
</CarouselContainer>
Expand All @@ -44,13 +51,10 @@ const CarouselContainer = styled.div`
overflow: hidden;
`;

const CarouselWrapper = styled.ul<{ currentIndex: number }>`
const CarouselWrapper = styled.ul`
display: flex;
transform: ${({ currentIndex }) => 'translateX(-' + currentIndex * CAROUSEL_WIDTH + 'px)'};
transition: ${({ currentIndex }) => (currentIndex === length - 1 ? '' : 'all 0.5s ease-in-out')};
`;

const CarouselItem = styled.li`
width: ${CAROUSEL_WIDTH}px;
height: fit-content;
`;
4 changes: 2 additions & 2 deletions frontend/src/components/Common/CategoryItem/CategoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ImageWrapper = styled.div`
border-radius: 10px;
background: ${({ theme }) => theme.colors.white};

img {
& > img {
width: 100%;
height: auto;
object-fit: cover;
Expand All @@ -44,5 +44,5 @@ const ImageWrapper = styled.div`
const CategoryName = styled.p`
margin-top: 10px;
font-weight: 600;
font-size: 0.8rem;
font-size: ${({ theme }) => theme.fontSizes.xs};
`;
1 change: 0 additions & 1 deletion frontend/src/components/Layout/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const DefaultLayoutContainer = styled.div`
const MainWrapper = styled.main`
position: relative;
height: calc(100% - 120px);
padding: 0 20px;
overflow-x: hidden;
overflow-y: auto;
`;
2 changes: 1 addition & 1 deletion frontend/src/components/Layout/SimpleHeaderLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SimpleHeaderLayoutContainer = styled.div`
const MainWrapper = styled.main`
position: relative;
height: calc(100% - 120px);
padding: 20px;
padding: 20px 20px 0;
overflow-x: hidden;
overflow-y: auto;
`;
20 changes: 12 additions & 8 deletions frontend/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const HomePage = () => {
</Link>
</section>
<Spacing size={40} />
<section>
<SectionWrapper>
<Heading as="h2" size="xl">
카테고리
</Heading>
Expand All @@ -36,9 +36,9 @@ const HomePage = () => {
<CategoryList />
</Suspense>
<Spacing size={15} />
</section>
</SectionWrapper>
<Spacing size={40} />
<section>
<SectionWrapper>
<Heading as="h2" size="xl">
🍯 꿀조합 랭킹
</Heading>
Expand All @@ -48,9 +48,9 @@ const HomePage = () => {
<RecipeRankingList />
</Suspense>
</ErrorBoundary>
</section>
</SectionWrapper>
<Spacing size={36} />
<section>
<SectionWrapper>
<Heading as="h2" size="xl">
👑 상품 랭킹
</Heading>
Expand All @@ -60,9 +60,9 @@ const HomePage = () => {
<ProductRankingList isHomePage />
</Suspense>
</ErrorBoundary>
</section>
</SectionWrapper>
<Spacing size={36} />
<section>
<SectionWrapper>
<Heading as="h2" size="xl">
📝 리뷰 랭킹
</Heading>
Expand All @@ -72,7 +72,7 @@ const HomePage = () => {
<ReviewRankingList isHomePage />
</Suspense>
</ErrorBoundary>
</section>
</SectionWrapper>
<Spacing size={36} />
<ScrollButton />
</>
Expand All @@ -84,3 +84,7 @@ export default HomePage;
const Banner = styled.img`
width: 100%;
`;

const SectionWrapper = styled.section`
padding: 0 20px;
`;
9 changes: 7 additions & 2 deletions frontend/src/pages/MemberPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Spacing } from '@fun-eat/design-system';
import { useQueryErrorResetBoundary } from '@tanstack/react-query';
import { Suspense } from 'react';
import styled from 'styled-components';

import { ErrorBoundary, ErrorComponent, Loading, NavigableSectionTitle } from '@/components/Common';
import { MembersInfo, MemberReviewList, MemberRecipeList } from '@/components/Members';
Expand All @@ -10,7 +11,7 @@ const MemberPage = () => {
const { reset } = useQueryErrorResetBoundary();

return (
<>
<MemberPageContainer>
<Suspense fallback={<Loading />}>
<MembersInfo />
</Suspense>
Expand All @@ -30,8 +31,12 @@ const MemberPage = () => {
</Suspense>
</ErrorBoundary>
<Spacing size={40} />
</>
</MemberPageContainer>
);
};

export default MemberPage;

const MemberPageContainer = styled.div`
padding: 20px 20px 0;
`;
10 changes: 8 additions & 2 deletions frontend/src/pages/MemberRecipePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Spacing } from '@fun-eat/design-system';
import { useQueryErrorResetBoundary } from '@tanstack/react-query';
import { Suspense } from 'react';
import styled from 'styled-components';

import { ErrorBoundary, ErrorComponent, Loading, ScrollButton, SectionTitle } from '@/components/Common';
import { MemberRecipeList } from '@/components/Members';
Expand All @@ -9,7 +10,7 @@ const MemberRecipePage = () => {
const { reset } = useQueryErrorResetBoundary();

return (
<>
<MemberRecipePageContainer>
<SectionTitle name="내가 작성한 꿀조합" />
<Spacing size={18} />
<ErrorBoundary fallback={ErrorComponent} handleReset={reset}>
Expand All @@ -18,8 +19,13 @@ const MemberRecipePage = () => {
</Suspense>
</ErrorBoundary>
<ScrollButton />
</>
<Spacing size={40} />
</MemberRecipePageContainer>
);
};

export default MemberRecipePage;

const MemberRecipePageContainer = styled.div`
padding: 20px 20px 0;
`;
10 changes: 8 additions & 2 deletions frontend/src/pages/MemberReviewPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Spacing } from '@fun-eat/design-system';
import { useQueryErrorResetBoundary } from '@tanstack/react-query';
import { Suspense } from 'react';
import styled from 'styled-components';

import { ErrorBoundary, ErrorComponent, Loading, ScrollButton, SectionTitle } from '@/components/Common';
import { MemberReviewList } from '@/components/Members';
Expand All @@ -9,7 +10,7 @@ const MemberReviewPage = () => {
const { reset } = useQueryErrorResetBoundary();

return (
<>
<MemberReviewPageContainer>
<SectionTitle name="내가 작성한 리뷰" />
<Spacing size={18} />
<ErrorBoundary fallback={ErrorComponent} handleReset={reset}>
Expand All @@ -18,8 +19,13 @@ const MemberReviewPage = () => {
</Suspense>
</ErrorBoundary>
<ScrollButton />
</>
<Spacing size={40} />
</MemberReviewPageContainer>
);
};

export default MemberReviewPage;

const MemberReviewPageContainer = styled.div`
padding: 20px 20px 0;
`;
9 changes: 7 additions & 2 deletions frontend/src/pages/RecipeDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const RecipeDetailPage = () => {
const { id, images, title, content, author, products, totalPrice, favoriteCount, favorite, createdAt } = recipeDetail;

return (
<>
<RecipeDetailPageContainer>
<SectionTitle name={title} />
<Spacing size={24} />
{images.length > 0 ? (
Expand Down Expand Up @@ -65,12 +65,17 @@ const RecipeDetailPage = () => {
<RecipeContent size="lg" lineHeight="lg">
{content}
</RecipeContent>
</>
<Spacing size={40} />
</RecipeDetailPageContainer>
);
};

export default RecipeDetailPage;

const RecipeDetailPageContainer = styled.div`
padding: 20px 20px 0;
`;

const RecipeImageContainer = styled.ul`
display: flex;
flex-direction: column;
Expand Down
Loading