Skip to content

Commit fb08e3d

Browse files
committed
feat: flyout모달 리팩토링을 위한 임시 파일 생성
1 parent 729ec75 commit fb08e3d

File tree

4 files changed

+80
-21
lines changed

4 files changed

+80
-21
lines changed

src/app/(afterlogin)/(common_navbar)/home/_components/_svgs/MenuIcon.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
import styles from '@/app/(beforelogin)/flyouttest/flyouttest.module.scss';
2+
13
const MenuIcon = () => {
24
return (
3-
<i>
4-
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="18" viewBox="0 0 4 18" fill="none">
5-
<circle cx="1.95654" cy="1.95654" r="1.95654" fill="#696969" />
6-
<circle cx="1.95654" cy="9.00048" r="1.95654" fill="#696969" />
7-
<circle cx="1.95654" cy="16.0435" r="1.95654" fill="#696969" />
8-
</svg>
9-
</i>
5+
<button className={styles.flyout__button}>
6+
<i>
7+
<svg
8+
xmlns="http://www.w3.org/2000/svg"
9+
width="4"
10+
height="18"
11+
viewBox="0 0 4 18"
12+
fill="none"
13+
>
14+
<circle cx="1.95654" cy="1.95654" r="1.95654" fill="#696969" />
15+
<circle cx="1.95654" cy="9.00048" r="1.95654" fill="#696969" />
16+
<circle cx="1.95654" cy="16.0435" r="1.95654" fill="#696969" />
17+
</svg>
18+
</i>
19+
</button>
1020
);
1121
};
1222

src/app/(beforelogin)/flyouttest/flyouttest.module.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,46 @@
4242
justify-content: space-between;
4343
max-width: 440px;
4444
}
45+
46+
.flyout {
47+
display: flex;
48+
flex-direction: column;
49+
align-items: center;
50+
justify-content: center;
51+
position: absolute;
52+
top: 20px;
53+
right: 20px;
54+
55+
.dimmed {
56+
width: 100%;
57+
height: 100%;
58+
}
59+
60+
&__button {
61+
@include pure-button;
62+
63+
margin-bottom: 8px;
64+
}
65+
66+
&__list {
67+
position: absolute;
68+
top: 30px;
69+
left: 0;
70+
z-index: 2;
71+
width: 120px;
72+
padding: 0;
73+
background: $white;
74+
border: 1px solid $gray-1;
75+
border-radius: 8px;
76+
box-shadow: 2px 2px 3px $gray-2;
77+
}
78+
79+
&__item {
80+
padding: 12px;
81+
border-bottom: 1px solid $gray-1;
82+
83+
&:last-child {
84+
border: unset;
85+
}
86+
}
87+
}

src/app/(beforelogin)/flyouttest/page.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ const page = () => {
1313
<div className={styles.dummyImg} />
1414
<div className={styles.menu__box}>
1515
<Flyout toggleButton={<MenuIcon />}>
16-
<button>a</button>
17-
<button>b</button>
16+
<article className={styles.flyout}>
17+
<button>수정하기</button>
18+
<button>삭제하기</button>
19+
</article>
1820
</Flyout>
1921
</div>
2022
</div>
@@ -25,8 +27,10 @@ const page = () => {
2527
<div className={styles.dummyImg} />
2628
<div className={styles.menu__box}>
2729
<Flyout toggleButton={<MenuIcon />}>
28-
<button>a</button>
29-
<button>b</button>
30+
<article className={styles.flyout}>
31+
<button>수정하기</button>
32+
<button>삭제하기</button>
33+
</article>
3034
</Flyout>
3135
</div>
3236
</div>
@@ -37,8 +41,10 @@ const page = () => {
3741
<div className={styles.dummyImg} />
3842
<div className={styles.menu__box}>
3943
<Flyout toggleButton={<MenuIcon />}>
40-
<button>a</button>
41-
<button>b</button>
44+
<article className={styles.flyout}>
45+
<button>수정하기</button>
46+
<button>삭제하기</button>
47+
</article>
4248
</Flyout>
4349
</div>
4450
</div>
@@ -49,8 +55,10 @@ const page = () => {
4955
<div className={styles.dummyImg} />
5056
<div className={styles.menu__box}>
5157
<Flyout toggleButton={<MenuIcon />}>
52-
<button>a</button>
53-
<button>b</button>
58+
<article className={styles.flyout}>
59+
<button>수정하기</button>
60+
<button>삭제하기</button>
61+
</article>
5462
</Flyout>
5563
</div>
5664
</div>

src/app/_components/_modules/Flyout.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { ReactNode, useEffect, useRef, useState } from 'react';
2-
import styles from './FlyoutMenu.module.scss';
32

43
interface Props {
54
toggleButton: ReactNode;
@@ -24,11 +23,10 @@ const Flyout = ({ toggleButton, children }: Props) => {
2423

2524
return (
2625
<div ref={ref}>
27-
<button className={styles.flyout__button} onClick={() => setIsOpen((prev) => !prev)}>
28-
{toggleButton}
29-
</button>
30-
{/* {children}에서 ul, li형태로 감싸진 버튼을 주든, 단일 버튼을 주든 외부에서 자유롭게 주입 */}
31-
{isOpen && <article className={styles.flyout}>{children}</article>}
26+
{/* 메뉴 모달 토글 버튼 */}
27+
{!isOpen && <div onClick={() => setIsOpen((prev) => !prev)}>{toggleButton}</div>}
28+
{/* 수정 삭제 버튼 */}
29+
{isOpen && children}
3230
</div>
3331
);
3432
};

0 commit comments

Comments
 (0)