TeamTheGenius / TeamTheGenius_Web

IT 업계 μ’…μ‚¬μžλ₯Ό μœ„ν•œ κ·œμΉ™μ μΈ 곡뢀 μŠ΅κ΄€ μ„œλΉ„μŠ€
https://gitget.co.kr
1 stars 0 forks source link

Refactor/369 global status modal #376

Closed choiseona closed 5 months ago

choiseona commented 5 months ago

🚨 Pull request 전에 확인해야 ν•  사항( [x] μ²΄ν¬ν•΄μ£Όμ„Έμš” )

πŸ“Œ κ°œμš”

λͺ¨λ‹¬μ„ μ „μ—­ μƒνƒœλ‘œ κ΄€λ¦¬ν•˜λ„λ‘ μˆ˜μ •ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

μ§€μ—­μ μœΌλ‘œ λͺ¨λ‹¬μ„ κ΄€λ¦¬ν•˜λ‹€λ³΄λ‹ˆ λΆˆν•„μš”ν•œ μ½”λ“œκ°€ 많이 λ°œμƒν•˜κ³ , μ„œλ‘œ λ‹€λ₯Έ 지역 λͺ¨λ‹¬κ°„μ˜ open,close 동기화가 λΆˆν•„μš”ν•˜κ²Œ κΉŒλ‹€λ‘œμ›Œ λͺ¨λ‹¬μ„ μ „μ—­ μƒνƒœλ‘œ κ΄€λ¦¬ν•˜λ„λ‘ μˆ˜μ •ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

369

✨ μž‘μ—… λ‚΄μš©

πŸ“Έ μŠ€ν¬λ¦°μƒ·(선택)

πŸ”Š λ¦¬λ·°μ–΄μ—κ²Œ(선택)

import { create } from "zustand";

interface ModalType {
  modal: React.ReactNode | null;
  isModalOpen: boolean;
  setModal: (newState: React.ReactNode | null) => void;
  closeModal: () => void;
}

export const useModalStore = create<ModalType>((set) => ({
  modal: null,
  isModalOpen: false,
  setModal: (newState) => {
    document.body.style.overflow = "hidden";
    set({ modal: newState, isModalOpen: true });
  },
  closeModal: () => {
    document.body.style.overflow = "unset";
    set({ isModalOpen: false });
  },
}));

setModal을 μ΄μš©ν•΄μ„œ λͺ¨λ‹¬μ„ μ„€μ •ν•  수 있고 closeModal을 ν†΅ν•΄μ„œ λͺ¨λ‹¬μ„ 닫을 수 μžˆμŠ΅λ‹ˆλ‹€. λͺ¨λ‹¬μ„ μ„€μ •ν•˜λ©΄(setModal) λͺ¨λ‹¬μ„ μžλ™μ μœΌλ‘œ 열도둝 (isModalOpen: true) λ§Œλ“€μ—ˆμœΌλ―€λ‘œ openModal을 해쀄 ν•„μš”κ°€ μ—†μŠ΅λ‹ˆλ‹€.

μ‚¬μš© μ˜ˆμ‹œλŠ” μ•„λž˜μ™€ 같이 μ‚¬μš©ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€.

const { setModal, closeModal } = useModalStore();

πŸ“š μΆ”κ°€ 사항(선택)

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
gitget βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback May 21, 2024 2:18pm