From 9cdc8f87824eb877329be5354dbb15089dc92b88 Mon Sep 17 00:00:00 2001 From: ali josheghani Date: Thu, 30 May 2024 16:16:18 +0330 Subject: [PATCH] feat : add rabbit animation form --- package-lock.json | 30 +++++ package.json | 1 + src/pages/login/components/Rabbit.tsx | 162 ++++++++++++++++++++++++++ src/types/props.d.ts | 11 +- 4 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 src/pages/login/components/Rabbit.tsx diff --git a/package-lock.json b/package-lock.json index 6d60150..a5727b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@tsparticles/react": "^3.0.0", "@tsparticles/slim": "^3.4.0", "country-flag-icons": "^1.5.11", + "framer-motion": "^11.2.9", "nprogress": "^0.2.0", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -2847,6 +2848,30 @@ "url": "https://github.com/sponsors/rawify" } }, + "node_modules/framer-motion": { + "version": "11.2.9", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.2.9.tgz", + "integrity": "sha512-gfxNSkp4dC3vpy2hGNQK3K9bNOKwfasqOhrqvmZzYxCPSJ9Tpv/9JlCkeCMgFdKefgPr8+JiouGjVmaDzu750w==", + "dependencies": { + "tslib": "^2.4.0" + }, + "peerDependencies": { + "@emotion/is-prop-valid": "*", + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4326,6 +4351,11 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "dev": true }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index fd748ec..c25f4cf 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@tsparticles/react": "^3.0.0", "@tsparticles/slim": "^3.4.0", "country-flag-icons": "^1.5.11", + "framer-motion": "^11.2.9", "nprogress": "^0.2.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/pages/login/components/Rabbit.tsx b/src/pages/login/components/Rabbit.tsx new file mode 100644 index 0000000..83790ae --- /dev/null +++ b/src/pages/login/components/Rabbit.tsx @@ -0,0 +1,162 @@ +import { motion } from "framer-motion"; +import { useEffect, useState } from "react"; + +const Rabbit = ({ + focusInputText, + focusInputPassword, +}: { + focusInputText?: boolean; + focusInputPassword?: boolean; +}) => { + const [text, setText] = useState(false); + const [password, setPassword] = useState(false); + + useEffect(() => { + if (focusInputText) { + setText(true); + } else { + setText(false); + } + }, [focusInputText]); + + useEffect(() => { + if (focusInputPassword) { + setPassword(true); + } else { + setPassword(false); + } + }, [focusInputPassword]); + + return ( + + + + + + + + + + + + + + + + + + {!password && ( + <> + + + + )} + {password && ( + <> + + + + )} + + + + ); +}; + +export default Rabbit; diff --git a/src/types/props.d.ts b/src/types/props.d.ts index da968b1..924b506 100644 --- a/src/types/props.d.ts +++ b/src/types/props.d.ts @@ -50,7 +50,7 @@ export interface NavData { } // begin ListTutorial.tsx -import { Component, SetStateAction } from "react"; +import { Component, InputHTMLAttributes, SetStateAction } from "react"; export type TutorialList = { id: number; name: string }[]; @@ -85,3 +85,12 @@ interface ProductBoxProps { btnText: string; variant: number; } + +interface InputProps extends InputHTMLAttributes { + label: string; + id?: string; + type: string; + name?: string; + placeholder?: string; + extra?: string; +}