File size: 9,022 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
import React from 'react'
import "./Home.css"
import Product from '../Product/Product'
import { toast } from 'react-toastify';
import { useEffect } from 'react'
import faker from 'faker'
import { ToastContainer } from 'react-toastify';
const Home = () => {
useEffect(() => (
slider(0)
), [])
return (
<div className="home">
<div className="home__container">
{/* Image Banner */}
<div className="home__toast-container">
<ToastContainer />
</div>
<div className="home__slider-container">
<div className="home__slide">
<img
className="home__image "
src="https://images-eu.ssl-images-amazon.com/images/G/31/skillsstore/2020/August/Medh_Alexa_GW_3000x1200._CB405585145_.jpg"
alt="image0" />
</div>
<div className="home__slide">
<img
className="home__image "
src="https://images-eu.ssl-images-amazon.com/images/G/31/img17/AmazonDevices/2019/Post_AugArt/GW_Echo_PC_2x_V2._CB405879256_.jpg"
alt="image1" />
</div>
<div className="home__slide">
<img
className="home__image"
src="https://images-eu.ssl-images-amazon.com/images/G/31/img20/Wireless/SamsungM/M51/8thSept_GW/P38983965_IN_WLME_SamsungGalaxy_M51_New_Launch_DesktopTallHero_2_1500x600._CB405103024_.jpg"
alt="image2" />
</div>
<div className="home__slide">
<img
className="home__image"
src="https://images-eu.ssl-images-amazon.com/images/G/31/AmazonVideo/2020/X-site/Multititle/Aug/1500x600_Hero-Tall_np._CB404803728_.jpg"
alt="image3" />
</div>
<div className="home__slide">
<img
className="home__image"
src="https://images-eu.ssl-images-amazon.com/images/G/31/AmazonVideo/2020/X-site/SingleTitle/TheBoyss2/3000x1200_Hero-Tall_p._CB404993994_.jpg"
alt="image4" />
</div>
<div className="home__slide">
<img
className="home__image"
src="https://images-eu.ssl-images-amazon.com/images/G/31/img20/Wireless/SamsungM/M51/GWTO/Pre_Launch/P38983965_IN_WLME_SamsungGalaxy_M51_New_Launch_M51_tallhero_1500x600_1._CB405468917_.jpg"
alt="image5" />
</div>
<div className="home__slide">
<img
className="home__image"
src="https://images-eu.ssl-images-amazon.com/images/G/31/img19/AmazonPay/Rajeshwari/September/GWBanners/Control/DesktopHero_1500x600._CB405007888_.jpg"
alt="image6" />
</div>
</div>
{/* Product id, title, price, rating, image */}
<div className="home__row">
{/* Product */}
<Product
id={12320}
title="The Lean Startup"
price={10}
rating={4.5}
image="https://images-na.ssl-images-amazon.com/images/I/51Zymoq7UnL._AC_SY400_.jpg"
/>
<Product
id={12321}
title="Apple Watch Series 3 (GPS, 42mm) - Space Grey Aluminium Case with Black Sport Band"
price={20}
rating={5}
image="https://images-eu.ssl-images-amazon.com/images/I/41RLXO5JUhL._AC_SX368_.jpg"
/>
<Product
id={12334}
title="Amazon Echo (3rd generation) | Smart speaker with Alexa, Charcoal Fabric"
price={98.99}
rating={3.5}
image="https://media.very.co.uk/i/very/P6LTG_SQ1_0000000071_CHARCOAL_SLf?$300x400_retinamobilex2$"
/>
</div>
<div className="home__row">
{/* Product */}
<Product
id={12323}
title="Samsung LC49RG90SSUXEN 49' Curved LED Gaming Monitor"
price={199.99}
rating={3}
image="https://images-na.ssl-images-amazon.com/images/I/71Swqqe7XAL._AC_SX466_.jpg"
/>
<Product
id={12324}
title="Amazon Echo (3rd generation) | Smart speaker with Alexa, Charcoal Fabric"
price={98.99}
rating={2}
image="https://media.very.co.uk/i/very/P6LTG_SQ1_0000000071_CHARCOAL_SLf?$300x400_retinamobilex2$"
/>
<Product
id={3254354345}
title="New Apple iPad Pro (12.9-inch, Wi-Fi, 128GB) - Silver (4th Generation)"
price={598.99}
rating={4}
image="https://images-na.ssl-images-amazon.com/images/I/816ctt5WV5L._AC_SX385_.jpg"
/>
</div>
<div className="home__row">
{/* Product */}
<Product
id={90829332}
title="Samsung LC49RG90SSUXEN 49' Curved LED Gaming Monitor - Super Ultra Wide Dual WQHD 5120 x 1440"
price={1094.98}
rating={4}
image="https://images-na.ssl-images-amazon.com/images/I/6125mFrzr6L._AC_SX355_.jpg"
/>
</div>
<div className="home__row">
{/* Product */}
<Product
id={12326}
title="Apple Watch Series 3 (GPS, 42mm) - Space Grey Aluminium Case with Black Sport Band"
price={20}
rating={5}
image="https://images-eu.ssl-images-amazon.com/images/I/41RLXO5JUhL._AC_SX368_.jpg"
/>
<Product
id={12328}
title="New Apple iPad Pro (12.9-inch, Wi-Fi, 128GB) - Silver (4th Generation)"
price={598.99}
rating={4}
image="https://images-na.ssl-images-amazon.com/images/I/816ctt5WV5L._AC_SX385_.jpg"
/>
<Product
id={12327}
title="Amazon Echo (3rd generation) | Smart speaker with Alexa, Charcoal Fabric"
price={98.99}
rating={5}
image="https://media.very.co.uk/i/very/P6LTG_SQ1_0000000071_CHARCOAL_SLf?$300x400_retinamobilex2$"
/>
<Product
id={12329}
title="The Lean Startup"
price={10}
rating={4.5}
image="https://images-na.ssl-images-amazon.com/images/I/51Zymoq7UnL._AC_SY400_.jpg"
/>
</div>
</div>
</div>
)
}
function slider(counter) {
const slides = document.querySelectorAll(".home__image");
slides.forEach((slide, index) => {
if (index !== counter) {
slide.style.visibility = `hidden`
slide.classList.add(`image-${index}`)
}
})
moveCorousal(counter, slides, slides.length)
}
function moveCorousal(counter, slides, len) {
if (slides) {
if (counter >= len - 1)
counter = 0
else
counter += 1
slides.forEach((slide, index) => {
if (index === counter) {
slide.style.visibility = `visible`
}
else {
slide.style.visibility = `hidden`
}
})
}
setTimeout(() => {
moveCorousal(counter, slides, len);
}, 5000)
parseInt(counter) % 5 === 0 ? (
setTimeout(() => {
toast.info(`${faker.name.findName()} added new product to cart`, {
position: "bottom-left"
});
}, 10500)
) : (
setTimeout(() => {
}, 21000)
)
}
export default Home
|