Skip to content

Commit b5a0d88

Browse files
authored
Merge branch 'develop' into DF-79-shared-Toast
2 parents b88bad6 + f2ffdb2 commit b5a0d88

13 files changed

Lines changed: 1249 additions & 733 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
#
2222
# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN
2323
# (On SonarCloud, click on your avatar on top-right > My account > Security
24-
# or go directly to https://sonarcloud.io/account/security/)
24+
# or go directly to
2525

26-
# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/)
27-
# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9)
26+
# Feel free to take a look at our documentation (
27+
# or reach out to our community forum if you need some help (
2828

2929
name: SonarCloud analysis
3030

3131
on:
3232
push:
33-
branches: [ "main", "develop" ]
33+
branches: [ '*' ] # 모든 브랜치에서 푸시 이벤트 발생 시 분석
3434
pull_request:
35-
branches: [ "main", "develop" ]
35+
branches: [ '*' ] # 모든 브랜치에 대한 PR 발생 시 분석
3636
workflow_dispatch:
3737

3838
permissions:
@@ -46,7 +46,6 @@ jobs:
4646
- name: Analyze with SonarCloud
4747

4848
# You can pin the exact commit or the version.
49-
# uses: SonarSource/[email protected]
5049
uses: SonarSource/sonarcloud-github-action@4006f663ecaf1f8093e8e4abb9227f6041f52216
5150
env:
5251
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
@@ -60,7 +59,7 @@ jobs:
6059
# Comma-separated paths to directories containing main source files.
6160
#-Dsonar.sources= # optional, default is project base directory
6261
# Comma-separated paths to directories containing test source files.
63-
#-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
62+
#-Dsonar.tests= # optional. For more info about Code Coverage, please refer to
6463
# Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
6564
#-Dsonar.verbose= # optional, default is false
6665
# When you need the analysis to take place in a directory other than the one from which it was launched, default is .

.pnp.cjs

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

src/app/styles/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from './globalText.css'
2-
export * from './reset.css'
2+
export * from './reset.css'

src/app/token/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './token';

src/shared/lib/hooks/useModal.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import {
2+
IExtendedModalConfig,
3+
IModalConfig,
4+
IModalReturn,
5+
} from '@/shared/types/modal.types'
6+
import { useState } from 'react'
7+
8+
const defaultModalConfig: IModalConfig = {
9+
open: false,
10+
btnSize: 24,
11+
outerTouchClose: true,
12+
}
13+
14+
/**
15+
* 동적 모달 관리를 위한 커스텀 훅
16+
* @param {IExtendedModalConfig} config 모달 기본 설정을 할 수 있는 객체(optional)
17+
* - [open=false]: 모달이 열려있는지 여부
18+
* - [showCloseButton=true]: 모달 내부 버튼 유무
19+
* - [btnSize=24]: 모달 내부 버튼 크기 (24, 32 only)
20+
* @returns 모달 설정을 변경할 수 있는 객체
21+
* - {void} toggleModal: 모달을 열거나 닫는 함수
22+
* - {void} showModal: 모달을 열어주는 함수
23+
* - {void} hideModal: 모달을 닫아주는 함수
24+
* - {void} updateModalConfig: 모달 설정을 업데이트하는 함수
25+
* - {object} modalConfig: 모달 설정 - 세부 타입 IModalConfig 참고
26+
*/
27+
28+
const useModal = (config?: IModalConfig): IModalReturn => {
29+
const [modalConfig, setModalConfig] = useState<IModalConfig>({
30+
...defaultModalConfig,
31+
...config,
32+
})
33+
34+
// 모달을 열거나 닫는 함수
35+
const toggleModal = () => {
36+
setModalConfig((prev) => {
37+
return {
38+
...prev,
39+
open: !prev.open,
40+
}
41+
})
42+
}
43+
// 모달을 열어주는 함수
44+
const showModal = () => {
45+
setModalConfig((prev) => {
46+
return {
47+
...prev,
48+
open: true,
49+
}
50+
})
51+
}
52+
// 모달을 닫아주는 함수
53+
const hideModal = () => {
54+
setModalConfig((prev) => {
55+
return {
56+
...prev,
57+
open: false,
58+
}
59+
})
60+
}
61+
// 모달 설정을 업데이트하는 함수
62+
const updateModalConfig = (config: Partial<IModalConfig>) => {
63+
setModalConfig((prev) => {
64+
return {
65+
...prev,
66+
...config,
67+
}
68+
})
69+
}
70+
// 닫기 함수 사용을 위한 모달 설정을 확장
71+
const extendConfig: IExtendedModalConfig = {
72+
...modalConfig,
73+
handleClose: hideModal,
74+
}
75+
// 모달 설정과 함수들을 반환
76+
return {
77+
toggleModal,
78+
showModal,
79+
hideModal,
80+
updateModalConfig,
81+
modalConfig: extendConfig,
82+
}
83+
}
84+
85+
export { useModal }

src/shared/types/modal.types.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface IModalConfig {
2+
// 모달이 열려있는지 여부
3+
open?: boolean
4+
// 모달 내부 버튼 유무
5+
showCloseButton?: boolean
6+
// 모달 내부 버튼 크기
7+
btnSize?: 24 | 32
8+
// 외부 클릭으로 모달 닫기
9+
outerTouchClose?: boolean
10+
}
11+
12+
export interface IModalReturn {
13+
// @shared/lib/hooks/useModal 참고
14+
toggleModal: () => void
15+
showModal: () => void
16+
hideModal: () => void
17+
updateModalConfig: (config: Partial<IModalConfig>) => void
18+
modalConfig: IExtendedModalConfig
19+
}
20+
// close 추가한 모달 설정
21+
export interface IExtendedModalConfig extends IModalConfig {
22+
handleClose: () => void
23+
}
24+
25+
export type ModalProps = Readonly<IExtendedModalConfig>

src/shared/ui/Box/Box.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { Sprinkles, sprinkles } from '@/app/sprinkle/sprinkle.css'
2-
import { AllHTMLAttributes, ElementType, forwardRef } from 'react'
3-
4-
export interface BoxProps
5-
extends Omit<AllHTMLAttributes<HTMLElement>, 'as' | 'color'>, Sprinkles {
6-
children?: React.ReactNode // 하위 React 노드
7-
className?: string // 클래스 이름
8-
as?: ElementType // HTML 엘리먼트 타입 (기본값: div)
9-
}
2+
import { forwardRef } from 'react'
3+
import { BoxProps } from './box.types'
104

115
/**
126
* Box 컴포넌트는 shared UI 컴포넌트 중 가장 기본이 되는 컴포넌트입니다.
13-
* @param as HTML 엘리먼트 타입 (기본값: div)
14-
* @param children 하위 React 노드
15-
* @param className 클래스 이름
16-
* @param props Sprinkles 속성 및 기타 속성
17-
* @returns Box 컴포넌트
7+
* @param {string} [as = 'div'] HTML 엘리먼트 타입(optional)
8+
* @param {ReactNode} children 하위 React 노드(optional)
9+
* @param {string} className 클래스 이름(optional)
10+
* @param {any} props Sprinkles 속성 및 기타 속성
11+
* @returns {JsxElement} Box 컴포넌트
12+
* @example
13+
* <Box as={'div' | 'span' | ...} className="example"">
14+
* <p>example</p>
15+
* </Box>
1816
*/
17+
1918
export const Box = forwardRef<HTMLElement, BoxProps>(
2019
(
2120
{

src/shared/ui/Box/box.types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { AllHTMLAttributes, ElementType } from 'react'
2+
import { Sprinkles } from '@/app/sprinkle/sprinkle.css'
3+
4+
export interface IBox
5+
extends Omit<AllHTMLAttributes<HTMLElement>, 'as' | 'color'>,
6+
Sprinkles {
7+
children?: React.ReactNode // 하위 React 노드
8+
className?: string // 클래스 이름
9+
as?: ElementType // HTML 엘리먼트 타입 (기본값: div)
10+
}
11+
12+
export type BoxProps = Readonly<IBox>

src/shared/ui/Box/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from './Box'
1+
export * from './Box'
2+
export * from './box.types'

src/shared/ui/Modal/Modal.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { IExtendedModalConfig } from '@/shared/types/modal.types'
2+
import { Box } from '../Box'
3+
import { modalBackdrop, modalContent } from './modal.css'
4+
5+
/**
6+
* 공용 모달 컴포넌트
7+
* @param {ReactNode} children 모달 내부에 들어갈 컨텐츠 (optional)
8+
* @parms modalConfig 모달 설정 - useModal에서 반환된 modalConfig
9+
* @returns {JsxElement}닫기 버튼이 존재하지 않는 모달
10+
* @example
11+
* const { modalConfig, toggleModal } = useModal({ open: true });
12+
* <Modal modalConfig={modalConfig}>
13+
* <p>example</p>
14+
* <button onClick={toggleModal}>toggle</button>
15+
* </Modal>
16+
*/
17+
18+
export default function Modal({
19+
children,
20+
modalConfig,
21+
}: Readonly<{
22+
children?: React.ReactNode
23+
modalConfig: IExtendedModalConfig
24+
}>) {
25+
if (modalConfig.open === false) return null
26+
return (
27+
<Box
28+
as={'div'}
29+
onClick={() =>
30+
modalConfig.outerTouchClose && modalConfig.handleClose()
31+
}
32+
role="presentation"
33+
className={modalBackdrop}
34+
display="flex"
35+
justifyContent="center"
36+
alignItems="center"
37+
>
38+
<Box
39+
as={'dialog'}
40+
onClick={(e) => e.stopPropagation()}
41+
className={modalContent}
42+
display="flex"
43+
flexDirection="column"
44+
>
45+
{children}
46+
</Box>
47+
</Box>
48+
)
49+
}

0 commit comments

Comments
 (0)