Skip to content

Commit

Permalink
#76 feat: overlay 클릭 비활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
hwanheejung committed Aug 15, 2024
1 parent 3267392 commit 2a1dbc4
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/app/(board)/board/[boardId]/components/Tutorial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const Tutorial = ({
const [overlayStyle, setOverlayStyle] = useState<CSSProperties>({})
const { run, currentStep, endTutorial } = useTutorial()

// overlay 클릭 방지
const [topBox, setTopBox] = useState<CSSProperties>({})
const [bottomBox, setBottomBox] = useState<CSSProperties>({})
const [leftBox, setLeftBox] = useState<CSSProperties>({})
const [rightBox, setRightBox] = useState<CSSProperties>({})

useEffect(() => {
if (run && step === currentStep) {
setIsOpen(true)
Expand All @@ -44,6 +50,19 @@ const Tutorial = ({
boxShadow: '0 0 0 9999px rgba(0, 0, 0, 0.6)',
pointerEvents: 'none',
})

setTopBox({
bottom: `calc(100% - ${targetRect.top}px + 2px)`,
})
setBottomBox({
top: targetRect.bottom + 5,
})
setLeftBox({
right: `calc(100% - ${targetRect.left}px + 2px)`,
})
setRightBox({
left: targetRect.right + 3,
})
}
}, [isOpen])

Expand All @@ -61,7 +80,24 @@ const Tutorial = ({
</div>
{isOpen && (
<>
<div style={overlayStyle} />
<div style={overlayStyle}>
<div
className="pointer-events-auto fixed left-0 h-dvh w-screen"
style={topBox}
/>
<div
className="pointer-events-auto fixed left-0 h-dvh w-screen"
style={bottomBox}
/>
<div
className="pointer-events-auto fixed top-0 h-dvh w-screen"
style={leftBox}
/>
<div
className="pointer-events-auto fixed top-0 h-dvh w-screen"
style={rightBox}
/>
</div>
{tooltip}
</>
)}
Expand Down

0 comments on commit 2a1dbc4

Please sign in to comment.