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

perf : 작성 페이지 성능 개선 #459

Merged
merged 12 commits into from
Jan 2, 2025
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/sample_icon.svg" />
<link rel="preconnect" href="https://www.bottler.store" />
<link rel="dns-prefetch" href="https://www.bottler.store" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="manifest" href="/manifest.json" />
<title>Bottler</title>
Expand Down
Binary file removed public/fonts/BagelFatOne-Regular.ttf
Binary file not shown.
Binary file added public/fonts/BagelFatOne-Regular.woff
Binary file not shown.
Binary file removed public/fonts/CookieRun Regular.ttf
Binary file not shown.
Binary file added public/fonts/CookieRun-Regular.woff
Binary file not shown.
Binary file removed public/fonts/Inter-VariableFont_opsz,wght.ttf
Binary file not shown.
Binary file added public/fonts/Inter-VariableFont_opsz_wght.woff
Binary file not shown.
Binary file added public/fonts/Pretendard-Regular.woff2
Binary file not shown.
Binary file removed public/fonts/PyeongChangPeace-Light.ttf
Binary file not shown.
Binary file added public/fonts/PyeongChangPeace-Light.woff
Binary file not shown.
Binary file removed public/fonts/Sagak-sagak.ttf
Binary file not shown.
Binary file added public/fonts/Sagak-sagak.woff
Binary file not shown.
20 changes: 13 additions & 7 deletions src/components/CreatLetterPage/LetterInput/LetterInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React from 'react';
import React, { useMemo } from 'react';

type LetterInputProps = {
value: string;
Expand All @@ -14,19 +14,25 @@ export const LetterInput = ({
setValue,
font,
placeholder,
maxLength
maxLength = undefined
}: LetterInputProps) => {
const inputClass = useMemo(
() =>
clsx(
`z-10 w-full bg-transparent border-none focus:border-none focus:outline-none text-wrap`,
font || 'font-sans'
),
[font]
);

return (
<>
<input
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder={placeholder}
className={clsx(
`z-10 w-full bg-transparent border-none focus:border-none focus:outline-none text-wrap`,
font ? font : 'font-sans'
)}
maxLength={maxLength || undefined}
className={inputClass}
maxLength={maxLength}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ReportButton } from '../../Report/ReportButton';
import { useParams, useNavigate, useLocation } from 'react-router-dom';
import { Label } from '@/components/Common/BottleLetter/Label/Label';
import { Loading } from '@/components/Common/Loading/Loading';
import { LetterLine } from '@/components/CreatLetterPage/LetterLine/LetterLine';

type KeywordLetterDetailProps = {
letterData: {
Expand Down Expand Up @@ -69,7 +70,7 @@ export const KeywordLetterDetail = ({
{reportBtn === 'received' && <ReportButton />}
</div>
<h1>{title}</h1>
<img src={'/to_line.f4c129e6.svg'} className="w-full" />
<LetterLine />

<div className="relative">
<TextArea value={content} font={font} isReadonly={true} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ReportButton } from '../../Report/ReportButton';
import { useLocation } from 'react-router-dom';
import { Label } from '@/components/Common/BottleLetter/Label/Label';
import { Loading } from '@/components/Common/Loading/Loading';
import { LetterLine } from '@/components/CreatLetterPage/LetterLine/LetterLine';

type MapLetterDetailProps = {
letterData: {
Expand Down Expand Up @@ -62,7 +63,7 @@ export const MapLetterArchieveDetail = ({
className="w-[15%] h-[15%] absolute top-[-7%] "
/>
<h1>{title}</h1>
<img src={'/to_line.f4c129e6.svg'} className="w-full" />
<LetterLine />

<div className="relative">
<TextArea value={content} font={font} isReadonly={true} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useParams, useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { ReportButton } from '../../Report/ReportButton';
import { Label } from '@/components/Common/BottleLetter/Label/Label';
import { LetterLine } from '@/components/CreatLetterPage/LetterLine/LetterLine';

type MapLetterDetailProps = {
letterData: {
Expand Down Expand Up @@ -102,7 +103,7 @@ export const MapLetterDetail = ({ letterData }: MapLetterDetailProps) => {

return (
<>
<div className="absolute top-8 right-16 cursor-pointer">
<div className="absolute cursor-pointer top-8 right-16">
<div className="flex">
<div className="w-8 -rotate-12">
<Label imgSrc={label} />
Expand All @@ -118,7 +119,7 @@ export const MapLetterDetail = ({ letterData }: MapLetterDetailProps) => {
className="w-[15%] h-[15%] absolute top-[-7%] "
/>
<h1>{title}</h1>
<img src={'/to_line.f4c129e6.svg'} className="w-full" />
<LetterLine />

<div className="relative">
<TextArea
Expand Down
24 changes: 17 additions & 7 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

@tailwind base;
@tailwind components;
@tailwind utilities;
Expand Down Expand Up @@ -67,35 +65,47 @@

@font-face {
font-family: 'BagelFatOne';
src: url('/fonts/BagelFatOne-Regular.ttf') format('truetype');
src: url('/fonts/BagelFatOne-Regular.woff') format('truetype');
font-display: swap;
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'Pretendard';
font-weight: 400;
font-display: swap;
src: url('Pretendard-Regular.woff2') format('woff2');
}

@font-face {
font-family: 'CookieRunRegular';
src: url('/fonts/CookieRun Regular.ttf') format('truetype');
src: url('/fonts/CookieRun Regular.woff') format('truetype');
font-display: swap;
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'InterVariableFont';
src: url('/fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
src: url('/fonts/Inter-VariableFont_opsz,wght.woff') format('truetype');
font-display: swap;
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'PyeongChangPeaceLight';
src: url('/fonts/PyeongChangPeace-Light.ttf') format('truetype');
src: url('/fonts/PyeongChangPeace-Light.woff') format('truetype');
font-display: swap;
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: 'Sagak-sagak';
src: url('/fonts/Sagak-sagak.ttf');
src: url('/fonts/Sagak-sagak.woff');
font-display: swap;
font-weight: normal;
font-style: normal;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/HomePage.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import { MemoryRouter } from 'react-router-dom';
import { HomePage } from './HomePage';
import HomePage from './HomePage';

const meta: Meta<typeof HomePage> = {
component: HomePage,
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type RecommendLetter = {
label: string;
};

export const HomePage = () => {
const HomePage = () => {
const { user } = useUserStore();
const { addToast } = useToastStore();

Expand Down Expand Up @@ -175,3 +175,5 @@ export const HomePage = () => {
</>
);
};

export default HomePage;
2 changes: 1 addition & 1 deletion src/pages/Letter/SelectItem/SelectItemPage.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import { MemoryRouter } from 'react-router-dom';
import { SelectItemPage } from './SelectItemPage';
import SelectItemPage from './SelectItemPage';

const meta: Meta<typeof SelectItemPage> = {
component: SelectItemPage,
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Letter/SelectItem/SelectItemPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SelectItem } from '@/components/SelectItemPage/SelectItem/SelectItem';
import React, { useCallback, useState } from 'react';
import { useNavigate } from 'react-router-dom';

export const SelectItemPage = () => {
const SelectItemPage = () => {
const navigate = useNavigate();
const [isActive, setIsActive] = useState(false);

Expand Down Expand Up @@ -35,3 +35,5 @@ export const SelectItemPage = () => {
</>
);
};

export default SelectItemPage;
4 changes: 2 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorPage } from '@/pages/ErrorPage';
import { HomePage } from '@/pages/Home/HomePage';
import HomePage from '@/pages/Home/HomePage';
import { CreateLetterPage } from '@/pages/Letter/Create/CreateLetterPage';
import { LoginPage } from '@/pages/User/Login/LoginPage';
import { RegisterPage } from '@/pages/User/Register/RegisterPage';
Expand All @@ -10,7 +10,7 @@ import { NotificationPage } from '@/pages/Notification/NotificationPage';
import { SentPage } from '@/pages/SentPage';
import { ProfileSharePage } from '@/pages/User/Profile/ProfileSharePage';
import { LabelLotteryPage } from './Label/Lottery/LabelLotteryPage';
import { SelectItemPage } from './Letter/SelectItem/SelectItemPage';
import SelectItemPage from './Letter/SelectItem/SelectItemPage';
import { MyPage } from '@/pages/User/MyPage/MyPage';
import { SuccessLetterPage } from './Letter/Success/SuccessLetterPage';
import { ProfilePage } from '@/pages/User/Profile/ProfilePage';
Expand Down
8 changes: 6 additions & 2 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createBrowserRouter, Outlet, Navigate } from 'react-router-dom';
import { NavigationBar } from '@/components/Common/NavigationBar/NavigationBar';
import {
ErrorPage,
HomePage,
CreateLetterPage,
MyPage,
LoginPage,
Expand All @@ -13,7 +12,6 @@ import {
SentPage,
ProfileSharePage,
LabelLotteryPage,
SelectItemPage,
SuccessLetterPage,
ProfilePage,
StoragePage,
Expand All @@ -22,11 +20,17 @@ import {
MapLetterArchieveDetailContainerPage,
KakaoRedirectPage
} from './pages';

const MapExplorerPage = lazy(() => import('@/pages/Map/MapExplorerPage'));
const HomePage = lazy(() => import('@/pages/Home/HomePage'));
const SelectItemPage = lazy(
() => import('@/pages/Letter/SelectItem/SelectItemPage')
);

import { tokenStorage } from './service/auth/tokenStorage';
import { AuthProvider } from './AuthProvider';
import { Container } from '@/components/Common/Container/Container';

import { CreateMapLetterPage } from './pages/Map/Create/CreateMapLetterPage';
import { MapSelectItemPage } from './pages/Map/Select/MapSelectItemPage';
import { ErrorBoundary } from './ErrorBoundary';
Expand Down
Loading