diff --git a/src/Router.tsx b/src/Router.tsx index 087917d..4192300 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -3,6 +3,7 @@ import Error from '@components/Error'; import Onboarding from '@pages/Onboarding'; import Search from '@pages/Search'; import App from './App'; +import Detail from '@pages/Detail'; export const router = createBrowserRouter([ { @@ -13,7 +14,13 @@ export const router = createBrowserRouter([ { index: true, element: }, { path: '/search', - element: , + children: [ + { + index: true, + element: , + }, + { path: ':title', element: }, + ], }, ], }, diff --git a/src/pages/Detail/index.tsx b/src/pages/Detail/index.tsx new file mode 100644 index 0000000..a2bbb30 --- /dev/null +++ b/src/pages/Detail/index.tsx @@ -0,0 +1,65 @@ +/** @jsxImportSource @emotion/react */ + +import { useParams } from 'react-router-dom'; +import useSWR from 'swr'; +import { fetcher } from '@utils/fetcher'; +import styled from '@emotion/styled'; +import { css } from '@emotion/react'; + +/** 상세 페이지 */ +export default function Detail() { + const { title } = useParams(); + const { data } = useSWR(`https://dapi.kakao.com/v3/search/book?query=${title}`, fetcher); + + return ( + + {data && ( + + book-cover +
+

{data[0].title}

+
+ {data[0].authors} + {data[0].publisher} + {data[0].price} +
+

{data[0].contents}

+
+
+ )} +
+ ); +} + +const mainTitle = css` + font-size: 3rem; + margin-bottom: 1rem; +`; + +const bookInfo = css` + display: flex; + gap: 3rem; + font-size: 1.4rem; + margin-bottom: 2rem; +`; + +const bookContent = css` + font-size: 2.4rem; +`; + +const DetailWrapper = styled.div` + width: 100%; + height: 100vh; + background-color: ${({ theme }) => theme.colors.bgColor}; + padding: 0 12rem; + margin: 0 auto; +`; + +const DetailBox = styled.div` + display: flex; + gap: 4.5rem; + max-width: 120rem; + margin: 50vh auto; + color: ${({ theme }) => theme.colors.textColor01}; + transform: translateY(-50%); +`; diff --git a/src/pages/Search/components/Books.tsx b/src/pages/Search/components/Books.tsx index 3037b5e..b529b72 100644 --- a/src/pages/Search/components/Books.tsx +++ b/src/pages/Search/components/Books.tsx @@ -1,24 +1,32 @@ +/** @jsxImportSource @emotion/react */ + +import { css } from '@emotion/react'; import styled from '@emotion/styled'; import { commonFlex } from '@styles/common'; +import { Link } from 'react-router-dom'; import { Book } from 'types/books'; export default function Books(props: Book) { const { authors, contents, title, thumbnail } = props; + return ( - - - - {title} - {authors} - {contents} - - +
+ + + + {title} + {authors} + {contents} + + +
); } -const Container = styled.article` +const bookLink = css` ${commonFlex} - gap: 4rem + gap: 4rem; + cursor: pointer; `; const BookImg = styled.img`