-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from sudeepmahato16/animation-feature
Added animation in filter menu
- Loading branch information
Showing
3 changed files
with
166 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,76 +1,131 @@ | ||
import React, { useState } from "react"; | ||
import { motion, AnimatePresence } from "framer-motion"; | ||
import { MdSearch, MdClear } from "react-icons/md"; | ||
import './css/style.css' | ||
const errorType = ["All", "push", "commit", "merge", "pull", "add", "branch"] | ||
|
||
import useWindowsize from "../../hooks/useWindowsize"; | ||
import "./css/style.css"; | ||
|
||
function SearchInput({ search, setSearch, setType }) { | ||
const [open, setOpen] = useState(true) | ||
const { width } = useWindowsize(); | ||
const errorType = ["All", "push", "commit", "merge", "pull", "add", "branch"]; | ||
|
||
return ( | ||
<div className="flex flex-col mx-auto mt-12 items-center gap-4 py-3 px-6 rounded-lg w-11/12 md:w-5/6"> | ||
<form | ||
onSubmit={(e) => e.preventDefault()} | ||
className="flex mx-auto mt-12 items-center gap-4 py-3 px-6 rounded-lg bg-white w-11/12 md:w-5/6" | ||
> | ||
<MdSearch className="text-gray text-2xl" /> | ||
<input | ||
type="text" | ||
id="searchbox" | ||
value={search} | ||
className="w-full text-sm md:text-base focus:outline-none placholder:font-semibold text-dark bg-transparent" | ||
placeholder="Search for errors" | ||
onChange={(e) => { setSearch(e.target.value); setType("") }} | ||
/> | ||
<button className={`focus:outline-none ${!search ? "hidden" : "block"}`} onClick={() => setSearch("")}> | ||
<MdClear className="text-gray text-xl" /> | ||
</button> | ||
</form> | ||
<div className="types mt-4"> | ||
const fadeInVariant = { | ||
hidden: { | ||
x: -100, | ||
opacity: 0, | ||
transition: { duration: 0.4, ease: "easeOut" }, | ||
}, | ||
show: { | ||
x: 0, | ||
opacity: 1, | ||
transition: { duration: 0.6, ease: "easeOut", type: "tween" }, | ||
}, | ||
}; | ||
|
||
{ | ||
width > 768 ? ( | ||
<ul className={`flex flex-col sm:flex-row mx-auto mt-2 items-start gap-4 py-3 px-6 rounded-lg bg-white w-full md:w-12/12 md:w-auto`}> | ||
{ | ||
errorType.map((item, i) => ( | ||
<li | ||
key={i} | ||
className={`${item === "add" ? "bg-[#4024e0]" : item === "commit" ? "bg-[#1a5ba5]" : item === "merge" ? "bg-[#118d7c]" : item === "push" ? "bg-[#8d54e1]" : item === "branch" ? "bg-[#40E4F0]" : "bg-[#7e1aa5]" | ||
} | ||
w-full md:w-auto rounded-md text-white font-bold py-1 px-3 cursor-pointer`} | ||
onClick={() => setType(item)} | ||
>{item}</li> | ||
)) | ||
} | ||
</ul> | ||
) : ( | ||
<div className="text-center"> | ||
<button className="bg-white py-3 pt-4 px-6 rounded-lg text-left text-black font-bold" | ||
onClick={() => setOpen(!open)}> | ||
Filter By Type | ||
</button> | ||
<ul className={`animate flex flex-col sm:flex-row mx-auto mt-2 items-start gap-4 py-3 pt-4 px-6 rounded-lg bg-white backdrop-blur-md w-[60vw] md:w-auto text-left ${open ? "hidden" : "block"}`}> | ||
{ | ||
errorType.map((item, i) => ( | ||
<li key={i} className={`${item === "add" ? "bg-[#4024e0]" : item === "commit" ? "bg-[#1a5ba5]" : item === "merge" ? "bg-[#118d7c]" : item === "push" ? "bg-[#8d54e1]" : item === "branch" ? "bg-[#40E4F0]" : "bg-[#7e1aa5]" | ||
} w-full md:w-auto rounded-md text-white font-bold py-2 px-3 cursor-pointer`} | ||
onClick={() => { setType(item); setOpen(!open) }} | ||
>{ | ||
item | ||
} | ||
|
||
</li> | ||
)) | ||
} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
function SearchInput({ search, setSearch, setType }) { | ||
const [open, setOpen] = useState(true); | ||
const { width } = useWindowsize(); | ||
|
||
</div> | ||
</div > | ||
); | ||
return ( | ||
<div className="flex flex-col mx-auto mt-12 items-center gap-4 py-3 px-6 rounded-lg w-11/12 md:w-5/6"> | ||
<form | ||
onSubmit={(e) => e.preventDefault()} | ||
className="flex mx-auto mt-12 items-center gap-4 py-3 px-6 rounded-lg bg-white w-11/12 md:w-5/6" | ||
> | ||
<MdSearch className="text-gray text-2xl" /> | ||
<input | ||
type="text" | ||
id="searchbox" | ||
value={search} | ||
className="w-full text-sm md:text-base focus:outline-none placholder:font-semibold text-dark bg-transparent" | ||
placeholder="Search for errors" | ||
onChange={(e) => { | ||
setSearch(e.target.value); | ||
setType(""); | ||
}} | ||
/> | ||
<button | ||
className={`focus:outline-none ${!search ? "hidden" : "block"}`} | ||
onClick={() => setSearch("")} | ||
> | ||
<MdClear className="text-gray text-xl" /> | ||
</button> | ||
</form> | ||
<div className="types mt-4"> | ||
{width > 768 ? ( | ||
<ul | ||
className={`flex flex-col sm:flex-row mx-auto mt-2 items-start gap-4 py-3 px-6 rounded-lg bg-white w-full md:w-12/12 md:w-auto`} | ||
> | ||
{errorType.map((item, i) => ( | ||
<li | ||
key={i} | ||
className={`${ | ||
item === "add" | ||
? "bg-[#4024e0]" | ||
: item === "commit" | ||
? "bg-[#1a5ba5]" | ||
: item === "merge" | ||
? "bg-[#118d7c]" | ||
: item === "push" | ||
? "bg-[#8d54e1]" | ||
: item === "branch" | ||
? "bg-[#40E4F0]" | ||
: "bg-[#7e1aa5]" | ||
} | ||
w-full md:w-auto rounded-md text-white font-bold py-1 px-3 cursor-pointer`} | ||
onClick={() => setType(item)} | ||
> | ||
{item} | ||
</li> | ||
))} | ||
</ul> | ||
) : ( | ||
<div className="text-center"> | ||
<button | ||
className="bg-white py-3 pt-4 px-6 rounded-lg text-left text-black font-bold" | ||
onClick={() => setOpen(!open)} | ||
> | ||
Filter By Type | ||
</button> | ||
<AnimatePresence> | ||
{!open && ( | ||
<motion.ul | ||
variants={fadeInVariant} | ||
initial="hidden" | ||
animate="show" | ||
exit="hidden" | ||
className={`flex flex-col sm:flex-row mx-auto mt-2 items-start gap-4 py-3 pt-4 px-6 rounded-lg bg-white backdrop-blur-md w-[60vw] md:w-auto text-left `} | ||
> | ||
{errorType.map((item, i) => ( | ||
<li | ||
key={i} | ||
className={`${ | ||
item === "add" | ||
? "bg-[#4024e0]" | ||
: item === "commit" | ||
? "bg-[#1a5ba5]" | ||
: item === "merge" | ||
? "bg-[#118d7c]" | ||
: item === "push" | ||
? "bg-[#8d54e1]" | ||
: item === "branch" | ||
? "bg-[#40E4F0]" | ||
: "bg-[#7e1aa5]" | ||
} w-full md:w-auto rounded-md text-white font-bold py-2 px-3 cursor-pointer`} | ||
onClick={() => { | ||
setType(item); | ||
setOpen(!open); | ||
}} | ||
> | ||
{item} | ||
</li> | ||
))} | ||
</motion.ul> | ||
)} | ||
</AnimatePresence> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default SearchInput; |
59c6a48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
github-error-solve – ./
github-error-solve.vercel.app
github-error-solve-git-main-devvsakib.vercel.app
github-error-solve-devvsakib.vercel.app