-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor: Context API로 BottomSheet onClose props drilling 제거 #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| 'use client'; | ||
|
|
||
| import { createContext, useContext } from 'react'; | ||
|
|
||
| interface BottomSheetContextValue { | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| export const BottomSheetContext = createContext<BottomSheetContextValue | null>(null); | ||
|
|
||
| export const useBottomSheetContext = (): BottomSheetContextValue => { | ||
| const ctx = useContext(BottomSheetContext); | ||
| if (!ctx) throw new Error('useBottomSheetContext must be used within BottomSheet'); | ||
| return ctx; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export { BottomSheet } from './BottomSheet'; | ||
| export type { BottomSheetProps } from './BottomSheet'; | ||
| export { BaseBottomSheetTemplate } from './templates'; | ||
| export { useBottomSheetContext } from './BottomSheetContext'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { Text } from '../../text'; | |
| import { vars } from '../../theme.css'; | ||
| import { IcClear, IcPlusSimple } from 'public/icons'; | ||
| import { Button } from '../../button'; | ||
| import { useBottomSheetContext } from '../BottomSheetContext'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: BaseBottomSheetTemplate.Header의 add 타입 사용처를 확인합니다.
rg -nP -C3 "<BaseBottomSheetTemplate\\.Header[^>]*type=['\"]add['\"]" --glob '*.tsx'Repository: Central-MakeUs/Monit_Front Length of output: 929 🏁 Script executed: #!/bin/bash
# 1. BaseBottomSheetTemplate.tsx 파일 크기 확인
wc -l apps/web/src/shared/ui/bottomSheet/templates/BaseBottomSheetTemplate.tsx
# 2. 파일 내용 읽기
cat -n apps/web/src/shared/ui/bottomSheet/templates/BaseBottomSheetTemplate.tsxRepository: Central-MakeUs/Monit_Front Length of output: 3438 🏁 Script executed: #!/bin/bash
# 3. Header 컴포넌트의 직접 import 사용 여부 검색
rg -n "import.*Header.*from.*BottomSheetTemplate|from.*BaseBottomSheetTemplate.*Header" --glob '*.tsx'Repository: Central-MakeUs/Monit_Front Length of output: 52 🏁 Script executed: #!/bin/bash
# 4. 전체 type='add' 사용처 재검색 (더 광범위)
rg -n "type=['\"]add['\"]" apps/web/src/features --glob '*.tsx' | grep -i "header\|template"Repository: Central-MakeUs/Monit_Front Length of output: 239
Line 43-44에서 🐛 제안 수정 import { Button } from '../../button';
import { useBottomSheetContext } from '../BottomSheetContext';
@@
-const BottomSheetHeader = ({ text, type = 'close', onClickAddBtn }: BottomSheetHeaderProps) => {
+const BottomSheetCloseButton = () => {
const { onClose } = useBottomSheetContext();
+
+ return <IcClear className={headerIcon} color={vars.color.icon.subtle} onClick={onClose} />;
+};
+
+const BottomSheetHeader = ({ text, type = 'close', onClickAddBtn }: BottomSheetHeaderProps) => {
return (
<div className={bottomSheetHeaderWrapper}>
@@
{type === 'close' ? (
- <IcClear className={headerIcon} color={vars.color.icon.subtle} onClick={onClose} />
+ <BottomSheetCloseButton />
) : (🤖 Prompt for AI Agents |
||
|
|
||
| interface BottomSheetButtonProps { | ||
| label: string; | ||
|
|
@@ -23,7 +24,6 @@ interface BottomSheetHeaderProps { | |
| text?: string; | ||
| type?: headerType; | ||
| onClickAddBtn?: () => void; | ||
| onClose?: () => void; | ||
| } | ||
|
|
||
| const BaseBottomSheetTemplate = ({ children }: { children: React.ReactNode }) => { | ||
|
|
@@ -40,12 +40,8 @@ const BottomSheetContent = ({ | |
| return <div className={className}>{children}</div>; | ||
| }; | ||
|
|
||
| const BottomSheetHeader = ({ | ||
| text, | ||
| type = 'close', | ||
| onClickAddBtn, | ||
| onClose, | ||
| }: BottomSheetHeaderProps) => { | ||
| const BottomSheetHeader = ({ text, type = 'close', onClickAddBtn }: BottomSheetHeaderProps) => { | ||
| const { onClose } = useBottomSheetContext(); | ||
| return ( | ||
| <div className={bottomSheetHeaderWrapper}> | ||
| <Text variant='t1' color={vars.color.text.primary}> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.