Skip to content

Commit 95b63c9

Browse files
authored
Merge pull request #48 from geulDa/feat/#42/main-page-layout
Feat: main page layout 작업
2 parents cc8be68 + 204b3e8 commit 95b63c9

File tree

8 files changed

+105
-23
lines changed

8 files changed

+105
-23
lines changed

public/assets/bannerMain.svg

Lines changed: 23 additions & 0 deletions
Loading

public/assets/board.svg

Lines changed: 9 additions & 0 deletions
Loading

src/pages/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { ControlBar, Header, Tag } from '@/shared/components';
21
import { Icon } from '@/shared/icons';
3-
import Progress from './main/components/stampBoard/Progress';
42
import StampBoard from './main/components/stampBoard/StampBoard';
53

64
export default function Home() {

src/pages/main/components/stampBoard/Progress.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use client';
2+
13
import * as ProgressPrimitive from '@radix-ui/react-progress';
24
import { cn } from '@/shared/lib';
35

@@ -9,11 +11,7 @@ export interface ProgressProps
911
value: number;
1012
}
1113

12-
export default function Progress({
13-
className,
14-
value,
15-
...props
16-
}: ProgressProps) {
14+
const Progress = ({ className, value, ...props }: ProgressProps) => {
1715
const progressPercent = Math.max(0, Math.min(100, value));
1816

1917
return (
@@ -39,4 +37,6 @@ export default function Progress({
3937
/>
4038
</ProgressPrimitive.Root>
4139
);
42-
}
40+
};
41+
42+
export default Progress;

src/pages/main/components/stampBoard/Stamp.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface StampProps {
77
className?: string;
88
}
99

10-
export default function Stamp({ index, acquired, className }: StampProps) {
10+
const Stamp = ({ index, acquired, className }: StampProps) => {
1111
if (acquired) {
1212
return (
1313
<div
@@ -28,4 +28,5 @@ export default function Stamp({ index, acquired, className }: StampProps) {
2828
aria-label={`${index + 1}번째 스탬프 미획득`}
2929
/>
3030
);
31-
}
31+
};
32+
export default Stamp;

src/pages/main/components/stampBoard/StampBoard.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ export interface StampBoardProps {
88
className?: string;
99
}
1010

11-
export default function StampBoard({
12-
count,
13-
total = 8,
14-
className,
15-
}: StampBoardProps) {
11+
const StampBoard = ({ count, total = 8, className }: StampBoardProps) => {
1612
const clamped = Math.max(0, Math.min(total, count));
1713
const percent = (clamped / total) * 100;
1814

@@ -33,15 +29,25 @@ export default function StampBoard({
3329
</span>
3430
</header>
3531

36-
<ul role='list' className='grid grid-cols-8' aria-label='스탬프 목록'>
37-
{Array.from({ length: total }).map((_, i) => (
38-
<li key={i} className='flex items-center justify-center'>
39-
<Stamp index={i} acquired={i < clamped} />
40-
</li>
41-
))}
32+
<ul
33+
role='list'
34+
className='grid'
35+
style={{ gridTemplateColumns: `repeat(${total}, minmax(0, 1fr))` }}
36+
aria-label='스탬프 목록'
37+
>
38+
{Array.from({ length: total }).map((_, i) => {
39+
const key = `stamp-${i}`;
40+
return (
41+
<li key={key} className='flex items-center justify-center'>
42+
<Stamp index={i} acquired={i < clamped} />
43+
</li>
44+
);
45+
})}
4246
</ul>
4347

4448
<Progress value={percent} className='my-[0.6rem]' />
4549
</section>
4650
);
47-
}
51+
};
52+
53+
export default StampBoard;

src/pages/main/index.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { cn } from '@/shared/lib';
2+
import StampBoard from './components/stampBoard/StampBoard';
3+
import { ControlBar } from '@/shared/components';
4+
import Image from 'next/image';
5+
6+
export default function MainPage() {
7+
return (
8+
<div className={cn('px-[2.4rem] bg-white flex flex-col gap-[1rem]')}>
9+
<ControlBar
10+
isLoggedIn={false}
11+
onLogin={() => {}}
12+
userName='글다'
13+
className='fixed top-[0.6rem] left-0 right-0 z-50 px-[2rem]'
14+
/>
15+
16+
<main className='w-full pt-[6.2rem] flex flex-col gap-4 overflow-auto'>
17+
<section>
18+
<Image
19+
src='/assets/bannerMain.svg'
20+
alt='...'
21+
width={354}
22+
height={79}
23+
className='w-full h-auto object-cover block'
24+
/>
25+
</section>
26+
27+
<section
28+
onClick={() => {
29+
/* TODO: 페이지 이동 */
30+
}}
31+
>
32+
<Image
33+
src='/assets/board.svg'
34+
alt='보드판'
35+
width={354}
36+
height={426.36}
37+
className='w-full h-auto object-cover block'
38+
/>
39+
</section>
40+
41+
<StampBoard count={3} total={8} />
42+
</main>
43+
</div>
44+
);
45+
}

src/shared/components/header/ControlBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const ControlBar = ({
2929
const iconColor = isLoggedIn ? 'mint-600' : ('gray-400' as const);
3030

3131
return (
32-
<header className={cn('bg-none w-full h-[5.4rem]', className)} role='group'>
32+
<header className={cn(' w-full h-[5.4rem] bg-white', className)}>
3333
<div className='h-full grid grid-cols-[auto_1fr_auto] items-center gap-[1.2rem]'>
3434
<div
3535
className='w-[7.8rem] h-[5.4rem] rounded-[0.6rem] bg-gray-200'

0 commit comments

Comments
 (0)