From 4e6d49a3b917f2aa7c081e8ca1cd64f1f3fd2fb2 Mon Sep 17 00:00:00 2001 From: Abhishek Subba Date: Sun, 29 Oct 2023 20:26:00 +0530 Subject: [PATCH] add wiggle anim to heart --- index.css | 28 ++++- src/components/RestruarantCards.js | 178 +++++++++++++++-------------- tailwind.config.js | 26 +++-- 3 files changed, 133 insertions(+), 99 deletions(-) diff --git a/index.css b/index.css index bd6213e..1d17a75 100644 --- a/index.css +++ b/index.css @@ -1,3 +1,25 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind base; +@tailwind components; +@tailwind utilities; + +@keyframes wiggle-scale { + 0% { + transform: rotate(-10deg) scale(1); + } + 25% { + transform: scale(1.5); + } + 50% { + transform: rotate(10deg) scale(0.9); + } + 75% { + transform: scale(1.1); + } + 100% { + transform: rotate(-10deg) scale(1); + } +} + +.wiggle-scale { + animation: wiggle-scale 500ms ease-in-out; +} diff --git a/src/components/RestruarantCards.js b/src/components/RestruarantCards.js index 8535850..0e414a3 100644 --- a/src/components/RestruarantCards.js +++ b/src/components/RestruarantCards.js @@ -1,88 +1,90 @@ -import React, { useState } from "react"; -import { CDN_URL } from "../utils/constants"; -import { AiOutlineHeart, AiFillHeart } from "react-icons/ai"; -import { Link } from "react-router-dom"; - -const RestruarantCards = (props) => { - const { resData, id, favlist, onClickFav } = props; - const [isfav, setfav] = useState(favlist.indexOf(id) > -1); - const { - cloudinaryImageId, - name, - avgRating, - cuisines, - slaString, - costForTwo, - aggregatedDiscountInfo, - } = resData; - return ( -
- -
- - { - setfav(!isfav); - onClickFav(id); - e.preventDefault(); - }} - > - - - -
-
-

{name}

- {cuisines.join(", ")} -
-
= 4 - ? "bg-green-500" - : avgRating >= 2 - ? "bg-amber-500" - : "bg-red-500" - } font-semibold`} - > - - - {avgRating === "--" ? "4.2" : avgRating} - -
- {slaString} -
- {costForTwo} -
-
-
- -
- - {!aggregatedDiscountInfo?.shortDescriptionList[0]?.meta - ? "30% off | Use NEWFUD" - : aggregatedDiscountInfo?.shortDescriptionList[0]?.meta} - -
-
- -
- ); -}; - -export default RestruarantCards; +import React, { useState } from "react"; +import { CDN_URL } from "../utils/constants"; +import { AiOutlineHeart, AiFillHeart } from "react-icons/ai"; +import { Link } from "react-router-dom"; + +const RestruarantCards = (props) => { + const { resData, id, favlist, onClickFav } = props; + const [isfav, setfav] = useState(favlist.indexOf(id) > -1); + const [wiggleEffect, setWiggleEffect] = useState(false); + const { + cloudinaryImageId, + name, + avgRating, + cuisines, + slaString, + costForTwo, + aggregatedDiscountInfo, + } = resData; + return ( +
+ +
+ + { + setfav(!isfav); + onClickFav(id); + setWiggleEffect(!wiggleEffect); + e.preventDefault(); + }} + > + + + +
+
+

{name}

+ {cuisines.join(", ")} +
+
= 4 + ? "bg-green-500" + : avgRating >= 2 + ? "bg-amber-500" + : "bg-red-500" + } font-semibold`} + > + + + {avgRating === "--" ? "4.2" : avgRating} + +
+ {slaString} +
+ {costForTwo} +
+
+
+ +
+ + {!aggregatedDiscountInfo?.shortDescriptionList[0]?.meta + ? "30% off | Use NEWFUD" + : aggregatedDiscountInfo?.shortDescriptionList[0]?.meta} + +
+
+ +
+ ); +}; + +export default RestruarantCards; diff --git a/tailwind.config.js b/tailwind.config.js index 19973dd..f42c4ec 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,8 +1,18 @@ -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: ["./src/**/*.{html,js}"], - theme: { - extend: {}, - }, - plugins: [], -}; +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ["./src/**/*.{html,js}"], + theme: { + extend: { + keyframes: { + wiggle: { + "0%, 100%": { transform: "rotate(-3deg)" }, + "50%": { transform: "rotate(3deg)" }, + }, + }, + animation: { + wiggle: "wiggle 1s ease-in-out", + }, + }, + }, + plugins: [], +};