-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslider2.jsx
95 lines (83 loc) · 3.73 KB
/
slider2.jsx
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
import Carousel from "react-elastic-carousel";
import React, { useState } from 'react';
import sliderData2 from "./slider2-data";
import './cards.css'
import './App.css'
import StarIcon from '@material-ui/icons/Star';
import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled';
import 'react-responsive-modal/styles.css';
import { Modal } from 'react-responsive-modal';
import EventIcon from '@material-ui/icons/Event';
import GetAppIcon from '@material-ui/icons/GetApp';
import PlayArrowIcon from '@material-ui/icons/PlayArrow';
import './slider1.css'
const SlideChild = ({ title, desc, img, likes, category }) => {
const [open, setOpen] = useState(false);
const onOpenModal = () => setOpen(true);
const onCloseModal = () => setOpen(false);
return (
<>
<div class="wrapper">
<div class="cards">
<figure class="card">
<img src={img} className="img" />
<p className="card_rating"><StarIcon className="star" />{likes}</p>
<figcaption><PlayCircleFilledIcon className="play" /></figcaption>
</figure>
</div>
<p className='name' onClick={onOpenModal}>{title} </p>
<Modal open={open} onClose={onCloseModal} center className="model" styles={{ modal: { background: "#000", border: "1px solid #fff" }, closeIcon: { background: "#fff" }, overlay: { background: "#000" } }}>
<div className="modal-main">
<div className="modal-row1 left">
<div className="modal-img">
<img src={img} className="modal-img" />
</div>
</div>
<div className="modal-title modal-row2 right">
<h2 className="modal-title">{title}</h2>
<EventIcon className="cal" /> <p className='modal-cat'>{category}</p>
<p className='modal-desc'>{desc}</p>
</div>
<div className="buttons">
<button className="but1"><PlayArrowIcon className="download" />Watch Now</button>
<button className="but2"><GetAppIcon className="download" />Download</button>
</div>
</div>
</Modal>
<a className='category'>{category}</a>
</div>
</>
)
}
const Slider2 = () => {
const carouselRef = React.useRef(null);
const onNextStart = (currentItem, nextItem) => {
if (currentItem.index === nextItem.index) {
carouselRef.current.goTo(0);
}
};
const onPrevStart = (currentItem, nextItem) => {
if (currentItem.index === nextItem.index) {
carouselRef.current.goTo(sliderData2.length);
}
};
const breakpoints = [
{ width: 1, itemsToShow: 2, itemsToScroll: 1 },
{ width: 550, itemsToShow: 5, itemsToScroll: 1 },
{ width: 850, itemsToShow: 5, itemsToScroll: 1 },
{ width: 1150, itemsToShow: 5, itemsToScroll: 1 },
{ width: 1450, itemsToShow: 5, itemsToScroll: 1 },
{ width: 1750, itemsToShow: 5, itemsToScroll: 1 },
];
const products = sliderData2.map(product => (
<SlideChild desc={product.desc} title={product.title} img={product.img} likes={product.likes} category={product.category} />
));
return (
<>
<Carousel enableSwipe={true} breakPoints = {breakpoints} enableAutoPlay autoPlaySpeed={3000} className="slider1" ref={carouselRef}onPrevStart={onPrevStart}onNextStart={onNextStart} disableArrowsOnEnd={false} >
{products}
</Carousel>
</>
)
};
export default Slider2;