diff --git a/index.css b/index.css index 28842c5..2702cbe 100644 --- a/index.css +++ b/index.css @@ -11,6 +11,7 @@ body,html { max-width: 100vw; } + a { color: inherit; text-decoration: none; @@ -480,3 +481,6 @@ a { } +.none { + display: none; +} \ No newline at end of file diff --git a/src/components/CommonShimmer.js b/src/components/CommonShimmer.js new file mode 100644 index 0000000..6c160cc --- /dev/null +++ b/src/components/CommonShimmer.js @@ -0,0 +1,152 @@ + +/** +* +* +* This component is not live, just using for trying reusing exisiting RestaurantCard and RestaurantMenu Components +* to generate Shimmer as well +* It's working fine but looks complicated and does not follow Single responsibility principle of component +* Here, the same component acts as both shimmer and actual component +* +*/ + + + +import { SHIMMER_RES_CARDS_COUNT } from '../config'; + +import {RES_IMG_CDN } from "../config"; +import { AiFillStar } from "react-icons/ai"; + + + +export const RestaurantShimmer = (props) => { + let shimmer = false; + const {name, cuisines, cloudinaryImageId, avgRating, slaString, costForTwoString} = props; + const buttonStyle = { + backgroundColor: avgRating == "--" ? "#fff" : parseFloat(avgRating) < 4.0 ? "#db7c38":"#48c479", + color : isNaN(avgRating)? "#535665" : "#fff" + } + + if(props.type == "shimmer") { + shimmer = true; + } + return ( +
+ {shimmer ?
: + {name}/ + } +
+
{name? name : ""}
+

{cuisines ? cuisines.join(", ") : ""}

+
+
+
+ {avgRating? avgRating : ""} +
+
+
{slaString? slaString : ""}
+
+
{costForTwoString? costForTwoString : ""}
+
+
+
+
+ + ); +}; + + +export const MenuShimmer = () => { + let shimmer = false; + if(props.type == "shimmer") { + shimmer = true; + } + return ( +
+
+ {shimmer ? + : {restaurant?.name}/ } +
+

{restaurant?.name}

+

{restaurant?.cuisines.join(", ")}

+
+
+
+ {restaurant?.avgRating} +
+
|
+
{restaurant?.sla.slaString}
+
|
+
{restaurant?.costForTwoMsg}
+
+
+
+
+ +
+
+
+

Recommended

+

{Object.keys(restaurant?.menu?.items).length} ITEMS

+
+
+ { shimmer ? Array.from({length:SHIMMER_RES_CARDS_COUNT}).map( (element, index) => + ) : + Object.values(restaurant?.menu?.items).map( item => + + ) + } +
+
+
+ +
+
+ ) +} + +export const ShimmerMenuItem = () => { + return ( +
+
+

+

+

+
+
+ +
+
+
+ ) +} + +export const MenuItem = () => { + return ( +
+
+

{item?.name}

+

{(item?.price > 0) ? + new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR'}).format(item?.price/100 ): " " }

+

{item?.description}

+
+
+ { item?.cloudinaryImageId && {item?.name}/ } + +
+
+ ) +} + + +const CommonShimmer = () => { + return ( +
+ {Array.from({length:SHIMMER_RES_CARDS_COUNT}).map((element, index) => { + return + }) } +
+ ) +} + +export default CommonShimmer; \ No newline at end of file diff --git a/src/components/Contact.js b/src/components/Contact.js index 087e458..73c12c2 100644 --- a/src/components/Contact.js +++ b/src/components/Contact.js @@ -1,6 +1,7 @@ +import { useState } from "react"; const Contact = () => { - return ( + return(
Contact