Skip to content

Commit f1f3954

Browse files
Merge pull request #46 from dnd-side-project/feature/#41/mypage-settings
2 parents 08fc519 + 295536a commit f1f3954

29 files changed

+912
-83
lines changed

β€Žpackage.jsonβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dnd-13th-8-frontend",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.0.1",
55
"type": "module",
66
"engines": {
77
"node": "22.12.0"
@@ -36,6 +36,7 @@
3636
"embla-carousel": "^8.6.0",
3737
"embla-carousel-react": "^8.6.0",
3838
"framer-motion": "^12.23.12",
39+
"lottie-react": "^2.4.1",
3940
"react": "^19.1.0",
4041
"react-dom": "^19.1.0",
4142
"react-router-dom": "^7.8.0",

β€Žpnpm-lock.yamlβ€Ž

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsrc/App.tsxβ€Ž

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1+
import { useState, useEffect } from 'react'
2+
import { useLocation } from 'react-router-dom'
3+
14
import styled from 'styled-components'
25

36
import { AppRoutes } from '@app/routes/routes'
47

8+
import { routesConfig } from '@shared/config/routesConfig'
59
import { useDevice, type DeviceType } from '@shared/hooks/useDevice'
610
import { flexRowCenter } from '@shared/styles/mixins'
711
import NavBar, { NAV_HEIGHT } from '@shared/ui/NavBar'
812

13+
const LAYOUT_BOTTOM_GAP = 34
14+
915
const App = () => {
1016
const deviceType = useDevice()
17+
const location = useLocation()
18+
19+
const [isNavVisible, setIsNavVisible] = useState(true)
1120

1221
const LAYOUT_WIDTH = deviceType === 'mobile' ? 'clamp(320px, 100dvw, 430px)' : '375px'
13-
const LAYOUT_BOTTOM_GAP = 34
22+
23+
useEffect(() => {
24+
const { pathname } = location
25+
const currentRoute = routesConfig.find((route) => route.path === pathname)
26+
const shouldHideNav = currentRoute?.hideNav ?? false
27+
setIsNavVisible(!shouldHideNav)
28+
}, [location])
1429

1530
return (
1631
<MainLayout
1732
$deviceType={deviceType}
33+
$isNavVisible={isNavVisible}
1834
$layoutWidth={LAYOUT_WIDTH}
1935
$layoutBottomGap={LAYOUT_BOTTOM_GAP}
2036
>
2137
<AppRoutes />
22-
<NavContainer $layoutWidth={LAYOUT_WIDTH} $layoutBottomGap={LAYOUT_BOTTOM_GAP}>
23-
<NavBar />
24-
</NavContainer>
38+
{isNavVisible && (
39+
<NavContainer $layoutWidth={LAYOUT_WIDTH} $layoutBottomGap={LAYOUT_BOTTOM_GAP}>
40+
<NavBar />
41+
</NavContainer>
42+
)}
2543
</MainLayout>
2644
)
2745
}
@@ -30,12 +48,16 @@ export default App
3048

3149
const MainLayout = styled.main<{
3250
$deviceType: DeviceType
51+
$isNavVisible: boolean
3352
$layoutWidth: string
3453
$layoutBottomGap: number
3554
}>`
3655
position: relative;
3756
margin: 0 auto;
38-
padding: 0 20px ${({ $layoutBottomGap }) => NAV_HEIGHT + $layoutBottomGap}px 20px;
57+
padding: 0 20px
58+
${({ $isNavVisible, $layoutBottomGap }) =>
59+
$isNavVisible ? NAV_HEIGHT + $layoutBottomGap : '0'}px
60+
20px;
3961
width: ${({ $layoutWidth }) => $layoutWidth};
4062
min-height: 100dvh;
4163
overflow-x: hidden;

β€Žsrc/app/routes/routes.tsxβ€Ž

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
import { lazy, Suspense } from 'react'
1+
import { Suspense } from 'react'
22
import { Routes, Route } from 'react-router-dom'
33

4+
import { routesConfig } from '@shared/config/routesConfig'
45
import Loading from '@shared/ui/Loading'
56

67
import PrivateRoute from '@widgets/authGuard/PrivateRoute'
78

8-
const MyPage = lazy(() => import('@/pages/myPage/ui'))
9-
const HomePage = lazy(() => import('@/pages/homePage'))
10-
const SearchPage = lazy(() => import('@/pages/searchPage'))
11-
const SearchResultPage = lazy(() => import('@/pages/searchPage/SearchResultPage'))
9+
const PageLoading = () => <Loading isLoading width="100%" height="100%" />
1210

13-
export const AppRoutes = () => {
14-
return (
15-
<Suspense fallback={<Loading isLoading width="100%" height="100%" />}>
16-
<Routes>
17-
<Route path="/" element={<HomePage />} />
18-
<Route path="/search" element={<SearchPage />} />
19-
<Route path="/searchResult" element={<SearchResultPage />} />
20-
<Route
21-
path="/mypage/*"
22-
element={
23-
<PrivateRoute>
24-
<MyPage />
25-
</PrivateRoute>
26-
}
27-
/>
28-
</Routes>
11+
// 곡톡 Wrapper
12+
const withWrapper = (
13+
Component: React.ComponentType,
14+
isPrivate?: boolean,
15+
isNotSuspense?: boolean
16+
): React.ReactElement => {
17+
const element = isNotSuspense ? (
18+
<Component />
19+
) : (
20+
<Suspense fallback={<PageLoading />}>
21+
<Component />
2922
</Suspense>
3023
)
24+
return isPrivate ? <PrivateRoute>{element}</PrivateRoute> : element
3125
}
26+
27+
export const AppRoutes = () => (
28+
<Routes>
29+
{routesConfig.map(({ path, component: Component, isPrivate, isNotSuspense }) => (
30+
<Route key={path} path={path} element={withWrapper(Component, isPrivate, isNotSuspense)} />
31+
))}
32+
</Routes>
33+
)
Lines changed: 3 additions & 0 deletions
Loading

β€Žsrc/assets/icons/index.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export { default as Like } from './icn_like.svg?react'
1111
export { default as Cancel } from './icn_cancel.svg?react'
1212
export { default as Gear } from './icn_gear.svg?react'
1313
export { default as LeftArrow } from './icn_left_arrow.svg?react'
14+
export { default as RightArrow } from './icn_right_arrow.svg?react'
1415
export { default as Logo } from './icn_logo.svg?react'
1516
export { default as Notification } from './icn_notification.svg?react'
1617
export { default as Plus } from './icn_plus.svg?react'

β€Žsrc/assets/lottie/index.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as LoadingLottie } from './loading.json'

0 commit comments

Comments
Β (0)