[READ-ONLY] a fast, modern browser for the npm registry
at main 24 lines 400 B view raw
1export function useModal(modalId: string) { 2 const getModal = () => document.querySelector<HTMLDialogElement>(`#${modalId}`) 3 4 function open() { 5 const modal = getModal() 6 if (modal) { 7 setTimeout(() => { 8 modal.showModal() 9 }) 10 } 11 } 12 13 function close() { 14 const modal = getModal() 15 if (modal) { 16 modal.close() 17 } 18 } 19 20 return { 21 open, 22 close, 23 } 24}