-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
551a77f
commit 9850676
Showing
14 changed files
with
2,289 additions
and
1,716 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,103 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { ClipboardList, FolderTree } from 'lucide-react'; | ||
import TaskForm from '../Tasks/TaskForm'; | ||
import ProjectForm from '../Projects/ProjectForm'; | ||
|
||
const Form = ({ addTask }) => { | ||
const [isProjectView, setIsProjectView] = useState(false); | ||
|
||
const handleClose = () => { | ||
const modal = document.getElementById('newtask-form'); | ||
if (modal) { | ||
modal.style.display = 'none'; | ||
} | ||
setIsProjectView(false); | ||
}; | ||
|
||
useEffect(() => { | ||
const modalContainer = document.createElement('div'); | ||
document.body.appendChild(modalContainer); | ||
|
||
return () => { | ||
document.body.removeChild(modalContainer); | ||
}; | ||
}, []); | ||
|
||
const modalContent = ( | ||
<div | ||
id="newtask-form" | ||
className="hidden fixed inset-0 bg-black/50 backdrop-blur-sm | ||
animate-fadeIn" | ||
style={{ | ||
display: 'none', | ||
zIndex: 9999 | ||
}} | ||
> | ||
<div className="flex items-center justify-center p-4 min-h-screen"> | ||
<div | ||
className="relative w-full max-w-md bg-white dark:bg-gray-800 rounded-lg shadow-xl | ||
transform scale-100 animate-modalSlide max-h-[calc(100vh-2rem)] overflow-y-auto" | ||
onClick={(e) => e.stopPropagation()} | ||
> | ||
<div className="p-6 space-y-6"> | ||
{/* toggle */} | ||
<div className="flex items-center justify-between"> | ||
<div className="flex bg-gray-100 dark:bg-gray-700 p-1 rounded-lg"> | ||
<button | ||
type="button" | ||
onClick={() => setIsProjectView(false)} | ||
className={`px-4 py-2 text-sm rounded-md transition-all duration-200 | ||
${ | ||
!isProjectView | ||
? 'bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 shadow-sm' | ||
: 'text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200' | ||
}`} | ||
> | ||
<div className="flex items-center gap-2"> | ||
<ClipboardList className="w-4 h-4" /> | ||
<span>Task</span> | ||
</div> | ||
</button> | ||
<button | ||
type="button" | ||
onClick={() => setIsProjectView(true)} | ||
className={`px-4 py-2 text-sm rounded-md transition-all duration-200 | ||
${ | ||
isProjectView | ||
? 'bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 shadow-sm' | ||
: 'text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200' | ||
}`} | ||
> | ||
<div className="flex items-center gap-2"> | ||
<FolderTree className="w-4 h-4" /> | ||
<span>Project</span> | ||
</div> | ||
</button> | ||
</div> | ||
<button | ||
type="button" | ||
onClick={handleClose} | ||
className="w-8 h-8 rounded-lg flex items-center justify-center bg-red-500/10 hover:bg-red-500/20 transition-colors" | ||
> | ||
<span className="text-red-600 dark:text-red-400 text-lg"> | ||
× | ||
</span> | ||
</button> | ||
</div> | ||
|
||
{isProjectView ? ( | ||
<ProjectForm addTask={addTask} /> | ||
) : ( | ||
<TaskForm addTask={addTask} /> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
return createPortal(modalContent, document.body); | ||
}; | ||
|
||
export default Form; |
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.