Skip to content

Commit 945e784

Browse files
authored
[#49] ✨ 공통 컴포넌트 Modal 개발 (#90)
* [#48] 🚚 rename index.tsx into index.ts * [#42] ♻️ add index.ts ad a module bridge * [#20] 💄 add text-inherit to tailwind config * [#50] ✨ add highlight component * [#40] ♻️ update Button components w/ fullWidth props & clsx * [#23] 🔧 update import order in prettier config * [#48] 💄 change default padding & margin in Box component * [#49] ✨ add Portal component * [#49] ✨ add modal global state w/ zustand * [#49] ✨ add Modal component * [#49] ✨ add portal root + modal at root layout * [#49] ✨ add SignUpSuccessModalContent * [#49] ✨ add Modal Content component * [#49] ♻️ refactor signupsuccess modal content composing modal content components * [#49] 🚚 rename modal contents directory to modal content + add a module bridge * [#49] 🚚 rename module paths + component name
1 parent 178306d commit 945e784

File tree

22 files changed

+361
-27
lines changed

22 files changed

+361
-27
lines changed

prettier.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ module.exports = {
1616
tailwindFunctions: ['clsx', 'twMerge'],
1717
importOrder: [
1818
'^next(.*)$', // Next 관련 import를 최상단으로
19+
'^react(.*)$', // React 관련 import를 최상단으로
1920
'<THIRD_PARTY_MODULES>', // 외부 모듈
2021
'^@/app/api/(.*)$', // api 폴더
2122
'^@/components/(.*)$', // components 폴더를
2223
'^@/queries/(.*)$', // queries 폴더
2324
'^@/hooks/(.*)$', // hooks 폴더
25+
'^@/stores/(.*)$', // stores 폴더
2426
'^@/services/(.*)$', // services 폴더
2527
'^@/utils/(.*)$', // utils 폴더
2628
'^[./]', // 상대 경로

src/app/layout.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
import Head from 'next/head'
2-
31
import Providers from '@/app/providers'
42
import '@/styles/globals.css'
53

4+
import { Modal } from '@/components/common/popup'
5+
66
const RootLayout = ({
77
children,
88
}: Readonly<{
99
children: React.ReactNode
1010
}>): JSX.Element => {
1111
return (
1212
<html lang='ko'>
13-
<Head>
13+
<head>
1414
<link
1515
rel='stylesheet'
1616
as='style'
1717
href='https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css'
1818
crossOrigin='anonymous'
1919
/>
20-
</Head>
20+
</head>
2121
<body>
22-
<Providers>{children}</Providers>
22+
<Providers>
23+
{children}
24+
<div id={'portal-root'}></div>
25+
<Modal />
26+
</Providers>
2327
</body>
2428
</html>
2529
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ModalContent } from '@/components/shared/modalContent'
2+
3+
import celebrateImage from '/public/assets/images/img-celebration.png'
4+
5+
export const SignUpSuccessModalContent = (): JSX.Element => {
6+
return (
7+
<ModalContent>
8+
<ModalContent.Image src={celebrateImage} alt={'축하 이미지'} />
9+
<ModalContent.Header
10+
title={'회원가입 완료!'}
11+
subTitle={
12+
<>
13+
홍길동님의 회원가입이
14+
<br />
15+
성공적으로 완료되었습니다.
16+
</>
17+
}
18+
/>
19+
<ModalContent.InfoBox
20+
firstLabel={'나의 정보 확인 및 수정은 '}
21+
linkLabel={'마이페이지 > 프로필'}
22+
lastLabel={'에서 가능합니다.'}
23+
to={'/'}
24+
/>
25+
<ModalContent.Link href={'/'} label={'로그인 바로가기'} />
26+
</ModalContent>
27+
)
28+
}
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
import clsx from 'clsx'
2+
13
import { Clickable, ClickableProps } from './Clickable'
24

3-
interface ButtonProps
5+
export interface ButtonProps
46
extends ClickableProps,
57
React.ButtonHTMLAttributes<HTMLButtonElement> {}
68

79
export const Button = ({
810
onClick,
911
type = 'button',
1012
disabled = false,
13+
fullWidth,
1114
...props
1215
}: ButtonProps): JSX.Element => (
13-
<button onClick={onClick} type={type} disabled={disabled}>
14-
<Clickable {...props} disabled={disabled} />
16+
<button
17+
onClick={onClick}
18+
type={type}
19+
disabled={disabled}
20+
className={clsx({ 'w-full': fullWidth })}
21+
>
22+
<Clickable {...props} disabled={disabled} fullWidth={fullWidth} />
1523
</button>
1624
)

src/components/common/button/Clickable.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import clsx from 'clsx'
2-
import { twMerge } from 'tailwind-merge'
32

43
export interface ClickableProps {
54
label?: string
@@ -83,18 +82,18 @@ export const Clickable = ({
8382
: ''
8483
const textColorClass = textColor ? styleByTextColor[textColor] : ''
8584

86-
const clickableStyle = twMerge(
85+
const clickableStyle = clsx(
8786
baseStyle,
8887
styleByVariant[variant],
8988
styleBySize[size],
9089
textColorClass,
91-
clsx({
90+
{
9291
[borderColorClass]: variant === 'outlined',
9392
[backgroundColorClass]: variant !== 'text',
9493
[disabledStyle]: disabled,
9594
'w-full': fullWidth,
9695
'justify-start': leftAlign,
97-
}),
96+
},
9897
className
9998
)
10099

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import NextLink from 'next/link'
22

3+
import clsx from 'clsx'
4+
35
import { Clickable, ClickableProps } from './Clickable'
46

5-
interface LinkProps
7+
export interface LinkProps
68
extends ClickableProps,
79
React.AnchorHTMLAttributes<HTMLAnchorElement> {}
810

911
export const Link = ({
1012
href = '#',
1113
disabled,
14+
onClick = () => {},
15+
fullWidth,
1216
...props
1317
}: LinkProps): JSX.Element => (
1418
<NextLink
@@ -18,9 +22,12 @@ export const Link = ({
1822
onClick={e => {
1923
if (disabled) {
2024
e.preventDefault()
25+
} else {
26+
onClick(e)
2127
}
2228
}}
29+
className={clsx({ 'w-full': fullWidth })}
2330
>
24-
<Clickable {...props} disabled={disabled} />
31+
<Clickable {...props} disabled={disabled} fullWidth={fullWidth} />
2532
</NextLink>
2633
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button } from './Button'
2-
import { Link } from './Link'
1+
import { Button, type ButtonProps } from './Button'
2+
import { Link, type LinkProps } from './Link'
33

4-
export { Button, Link }
4+
export { Button, ButtonProps, Link, LinkProps }

src/components/common/containers/Box.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ import { twMerge } from 'tailwind-merge'
22

33
type Variant = 'contained' | 'outlined'
44
type Rounded = 8 | 12
5-
type Padding = 0 | 10 | 20 | 30 | 40
5+
type Padding = 0 | 10 | 20 | 30 | 32 | 40
66
type Margin = 0 | 10 | 20 | 30 | 40
77
type Color = 'primary' | 'secondary' | 'tertiary'
88

9-
interface BoxProps {
10-
children: React.ReactNode
9+
interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {
1110
variant?: Variant
1211
rounded?: Rounded
1312
padding?: Padding
1413
margin?: Margin
1514
color?: Color
16-
className?: string
1715
}
1816

1917
const BaseStyle = 'flex items-center justify-center w-full'
@@ -33,6 +31,7 @@ const styleByPadding: Record<Padding, string> = {
3331
10: 'p-10',
3432
20: 'p-20',
3533
30: 'p-30',
34+
32: 'p-32',
3635
40: 'p-40',
3736
}
3837

@@ -54,8 +53,8 @@ export const Box = ({
5453
children,
5554
variant = 'outlined',
5655
rounded = 12,
57-
padding = 20,
58-
margin = 10,
56+
padding = 0,
57+
margin = 0,
5958
color = 'primary',
6059
className = '',
6160
}: BoxProps): JSX.Element => {
File renamed without changes.

0 commit comments

Comments
 (0)