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

[#412] [북카이브] 북카이브 페이지 (회원) #436

Merged
merged 6 commits into from
Nov 16, 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
31 changes: 8 additions & 23 deletions src/app/bookarchive/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,21 @@

import useMyProfileQuery from '@/queries/user/useMyProfileQuery';
import { isAuthed } from '@/utils/helpers';
import { Skeleton, Text, VStack } from '@chakra-ui/react';
import { Suspense } from 'react';
import useMounted from '@/hooks/useMounted';
import { BookArchiveForAuth, BookArchiveForUnAuth } from '@/ui/BookArchive';
import BookArchiveForAuth from '@/v1/bookArchive/BookArchiveForAuth';
import BookArchiveForUnAuth from '@/v1/bookArchive/BookArchiveForUnAuth';
import TopHeader from '@/ui/Base/TopHeader';

export default function BookArchivePage() {
return (
<VStack as="main" width="100%" spacing="2rem">
<VStack w="100%">
<Text
alignSelf="flex-start"
fontSize="2rem"
fontWeight="800"
color="main"
>
BookArchive
</Text>
</VStack>
<Suspense
fallback={
<VStack gap="3rem">
<Skeleton width="39rem" height="19.6rem" />
<Skeleton width="39rem" height="19.6rem" />
<Skeleton width="39rem" height="19.6rem" />
</VStack>
}
>
<div className="flex w-full flex-col gap-[1rem]">
<TopHeader pathname="/bookarchive"></TopHeader>
{/* TODO: 스켈레톤 컴포넌트로 교체 */}
<Suspense fallback={null}>
<Contents />
</Suspense>
</VStack>
</div>
Comment on lines +13 to +19
Copy link
Member

Choose a reason for hiding this comment

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

p3;

현재 Component/ContextProvider.tsx<Layout />부분이 새로 만든 레이아웃으로 교체되지 않았습니다
만약 그부분이 교체된다면 <TopHeader /> 컴포넌트와 감싸고 있는 <div>요소는 따로 필요하지 않을 것 같아요!

Copy link
Member Author

@minjongbaek minjongbaek Nov 12, 2023

Choose a reason for hiding this comment

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

@hanyugeon 혹시 이 부분이 오늘 스크럼 때 이야기 했던 내용과 연결되는 건가요? ContextProvider 에서 사용되는 Layout 컴포넌트가 교체되어야 한다는 말씀이신가요? 👀

Copy link
Member

Choose a reason for hiding this comment

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

@minjongbaek

ContextProvider 에서 사용되는 Layout 컴포넌트가 교체되어야 한다는 말씀이신가요? 👀

다시 검토해보니 아직 BottomNavigation에 BottomSheet를 띄우는 이벤트가 적용되지않아 부자연스러움이 있네요...!
나중에 새로운 이슈를 통해 일괄적으로 적용하는게 좋을 것 같아 보이네요.
이 부분은 나중에 수정해봅시다!!

Copy link
Member Author

Choose a reason for hiding this comment

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

@hanyugeon 확인했습니다. 다시 리뷰 부탁드려요~

Copy link
Member

Choose a reason for hiding this comment

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

@minjongbaek @hanyugeon

현재 Component/ContextProvider.tsx에 부분이 새로 만든 레이아웃으로 교체되지 않았습니다
만약 그부분이 교체된다면 <TopHeader /> 컴포넌트와 감싸고 있는 <div>요소는 따로 필요하지 않을 것 같아요!

재현님이 작업하신 Layout 컴포넌트TopHeader 컴포넌트가 포함되어있어서 해당 페이지에서는 제거하면 좋을 것 같다는 뜻으로 이해했어요!

그런데 문득.. layout에 TopHeader 컴포넌트가 포함되어있는게 어색한것 같기두 하네요..!! 모든 페이지에서 TopHeader가 노출되는 것이 아니기 때문에 매번 pathname을 비교해서 일부 페이지에서만 렌더링하는 것도 비효율적인 것 같다는 생각이 들어요. 혹시 이전에 이와 관련해서 이야기를 나눴던 적이 있을까요? 제가 놓친거라면 죄송해요..🥺

Copy link
Member Author

Choose a reason for hiding this comment

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

@gxxrxn @hanyugeon
아 재현님이 남긴 코멘트를 이제서야 제대로 이해한 것 같아요 😅
이전에 이야기 했을 때는 layout 에 TopHeader 컴포넌트를 포함하는 방향으로 작업하자고 했던 것 같아요. 이와 관련해서는 이번 주 회의 시간에 다시 이야기 해보는건 어떨까요? 👀

);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BookShelf from '@/v1/bookShelf/BookShelf';
import BookShelf from '@/v1/bookShelf/BookShelfCard';
import { Meta, StoryObj } from '@storybook/react';

const meta: Meta<typeof BookShelf> = {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/Base/TopHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const getHeaderLabel = (pathname: string) => {
const TopHeader = ({ pathname, children }: TopHeaderProps) => {
return (
<div className="flex w-full items-center justify-between pb-[0.8rem]">
<p className="text-xl font-bold text-main-900">
<h1 className="text-xl font-bold text-main-900">
{getHeaderLabel(pathname)}
</p>
</h1>
Comment on lines +27 to +29
Copy link
Member

Choose a reason for hiding this comment

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

너무 좋은데요?? 👍🏻

{children}
</div>
);
Expand Down
60 changes: 0 additions & 60 deletions src/ui/BookArchive/BookArchiveForAuth.tsx

This file was deleted.

31 changes: 0 additions & 31 deletions src/ui/BookArchive/BookArchiveForUnAuth.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/ui/BookArchive/index.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/v1/book/BookCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const BookCover = ({ src, title, size = 'medium' }: BookCoverProps) => {
const sizeClasses = getCoverSizeClasses(size);

return (
<span className={`relative ${sizeClasses}`}>
<div className={`relative ${sizeClasses}`}>
Copy link
Member Author

Choose a reason for hiding this comment

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

@gxxrxn 기존 코드에는 감싸는 요소가 <span /> 태그로 작성되어 있었는데 inline 요소를 사용하신 이유가 있을까요?

BookCover 컴포넌트가 display:inline 이기 때문에 사용하는 곳에서 크기를 명시적으로 정해줘야하는 문제가 있어서 <div /> 태그로 수정해두었어요. 👀

Copy link
Member

Choose a reason for hiding this comment

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

생각해보니 inline 요소에 크기 속성을 주고 있었군요..🫠 div 태그로 수정하면 좋을 것 같아요! 감사합니다! 👍🏻

<Image
src={src}
alt={title}
Expand All @@ -54,7 +54,7 @@ const BookCover = ({ src, title, size = 'medium' }: BookCoverProps) => {
className="object-fit rounded-[0.5rem] shadow-bookcover"
fill
/>
</span>
</div>
);
};

Expand Down
60 changes: 60 additions & 0 deletions src/v1/bookArchive/BookArchiveForAuth.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use client';

import useAuthRecommendedBooks from '@/queries/recommend/useAuthRecommendedBooks';
import useAuthRecommendedBookshelf from '@/queries/recommend/useAuthRecommendedBookshelf';
import { APIJobGroup } from '@/types/job';
import BookCover from '@/v1/book/BookCover';
import BookShelfCard from '@/v1/bookShelf/BookShelfCard';
import Link from 'next/link';

const BookArchiveForAuth = ({
userJobGroup,
}: {
userJobGroup: APIJobGroup['name'];
}) => {
const {
data: bookshelfData,
isSuccess: bookshelfIsSuccess,
isLoading: bookshelfIsLoading,
} = useAuthRecommendedBookshelf(userJobGroup);
const {
data: booksData,
isSuccess: booksIsSuccess,
isLoading: booksIsLoading,
} = useAuthRecommendedBooks(userJobGroup);

const isSuccess = bookshelfIsSuccess && booksIsSuccess;
const isLoading = bookshelfIsLoading && booksIsLoading;

if (isLoading) {
// TODO: 스켈레톤 컴포넌트로 교체
return null;
}

if (!isSuccess) return null;
if (!bookshelfData || !booksData) return null;

return (
<div className="flex w-full flex-col gap-[1.5rem] text-md font-bold">
<h2>👀 이런 책들이 많이 꽂혔어요</h2>
<ul className="flex gap-[1.5rem] overflow-auto">
{booksData.books.map(({ bookId, imageUrl, title }) => (
<li key={bookId} className="max-w-[9rem]">
<Link href={`/book/${bookId}`} className="flex flex-col gap-[1rem]">
<BookCover src={imageUrl} title={title} size="large" />
<span className="line-clamp-2 break-keep text-center text-xs font-normal leading-tight">
{title}
</span>
</Link>
</li>
))}
</ul>
<h2>🔥 인기 책장</h2>
{...bookshelfData.bookshelfResponses.map(bookShelf => (
<BookShelfCard key={bookShelf.bookshelfId} {...bookShelf} />
))}
</div>
);
};

export default BookArchiveForAuth;
25 changes: 25 additions & 0 deletions src/v1/bookArchive/BookArchiveForUnAuth.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use client';

import useUnAuthRecommendedBookshelfQuery from '@/queries/recommend/useUnAuthRecommendedBookshelfQuery';
import BookShelfCard from '@/v1/bookShelf/BookShelfCard';

const BookArchiveForUnAuth = () => {
const { data, isSuccess, isLoading } = useUnAuthRecommendedBookshelfQuery();

if (isLoading) {
// TODO: 스켈레톤 컴포넌트로 교체
return null;
}
if (!isSuccess) return null;

return (
<div className="flex w-full flex-col gap-[1.5rem] text-md font-bold">
<h2>🔥 인기 책장</h2>
{...data.bookshelfResponses.map(bookShelf => (
<BookShelfCard key={bookShelf.bookshelfId} {...bookShelf} />
))}
</div>
);
};

export default BookArchiveForUnAuth;
44 changes: 0 additions & 44 deletions src/v1/bookShelf/BookShelf.tsx

This file was deleted.

52 changes: 46 additions & 6 deletions src/v1/bookShelf/Book.tsx → src/v1/bookShelf/BookShelfCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
'use client';

import { APIBook } from '@/types/book';
import ColorThief from 'colorthief';
import Image from 'next/image';
import { APIBookshelf } from '@/types/bookshelf';
import { IconArrowRight, IconHeart } from '@public/icons';
import Link from 'next/link';
import Badge from '@/ui/Base/Badge';
import Image from 'next/image';
import { APIBook } from '@/types/book';
import { useState } from 'react';
import ColorThief from 'colorthief';

const BookShelf = ({
bookshelfId,
bookshelfName,
books,
likeCount,
}: APIBookshelf) => {
Comment on lines +10 to +15
Copy link
Member

Choose a reason for hiding this comment

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

comment;

현재 BookShelfCard 컴포넌트에 BookShelf, Book 컴포넌트가 한꺼번에 정의되어 사용되고 있습니다!

이후 북카이브 뿐만이 아닌 사용자 책장 페이지, 프로필 페이지에서도 사용하기 용이한 구조를 만들 수 있도록 고민해보아도 좋을 것 같아요!

마크업 및 API연동은 잘 구현해 주신것같아요! 고생하셨어요!!

Copy link
Member Author

Choose a reason for hiding this comment

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

@hanyugeon 재현님 의견에 동의해요. 북카이브와 책장 페이지에서 보여지는 모습이 미세하게 달라서 어떻게 추상화를 할 지 고민하다가 우선 작업 목적에 맞게끔 구현해두었어요.
다음 책장 페이지를 작업하게 된다면 의견 반영하도록 하겠습니다~

return (
<div className="relative rounded-[2rem] pb-[2.5rem] pt-[2rem] shadow-[0px_0px_10px_0px_#D1D1D1]">
<div className="absolute bottom-0 w-full">
<div className="h-[3rem] bg-[#F2ECDF] shadow-[0px_-3px_8px_0px_#F1F1F1_inset]" />
<div className="h-[1rem] rounded-b-[2rem] bg-[#F6F3EC] shadow-[0px_-1px_8px_-4.5px_#494949]" />
</div>
<div className="flex flex-col gap-[2.6rem] bg-white px-[2rem]">
<div className="flex flex-col gap-[1rem]">
<div className="flex items-center justify-between">
<div className="text-md font-bold">{bookshelfName}</div>
<Link href={`/bookshelf/${bookshelfId}`}>
<IconArrowRight width="1.8rem" height="1.8rem" />
</Link>
</div>
<Badge colorScheme="red" fontWeight="bold" size="small">
<div className="flex items-center gap-[0.4rem]">
<IconHeart fill="white" height="1.3rem" w="1.3rem" />
<div className="bold text-xs">{likeCount}</div>
</div>
</Badge>
</div>
<ul className="flex justify-between px-[0.5rem]">
{books.map(book => (
<li key={book.bookId} className="flex">
<Book {...book} />
</li>
))}
</ul>
</div>
</div>
);
};

const Book = ({
imageUrl,
Expand Down Expand Up @@ -64,4 +104,4 @@ const Book = ({
);
};

export default Book;
export default BookShelf;