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

리펙토링 기간 중 진행한 변경 사항 #7

Open
wants to merge 43 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5ba1b1d
feat : 전체 레이아웃을 관리하는 layout 코드를 app 폴더로 분리
sunub Jan 9, 2025
39f5138
refactor : features 내부에 있던 코드들을 pages 코드로 맥락에 맞게 변경
sunub Jan 9, 2025
b068e7d
refactor : features 내부에 있던 코드들을 pages 코드로 맥락에 맞게 변경
sunub Jan 9, 2025
5eb56f6
feat : 네트워크 요청을 전역 상태를 이용하여 줄이기 위하여 Recoil 패키지 추가가
sunub Jan 14, 2025
c795ddd
feat : Recoil 추가 및 FSD 폴더 구조에 맞게끔 RouterProvider을 분리리
sunub Jan 14, 2025
f10ed42
feat : Recoil을 활용하여 전역에서 사용자의 로그인 유무, 닉네임의 정보를 상태를 관리할 수 있게끔 로직 수정
sunub Jan 14, 2025
1de2308
feat : Recoil를 활용하여 auth state를 관리하고 hook을 이용하여 상태 변경을 하게끔 로직 추가가
sunub Jan 14, 2025
30057ea
refactor : 불필요한 인증 확인 절차 제거거
sunub Jan 14, 2025
d9a285c
feat : Router 계층에서 사용자의 인가 정보를 확인하지 않고 Client 계층에서 확인 후 리다이렉트 하게 끔 로직 수정
sunub Jan 14, 2025
93c2bea
feat : 새로고침 시 서버로 부터 세션 정보를 갱신하여 전역에서 관리하는 Auth 데이터를 최신으로 유지할 수 있게 Pr…
sunub Jan 14, 2025
b5ab0e8
feat : ProtectedRoute 추가가
sunub Jan 14, 2025
e830b8e
feat : Test 라이브러리 추가
sunub Jan 16, 2025
d0f6d14
test : 인증 상태에 따른 리다이렉션에 대한 테스트 코드 추가
sunub Jan 16, 2025
2edc693
feat : playwright 설정 추가
sunub Jan 16, 2025
962d048
feat : 전역 상태인 Auth를 활용하여 인증 관리를 하게끔 로직 수정
sunub Jan 16, 2025
7d7fe65
refactor : 인증 과정에서 불필요한 병렬처리 과정 제거
sunub Jan 16, 2025
ded56ce
feat : 리다이렉트시 불필요한 검증 로직 제거 및 수정
sunub Jan 16, 2025
832f002
refactor : 테스트를 진행하기 위해 nav 버튼들에 id 추가
sunub Jan 16, 2025
f2d99b9
refactor : 불필요한 로그아웃 로직 수정 및 Hook으로 기능 분리
sunub Jan 16, 2025
3148810
refactor : test 폴더구조 수정
sunub Jan 16, 2025
e3495d9
refactor : vite에서 제공하는 빌드 성능 개선 플러그인을 설치 및 적용
sunub Jan 21, 2025
58df402
feat : cssnano를 이용하여 css 최소화 및 최적화
sunub Jan 21, 2025
4270893
feat : 이미지 포맷을 png에서 avif로 변경
sunub Jan 21, 2025
6b64eab
feat ; 현재 프로젝트의 코드의 크기, 구성, 구조를 파악할 수 있는 템플릿 추가
sunub Jan 21, 2025
ea2c66e
feat : Tanstack router dev tool 추가
sunub Jan 21, 2025
4e88520
feat : tanstack router devtool 추가
sunub Jan 21, 2025
beb3a4d
refactor : 불필요한 네트워크 요청과 렌더링 [>
sunub Jan 21, 2025
31bf3c2
fix : 아이디 입력 시 계속해서 네트워크 요청이 전송되던 문제 수정
sunub Jan 21, 2025
288594e
refactor : 바뀐 이미지 포맷에 따라 코드 수정
sunub Jan 21, 2025
2508407
feat : 별도의 query Key를 추가하여 하나에 묶여 있던 상태를 분리
sunub Jan 21, 2025
d9a7100
refactor : 데이터가 업데이트 되었을 경우 즉시 리다이렉트가 되지 않고 딜레이가 생기게끔 수정
sunub Jan 21, 2025
947c6b8
feat : 중복되는 코드를 커스텀 훅으로 관리하게끔 코드 추가
sunub Jan 21, 2025
4955123
refactor : 이미지 로드 방식 변경
sunub Jan 21, 2025
83cd118
refactor : 불필요한 컴포넌트 제거
sunub Jan 21, 2025
6d9db19
refactor : 리다이렉트시 데이터의 상태에 따라 지연 처리되게끔 수정
sunub Jan 21, 2025
8a1bb16
refactor : 상태 변화에 약간의 딜레이 추가
sunub Jan 21, 2025
14da81f
refactor : 이미지 로드 방식 변경
sunub Jan 21, 2025
9c0e8e0
feat : build시 코드 스플릿을 더 세분화가 필요한 패키지와 그렇지 않은 패키지를 적절하게 스플릿하게끔 수정정
sunub Jan 22, 2025
099bb9c
feat : SVGO를 이용하여 svg 파일 최적화 진행행
sunub Jan 22, 2025
a727ca3
refactor : 불필요한 렌더링을 막기 위해 코드를 분리하였지만 아직 문제를 개선하지 못함함
sunub Jan 22, 2025
7bf857c
Merge branch 'dev' into feature/1
stop0ho Jan 23, 2025
ebe00ae
refactor: 베팅 상세 정보 부분 컴포넌트로 분리
stop0ho Jan 23, 2025
7f6dde8
refactor: 기존에 있던 features 폴더 삭제
stop0ho Jan 23, 2025
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
27 changes: 27 additions & 0 deletions frontend/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ dist-ssr
.env.*.local
.env.*.production
*.local
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
14 changes: 4 additions & 10 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@
crossorigin="anonymous"
/>
<link
rel="preload"
href="/src/assets/images/pond.png"
rel="lazy"
href="/src/assets/images/waiting-user.avif"
as="image"
type="image/png"
/>
<link
rel="preload"
href="/src/assets/images/waiting-user.png"
as="image"
type="image/png"
/>
<link
rel="preload"
href="/src/assets/images/main-logo.png"
rel="lazy"
href="/src/assets/images/main-logo.avif"
as="image"
type="image/png"
/>
Expand Down
21 changes: 16 additions & 5 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview",
"test": "vitest"
"test": "vitest --watch"
},
"dependencies": {
"@betting-duck/shared": "workspace:*",
Expand All @@ -21,7 +21,7 @@
"@radix-ui/react-slot": "^1.1.0",
"@react-three/cannon": "^6.6.0",
"@react-three/drei": "^9.119.0",
"@react-three/fiber": "^8.17.10",
"@react-three/fiber": "^8.17.12",
"@tanstack/react-query": "^5.62.0",
"@tanstack/react-router": "^1.81.1",
"@types/three": "^0.170.0",
Expand All @@ -30,33 +30,44 @@
"framer-motion": "^11.12.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"recoil": "^0.7.7",
"socket.io-client": "^4.8.1",
"tailwind-merge": "^2.5.4",
"three": "^0.171.0"
"terser": "^5.37.0",
"three": "^0.172.0"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@playwright/test": "^1.49.1",
"@tanstack/router-cli": "^1.79.0",
"@tanstack/router-devtools": "^1.81.1",
"@tanstack/router-devtools": "^1.81.5",
"@tanstack/router-plugin": "^1.79.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.2.0",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"autoprefixer": "^10.4.20",
"cssnano": "^7.0.6",
"eslint": "^9.13.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.11.0",
"jsdom": "^26.0.0",
"msw": "^2.6.4",
"postcss": "^8.4.48",
"prettier": "^3.3.3",
"rollup-plugin-visualizer": "^5.14.0",
"sharp": "^0.33.5",
"tailwindcss": "^3.4.14",
"typescript": "~5.6.3",
"typescript-eslint": "^8.11.0",
"vite": "^5.4.10",
"vite-plugin-compression2": "^1.3.3",
"vite-plugin-image-optimizer": "^1.1.8",
"vite-tsconfig-paths": "^5.1.3",
"vitest": "^2.1.4"
"vitest": "^2.1.5"
},
"msw": {
"workerDirectory": [
Expand Down
56 changes: 56 additions & 0 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://127.0.0.1:3000",
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],

// webServer: {
// command: "pnpm run preview",
// url: "http://localhost:4173",
// reuseExistingServer: !process.env.CI,
// }
});
3 changes: 2 additions & 1 deletion frontend/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
...(process.env.NODE_ENV === "production" ? { cssnano: {} } : {}),
},
}
};
2 changes: 2 additions & 0 deletions frontend/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// vitest.setup.ts
import "@testing-library/react";
1 change: 1 addition & 0 deletions frontend/src/app/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Layout } from "./ui/Layout";
37 changes: 37 additions & 0 deletions frontend/src/app/layout/ui/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useLayout } from "@/shared/hooks/useLayout";
import { cn } from "@/shared/misc";
import { RootHeader } from "./RootHeader";
import { RootSideBar } from "./RootSidebar";
import { Suspense } from "react";
import { LoadingAnimation } from "@/shared/components/Loading";
import { useRecoilValue } from "recoil";
import { Auth } from "@/app/provider/RouterProvider/lib/auth";

const layoutStyles = {
default: "max-w-[520px]",
wide: "max-w-[1200px]",
} as const;

function Layout({ children }: { children: React.ReactNode }) {
const { layoutType } = useLayout();
const authData = useRecoilValue(Auth);

return (
<div
id="root-layout"
className={cn(
"layout",
`h-h-full ml-auto mr-auto grid max-h-[834px] w-full`,
layoutStyles[layoutType],
)}
>
<Suspense fallback={<LoadingAnimation />}>
<RootHeader nickname={authData.nickname ?? ""} />
<RootSideBar isAuthenticated={authData.isAuthenticated} />
</Suspense>
{children}
</div>
);
}

export { Layout };
46 changes: 46 additions & 0 deletions frontend/src/app/layout/ui/NavItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from "react";
import { createLink, LinkComponent, useLocation } from "@tanstack/react-router";

interface LinkComponentProps
extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
icon: React.ReactNode;
label: string;
}

const Link = React.forwardRef<HTMLAnchorElement, LinkComponentProps>(
({ icon, label, className, ...props }, ref) => {
const location = useLocation();
const isChecked = location.pathname.includes(label.split(" ")[0]);

return (
<a ref={ref} {...props} className="w-full">
<label htmlFor={`nav-item-${label}`} className={className}>
<input
id={`nav-item-${label}`}
type="radio"
name={"nav-item"}
value={label}
checked={isChecked}
disabled
/>
{icon}
<span className="font-nanum-eb text-xs">{label}</span>
</label>
</a>
);
},
);

const CreatedLinkComponent = createLink(Link);

const NavItem: LinkComponent<typeof Link> = (props) => {
return (
<CreatedLinkComponent
className="font-nanum-b flex cursor-pointer flex-col items-center gap-2 text-center"
preload="intent"
{...props}
/>
);
};

export { NavItem };
37 changes: 37 additions & 0 deletions frontend/src/app/layout/ui/RootHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { LogoIcon } from "@/shared/icons";
import { Image } from "@/shared/components/Image";
import waitingUserImage from "@assets/images/waiting-user.avif";
import { Link } from "@tanstack/react-router";

function UserInfo({ nickname }: { nickname: string }) {
return (
<div className="flex h-fit w-fit select-none items-center justify-end gap-3 p-4 font-bold">
<div>
<Image
src={waitingUserImage}
width={20}
height={15}
alt="대기 중인 사용자 이미지"
/>
</div>
{nickname}
</div>
);
}

function RootHeader({ nickname }: { nickname: string }) {
return (
<div className="header flex-start flex items-center justify-between gap-2 pl-[60px]">
<Link
to={"/"}
className="flex w-fit select-none flex-row items-center gap-2"
>
<LogoIcon />
<h1>Betting Duck</h1>
</Link>
{nickname ? <UserInfo nickname={nickname} /> : null}
</div>
);
}

export { RootHeader };
15 changes: 15 additions & 0 deletions frontend/src/app/layout/ui/RootSidebar.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.navigator {
content: "";
position: absolute;

top: 0;
left: 0;

width: 4px;
height: 46px;

background: #6e29da;
transition: transform 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);

transform: translateY(calc(48px * calc(1.5 * var(--navigator-position))));
}
Loading