Skip to content

Commit

Permalink
Revert "[#632] 사용하지 않는 라이브러리 제거 (#633)"
Browse files Browse the repository at this point in the history
This reverts commit 34b4efb.
  • Loading branch information
gxxrxn authored Aug 20, 2024
1 parent 604253e commit 3129c7d
Show file tree
Hide file tree
Showing 46 changed files with 3,358 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const config: StorybookConfig = {
docs: {
autodocs: 'tag',
},
refs: {
'@chakra-ui/react': {
disable: true,
},
},
webpackFinal: async config => {
const imageRule = config.module?.rules?.find(rule => {
const test = (rule as { test: RegExp }).test;
Expand Down
1 change: 1 addition & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { initialize, mswLoader } from 'msw-storybook-addon';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { Preview } from '@storybook/react';

import Layout from '../src/v1/layout/Layout';
import ToastProvider from '../src/v1/base/Toast/ToastProvider';

import '@/styles/global.css';
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"@chakra-ui/icons": "^2.0.17",
"@chakra-ui/react": "^2.4.9",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@headlessui/react": "^1.7.15",
"@tanstack/react-query": "^4.24.4",
"@tanstack/react-query-devtools": "^4.24.12",
Expand All @@ -26,12 +30,14 @@
"@types/react-dom": "18.0.10",
"axios": "^1.3.4",
"colorthief": "^2.4.0",
"framer-motion": "^9.0.2",
"next": "13.4.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "^3.1.4",
"react-hook-form": "^7.43.2",
"react-intersection-observer": "^9.4.3"
"react-intersection-observer": "^9.4.3",
"recoil": "^0.7.7"
},
"devDependencies": {
"@babel/core": "^7.22.8",
Expand Down
1 change: 1 addition & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const metadata: Metadata = {
const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang="ko">
{/* @todo Chakra 제거시 app-layout 프로퍼티 제거. */}
<body className={`${LineSeedKR.variable} app-layout font-lineseed`}>
<Layout>
<ContextProvider>
Expand Down
13 changes: 13 additions & 0 deletions src/components/ChakraThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import theme from '@/styles/theme';
import { ChakraProvider } from '@chakra-ui/react';
import { NextPage } from 'next/types';

interface PropTypes {
children: React.ReactNode;
}

const ChakraThemeProvider: NextPage<PropTypes> = ({ children }) => {
return <ChakraProvider theme={theme}>{children}</ChakraProvider>;
};

export default ChakraThemeProvider;
12 changes: 9 additions & 3 deletions src/components/ContextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
'use client';

import { ReactNode } from 'react';
import { RecoilRoot } from 'recoil';

import PWAServiceWorkerProvider from '@/components/PWAServiceWorkerProvider';
import ChakraThemeProvider from '@/components/ChakraThemeProvider';
import ReactQueryProvider from '@/components/ReactQueryProvider';

import ToastProvider from '@/v1/base/Toast/ToastProvider';

const ContextProvider = ({ children }: { children: ReactNode }) => {
return (
<PWAServiceWorkerProvider>
<ReactQueryProvider>
<ToastProvider>{children}</ToastProvider>
</ReactQueryProvider>
<RecoilRoot>
<ReactQueryProvider>
<ChakraThemeProvider>
<ToastProvider>{children}</ToastProvider>
</ChakraThemeProvider>
</ReactQueryProvider>
</RecoilRoot>
</PWAServiceWorkerProvider>
);
};
Expand Down
10 changes: 1 addition & 9 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,16 @@
html {
@apply w-full bg-background font-[LineSeedKR] text-[62.5%] text-black-700;
-webkit-tap-highlight-color: #ffffff50;

/** from charka */
-webkit-text-size-adjust: 100%;
font-family: system-ui, sans-serif;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
touch-action: manipulation;
}

body {
font-size: 1.6rem;
}

.app-layout {
/* TODO: Chakra UI 걷어내면 제거 */
max-width: 43rem;
margin: 0 auto;
@apply bg-white;
}

.sticky {
Expand Down
115 changes: 115 additions & 0 deletions src/styles/theme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import {
ChakraStyledOptions,
extendTheme,
ThemeOverride,
} from '@chakra-ui/react';

const fontSizes = {
xs: '1.2rem',
sm: '1.4rem',
md: '1.6rem',
lg: '1.8rem',
xl: '2rem',
'2xl': '2.2rem',
} as const;

const buttonSizes = {
md: {
padding: '1.3rem 1rem',
height: '3.5rem',
},
lg: {
padding: '2.5rem 1.8rem',
height: '4.5rem',
},
} as const;

const colors = {
main: '#F6AD55', // Main Theme
red: {
800: '#F56565', // button (NoticeTheme)
900: '#FF0000', // validation (NoticeTheme)
},
yellow: {
200: '#FFD4802E',
900: '#FFA436',
},
black: {
400: '#C1C0C0', // subHeader (Slider)
500: '#AFAFAF', // placeHolder (BookSearch)
600: '#ACACAC', // placeHolder (MeetingEdit)
700: '#727272', // subHeader (MeetingDetail)
800: '#3D3D3D', // meetingPeriod (MeetingDetail)
900: '#000000', // black
},
white: {
400: '#CFCFCF', // placeHolder (MyPage)
500: '#D9D9D9', // addBook (MeetingCreate)
600: '#E3E3E3', // bookBorder (Bookaive)
700: '#E2E8F0', // inputBorder (Common)
800: '#FAFAFA', // backGround
900: '#FFFFFF', // white
},
kakao: {
brown: '#191600',
yellow: '#fee102',
},
} as const;

interface SchemeTypings {
component: 'button';
colorScheme: 'orange' | 'kakao' | 'orange-fill' | 'grey' | 'grey-fill';
cssProps: ChakraStyledOptions;
}

const scheme: Record<
SchemeTypings['component'],
Record<SchemeTypings['colorScheme'], Partial<SchemeTypings['cssProps']>>
> = {
button: {
orange: {
color: colors.main,
border: `${colors.main} 0.1rem solid`,
},
'orange-fill': {
color: colors.white[900],
backgroundColor: colors.main,
_hover: {
opacity: 0.8,
},
},
grey: {
color: colors.black[900],
border: `${colors.white[400]} 0.1rem solid`,
backgroundColor: colors.white[900],
_hover: {
color: colors.black['800'],
backgroundColor: colors.white[400],
},
},
'grey-fill': {
color: colors.black[600],
backgroundColor: colors.white[400],
},
kakao: {
color: colors.kakao.brown,
backgroundColor: colors.kakao.yellow,
},
},
};

const shadows = {
default: '0px 0px 7px -5px #000000', // BoxShadow (MeetingList Box)
};

const theme: ThemeOverride = extendTheme({
fontSizes,
buttonSizes,
colors,
scheme,
shadows,
});

export default theme;

export type ChakraTheme = typeof theme;
148 changes: 148 additions & 0 deletions src/ui/BookDetail/BookInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import {
Avatar,
AvatarGroup,
Box,
Flex,
Text,
useDisclosure,
useTheme,
VStack,
} from '@chakra-ui/react';
import Image from 'next/image';

import IconButton from '@/ui/common/IconButton';

import type { APIBookDetail, APIBookmarkedUserList } from '@/types/book';
import Link from 'next/link';

import { checkAuthentication } from '@/utils/helpers';
import { useState } from 'react';
import LoginBottomSheet from '../LoginBottomSheet';

type Props = Pick<
APIBookDetail,
'title' | 'author' | 'contents' | 'imageUrl' | 'url'
> &
Omit<APIBookmarkedUserList, 'bookId'> & {
onBookmarkClick: (isBookMarked: boolean) => void;
};

const BookInfo = ({
title,
author,
contents,
imageUrl,
url: contentsUrl,
onBookmarkClick,
...bookmarkInfo
}: Props) => {
const isAuthenticated = checkAuthentication();
const theme = useTheme();
const [bookmark, setBookmark] = useState(bookmarkInfo.isInMyBookshelf);

const {
isOpen: isLoginBottomSheetOpen,
onOpen: onLoginBottomSheetOpen,
onClose: onLoginBottomSheetsClose,
} = useDisclosure();

const handleBookmarkClick = () => {
if (!isAuthenticated) {
onLoginBottomSheetOpen();
return;
}

setBookmark(prev => {
const next = !prev;
onBookmarkClick(next);
return next;
});
};

return (
<>
<Flex gap="2rem" align="flex-end">
<Box
shadow="lg"
position="relative"
width="18rem"
height="24rem"
flexShrink={0}
>
<Image
src={imageUrl.replace('R120x174.q85', 'R300x0.q100')}
alt="book"
fill
sizes="300px"
/>
</Box>
<VStack align="flex-start">
<IconButton
name="bookmark-legacy"
color={theme.colors.main}
strokeWidth="0.15rem"
onClick={handleBookmarkClick}
fill={bookmark}
mb="0.5rem"
ml="-0.1rem"
/>
<Text fontSize="lg" fontWeight="bold">
{title}
</Text>
<Text fontSize="sm">{author}</Text>
</VStack>
</Flex>
<Text fontSize="md">
{contents}&nbsp;...&nbsp;
{contentsUrl && (
<Text
as={Link}
href={contentsUrl}
color="main"
target="_blank"
rel="noopener noreferrer"
>
더보기
</Text>
)}
</Text>

{!isAuthenticated && (
<LoginBottomSheet
isOpen={isLoginBottomSheetOpen}
onClose={onLoginBottomSheetsClose}
/>
)}

<Flex align="center" minH="2rem">
<AvatarGroup>
{bookmarkInfo.users.map(({ userId, profileImage }) => (
<Avatar
as={Link}
href={`/profile/${userId}`}
key={userId}
src={profileImage}
/>
))}
</AvatarGroup>
<Text fontSize="sm" pl="0.8rem">
{getUserInfoText(bookmarkInfo.totalCount, bookmarkInfo.users.length)}
</Text>
</Flex>
</>
);
};

const getUserInfoText = (totalCount: number, avatarCount: number) => {
const otherCount = totalCount - avatarCount;

if (otherCount === 0 && totalCount === 0) {
return '아직 이 책을 책장에 꽂은 사람이 없어요.';
} else if (otherCount === 0) {
return '님이 이 책을 책장에 꽂았어요.';
}

return `외 ${otherCount}명이 이 책을 책장에 꽂았어요.`;
};

export default BookInfo;
Loading

0 comments on commit 3129c7d

Please sign in to comment.