diff --git a/src/animations/search.animation.ts b/src/animations/search.animation.ts new file mode 100644 index 0000000..3011609 --- /dev/null +++ b/src/animations/search.animation.ts @@ -0,0 +1,15 @@ +// Types +import { Variants } from "framer-motion"; + +export const searchMotion: Variants = { + rest: { + transform: "translateY(0rem)", + opacity: 1, + type: "spring", + }, + active: { + transform: "translateX(6rem)", + opacity: 0, + type: "tween", + }, +}; diff --git a/src/components/header/Search.tsx b/src/components/header/Search.tsx index da4b780..1389bdc 100644 --- a/src/components/header/Search.tsx +++ b/src/components/header/Search.tsx @@ -1,7 +1,15 @@ +// Modules +import { useState } from "react"; +import { motion } from "framer-motion"; + +// Animations +import { searchMotion } from "../../animations/search.animation"; + // Icons import { ReactComponent as Loop } from "../../assets/icons/loop.svg"; const Search = () => { + const [input, setInput] = useState(""); return (
{ event.preventDefault() } > - -
- + ) => + setInput(event.target.value) + } + /> + 0 ? "active" : "rest"} + variants={searchMotion} + > + + + Search anything... -
+
); }; diff --git a/src/styles/_nav.scss b/src/styles/_nav.scss index 0496c41..a5c8b92 100644 --- a/src/styles/_nav.scss +++ b/src/styles/_nav.scss @@ -9,6 +9,7 @@ } .search { + overflow: hidden; position: relative; input { border: 0.1rem solid $gray-dark;