-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: separate project link dialog to AppProjectLinkDialog
- Loading branch information
Showing
2 changed files
with
58 additions
and
43 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
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,45 @@ | ||
import { useEffect, useRef } from "react" | ||
|
||
export function AppProjectLinkDialog({ link }: { | ||
link: string | ||
}) { | ||
const dialogRef = useRef<HTMLDialogElement>(null); | ||
const textAreaRef = useRef<HTMLTextAreaElement>(null); | ||
|
||
useEffect(() => { | ||
if (link.trim() == "") | ||
return; | ||
|
||
dialogRef.current!.showModal(); | ||
|
||
setTimeout(() => { | ||
textAreaRef.current!.focus(); | ||
textAreaRef.current!.select(); | ||
}, 50); | ||
}, [link]); | ||
|
||
return ( | ||
<dialog ref={dialogRef} className="modal"> | ||
<div className="modal-box max-w-none w-1/2"> | ||
<h3 className="font-bold text-lg">Project link</h3> | ||
<p className="py-4"> | ||
This is a link to your project - whenever you'll open it, this | ||
version of the project will be restored. | ||
</p> | ||
|
||
<textarea ref={textAreaRef} | ||
className="textarea textarea-bordered w-full h-full min-h-[200px]" | ||
aria-label="Project link" | ||
value={link} | ||
readOnly | ||
/> | ||
|
||
<div className="modal-action"> | ||
<form method="dialog"> | ||
<button className="btn">Close</button> | ||
</form> | ||
</div> | ||
</div> | ||
</dialog> | ||
); | ||
}; |