-
Notifications
You must be signed in to change notification settings - Fork 1
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
4f78ef1
commit 0515103
Showing
6 changed files
with
342 additions
and
245 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,48 @@ | ||
import { useEffect } from "react" | ||
import delay from "../lib/delay" | ||
|
||
export type OptionsSelectorOptions = { name: string, value: string }[] | ||
|
||
type OptionSelectorArg = { | ||
children: JSX.Element, | ||
isOpen: boolean, | ||
setIsOpen: Function, | ||
options: OptionsSelectorOptions, | ||
setOption: Function, | ||
heading: string, | ||
description?: string | ||
} | ||
|
||
export default function OptionSelector({ children, isOpen, setIsOpen, options, setOption, heading, description }: OptionSelectorArg) { | ||
useEffect(() => { | ||
if (isOpen) document.body.style.overflowY = 'hidden' | ||
return () => { document.body.style.overflowY = 'auto' } | ||
}, [isOpen]) | ||
|
||
return <> | ||
<div className={`h-[100vh] w-[100vw] left-0 top-0 fixed justify-center items-center bg-black/20 dark:bg-transparent backdrop-blur-md | ||
${isOpen ? 'flex' : 'hidden'} z-[70]`} | ||
onClick={() => { | ||
setIsOpen(false) | ||
}} | ||
> | ||
<div className="bg-white dark:bg-[#1a1a1a] p-4 py-0 px-0 min-h-[100px] w-[80%] rounded-3xl overflow-hidden backdrop-blur-sm"> | ||
<p className="text-center font-semibold py-5 pt-6">{heading}</p> | ||
<div className={`flex flex-col justify-center items-start tracking-wide`}> | ||
{ | ||
options.map((option, index) => { | ||
return <p onClick={() => { setIsOpen(false), setOption(option.value) }} key={index} | ||
className="p-4 border-gray-100 dark:border-[#ffffff15] border-t-[1.1px] | ||
active:bg-gray-100 dark:active:bg-gray-800 | ||
text-sm w-full font-[450] text-center text-blue-500">{option.name}</p> | ||
}) | ||
} | ||
<p onClick={() => setIsOpen(false)} | ||
className="p-4 border-gray-100 dark:border-[#ffffff10] border-t-[1.1px] pb-6 | ||
active:bg-gray-100 dark:active:bg-gray-800 text-sm w-full font-[450] text-center text-red-500">Cancel</p> | ||
</div> | ||
</div> | ||
</div > | ||
{children} | ||
</> | ||
} |
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.