-
Notifications
You must be signed in to change notification settings - Fork 8
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
Nikita Kakuev
authored and
Dominik Piatek
committed
Sep 29, 2023
1 parent
5f724b1
commit 72ff1ae
Showing
5 changed files
with
66 additions
and
4 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
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,55 @@ | ||
import { FormEvent, useContext, useRef } from 'react'; | ||
import cn from 'classnames'; | ||
|
||
import { SpacesContext } from '.'; | ||
import { Member } from '../utils/types'; | ||
|
||
interface Props { | ||
self?: Member; | ||
isVisible?: boolean; | ||
setIsVisible?: (isVisible: boolean) => void; | ||
} | ||
|
||
export const Modal = ({ isVisible = false, setIsVisible, self }: Props) => { | ||
const space = useContext(SpacesContext); | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
const handleSubmit = (e: FormEvent) => { | ||
e.preventDefault(); | ||
|
||
if (!space || !setIsVisible) return; | ||
|
||
space.updateProfileData((profileData) => ({ ...profileData, name: inputRef.current?.value })); | ||
setIsVisible(false); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
'backdrop-blur-md bg-black/30 fixed top-0 left-0 w-full h-full flex items-center justify-center transition-all duration-300', | ||
{ | ||
'opacity-0 pointer-events-none': !isVisible, | ||
'opacity-100': isVisible, | ||
}, | ||
)} | ||
> | ||
<form | ||
onSubmit={handleSubmit} | ||
className="bg-white p-8 shadow-lg rounded-[20px]" | ||
> | ||
<h3 className="font-semibold text-xl text-center mb-8">Enter your name</h3> | ||
<input | ||
ref={inputRef} | ||
className="border border-gray-300 rounded-md p-2 w-full" | ||
defaultValue={self?.profileData?.name} | ||
/> | ||
<button | ||
type="submit" | ||
className="bg-ably-black text-white rounded-md p-2 w-full mt-4" | ||
> | ||
Set name | ||
</button> | ||
</form> | ||
</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
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