-
-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge master into update-tools/regenerateTools
- Loading branch information
Showing
6 changed files
with
388 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ out | |
config/posts.json | ||
public/rss.xml | ||
.env.local | ||
roadmap.json | ||
yarn.lock | ||
meetings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useEffect, useRef } from 'react' | ||
|
||
export default function Modal({ | ||
title, | ||
children, | ||
onModalClose = () => {}, | ||
}) { | ||
const modalRef = useRef(null) | ||
|
||
useEffect(() => { | ||
modalRef.current.focus() | ||
}, []) | ||
|
||
function backdropClickHandler(e) { | ||
if (modalRef.current && (modalRef.current === e.target || !modalRef.current.contains(e.target))) { | ||
onModalClose() | ||
} | ||
} | ||
|
||
function onKeyUpHandler(e) { | ||
if (e.key === 'Escape') onModalClose() | ||
} | ||
|
||
return ( | ||
<div ref={modalRef} tabIndex={-1} className="backdrop-blur bg-black/30 fixed inset-0 z-30 flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0" onClick={backdropClickHandler} onKeyUp={onKeyUpHandler}> | ||
<div className="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-4xl sm:p-6"> | ||
<div className="flex justify-between mb-6"> | ||
<h1 className="text-lg font-bold truncate mr-4">{title}</h1> | ||
<button onClick={() => onModalClose()}> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-6 h-6"> | ||
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" /> | ||
</svg> | ||
</button> | ||
</div> | ||
<div className="w-full overflow-auto max-h-120"> | ||
{children} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.