Skip to content

Commit 13f015d

Browse files
authored
Merge pull request #332 from CodIN-INU/style/top-element
style: click easily floor topNav on mobile
2 parents 2af98bb + 5123e5a commit 13f015d

3 files changed

Lines changed: 50 additions & 15 deletions

File tree

src/app/(auth-required)/boards/page.tsx

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ const mapPostCategoryToBoardPath = (postCategory: string): string | null => {
2626
const timeAgo = (timestamp: string): string => {
2727
const now = new Date();
2828
const createdAt = new Date(timestamp);
29-
const diffInSeconds = Math.floor((now.getTime() - createdAt.getTime()) / 1000);
29+
const diffInSeconds = Math.floor(
30+
(now.getTime() - createdAt.getTime()) / 1000
31+
);
3032
if (diffInSeconds < 60) return '방금 전';
3133
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}분 전`;
32-
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}시간 전`;
34+
if (diffInSeconds < 86400)
35+
return `${Math.floor(diffInSeconds / 3600)}시간 전`;
3336
return `${Math.floor(diffInSeconds / 86400)}일 전`;
3437
};
3538

@@ -139,12 +142,19 @@ export default function Board() {
139142

140143
return (
141144
<>
142-
<Header showBack title="커뮤니티" tempBackOnClick="/main"/>
145+
<Header
146+
showBack
147+
title="커뮤니티"
148+
tempBackOnClick="/main"
149+
/>
143150
<DefaultBody hasHeader={1}>
144151
{/* 🔎 검색 바: sticky + form submit */}
145-
<form onSubmit={handleSearch} className=' bg-white fixed top-[80px]
146-
left-1/2 -translate-x-1/2 right-0 z-50 w-full max-w-[410px] '>
147-
<div className="fixed top-[0px] flex relative justify-center items-center bg-[#F9F9F9] w-full h-[46px] px-[20px] rounded-[14px] shadow-[0px_6px_7.2px_#B6B6B64D] gap-[16px] z-[60]">
152+
<form
153+
onSubmit={handleSearch}
154+
className=" bg-white fixed top-[80px]
155+
left-1/2 -translate-x-1/2 right-0 z-50 w-full max-w-[410px] "
156+
>
157+
<div className="fixed pt-[3px] top-[-3px] flex relative justify-center items-center bg-[#F9F9F9] w-full h-[46px] px-[20px] rounded-[14px] shadow-[0px_6px_7.2px_#B6B6B64D] gap-[16px] z-[60]">
148158
<input
149159
type="text"
150160
className="w-full px-[20px] text-[13px] bg-transparent placeholder:text-[#CDCDCD] outline-none"
@@ -158,7 +168,10 @@ export default function Board() {
158168
className="cursor-pointer"
159169
aria-label="검색"
160170
>
161-
<Search width={20} height={20} />
171+
<Search
172+
width={20}
173+
height={20}
174+
/>
162175
</button>
163176
</div>
164177
</form>
@@ -167,12 +180,18 @@ export default function Board() {
167180
{isSearching ? (
168181
<>
169182
{/* 검색 결과 목록 */}
170-
<div className='mt-[50px]'>
171-
<PostList posts={posts} boardName="search" boardType="listWithCategory" />
183+
<div className="mt-[50px]">
184+
<PostList
185+
posts={posts}
186+
boardName="search"
187+
boardType="listWithCategory"
188+
/>
172189
</div>
173190
{/* 로딩 상태 표시 */}
174191
{isLoading && (
175-
<div className="text-center my-[18px] text-sub text-Lm">검색 중...</div>
192+
<div className="text-center my-[18px] text-sub text-Lm">
193+
검색 중...
194+
</div>
176195
)}
177196

178197
{/* 검색 결과가 없을 때 표시 */}
@@ -186,7 +205,10 @@ export default function Board() {
186205
<>
187206
{/* 기본 섹션들 */}
188207
<ShadowBox className="px-[15px] py-[1px] mt-[70px]">
189-
<Link href={'/boards/need-help'} className="flex items-center py-[15px]">
208+
<Link
209+
href={'/boards/need-help'}
210+
className="flex items-center py-[15px]"
211+
>
190212
<div className="flex justify-center items-center w-[48px] aspect-square rounded-full shadow-05134">
191213
<NeedHelp />
192214
</div>
@@ -198,7 +220,10 @@ export default function Board() {
198220
</div>
199221
</Link>
200222
<hr />
201-
<Link href={'/boards/communicate'} className="flex items-center py-[15px]">
223+
<Link
224+
href={'/boards/communicate'}
225+
className="flex items-center py-[15px]"
226+
>
202227
<div className="flex justify-center items-center w-[48px] aspect-square rounded-full shadow-05134">
203228
<Communicate />
204229
</div>
@@ -210,7 +235,10 @@ export default function Board() {
210235
</div>
211236
</Link>
212237
<hr />
213-
<Link href={'/vote'} className="flex items-center py-[15px]">
238+
<Link
239+
href={'/vote'}
240+
className="flex items-center py-[15px]"
241+
>
214242
<div className="flex justify-center items-center w-[48px] aspect-square rounded-full shadow-05134">
215243
<Vote />
216244
</div>
@@ -237,7 +265,9 @@ export default function Board() {
237265
<p className="text-center text-sub">{error}</p>
238266
) : rankingPosts.length > 0 ? (
239267
rankingPosts.map((post, index) => {
240-
const boardPath = mapPostCategoryToBoardPath(post.postCategory);
268+
const boardPath = mapPostCategoryToBoardPath(
269+
post.postCategory
270+
);
241271
return boardPath ? (
242272
<Link
243273
key={index}
@@ -300,7 +330,9 @@ export default function Board() {
300330
})
301331
) : (
302332
<>
303-
<p className="text-center text-gray-500">게시물이 없습니다.</p>
333+
<p className="text-center text-gray-500">
334+
게시물이 없습니다.
335+
</p>
304336
</>
305337
)}
306338
</div>

src/components/Layout/Navigation/topNav.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function TopNav({
2626
<Link
2727
key={item.path}
2828
href={`${item.path}${item.params ? item.params : ''}`}
29+
className="min-w-[55px]"
2930
>
3031
<div
3132
className={clsx(

src/middleware.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const PUBLIC_PATHS = [
99
/^\/main/,
1010
/^\/vote/,
1111
/^\/test/,
12+
/^\/vote/,
1213
/^\/.*\.(?:js|css|png|jpg|svg|ico)$/, // 정적 자산
1314
];
1415

@@ -32,6 +33,7 @@ export default function middleware(req: NextRequest) {
3233

3334
if (!access && !isPublic(pathname)) {
3435
// 원래 가려던 경로를 next에 실어 로그인으로
36+
console.log('[MIDDLEWARE] 인증 필요 - 로그인 페이지로 리다이렉트');
3537
const loginUrl = new URL('/login', req.url);
3638
const returnTo = pathname + search;
3739
loginUrl.searchParams.set('next', returnTo);

0 commit comments

Comments
 (0)