Skip to content

Commit e9b3b7e

Browse files
committed
[#143] feat: BlockHandler에서 모달 띄우기
1 parent 841591a commit e9b3b7e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

frontend/src/components/molecules/BlockHandler/BlockHandler.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ReactComponent as DraggableIcon } from '@assets/draggable.svg';
77
import { ReactComponent as PlusIcon } from '@assets/plus.svg';
88
import { useSetRecoilState } from 'recoil';
99

10-
import { draggingBlockState } from '@/stores';
10+
import { draggingBlockState, modalState } from '@/stores';
1111
import { Block } from '@/schemes';
1212

1313
const buttonWrapperCss = () => css`
@@ -38,6 +38,7 @@ interface Props {
3838

3939
function BlockHandler({ blockDTO, blockComponentRef }: Props): JSX.Element {
4040
const setDraggingBlock = useSetRecoilState(draggingBlockState);
41+
const setModal = useSetRecoilState(modalState);
4142

4243
const dragStartHandler = (event: React.DragEvent<HTMLDivElement>) => {
4344
event.dataTransfer.effectAllowed = 'move';
@@ -47,9 +48,19 @@ function BlockHandler({ blockDTO, blockComponentRef }: Props): JSX.Element {
4748
setDraggingBlock(blockDTO);
4849
};
4950

51+
const handleModal = (event: React.MouseEvent) => {
52+
setModal({
53+
isOpen: true,
54+
top: event.clientY,
55+
left: event.clientX,
56+
caretOffset: 0,
57+
blockId: blockDTO.id,
58+
});
59+
};
60+
5061
return (
5162
<div css={buttonWrapperCss()}>
52-
<PlusIcon css={buttonCss()} />
63+
<PlusIcon css={buttonCss()} onClick={handleModal} />
5364
<div
5465
css={buttonCss()}
5566
draggable="true"

0 commit comments

Comments
 (0)