-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from mvhacks/noam-carousel
Made Carousel Show Multiple Images at Once
- Loading branch information
Showing
4 changed files
with
78 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,67 @@ | ||
import AwesomeSlider from "react-awesome-slider"; | ||
import "react-awesome-slider/dist/styles.css"; | ||
import React from "react"; | ||
import Carousel from "react-multi-carousel"; | ||
import "react-multi-carousel/lib/styles.css"; | ||
|
||
const slider = ( | ||
<AwesomeSlider | ||
className="slider" | ||
bullets={false} /*cssModule={AwesomeSliderStyles}*/ | ||
> | ||
<div data-src="/presentation.jpg" /> | ||
<div data-src="/mrnguyen.jpg" /> | ||
<div data-src="/hackers.jpg" /> | ||
<div data-src="/food.jpg" /> | ||
<div data-src="/awards.jpg" /> | ||
</AwesomeSlider> | ||
); | ||
function ImageCarousel() { | ||
const images = [ | ||
{ src: "/presentation.jpg", alt: "Presentation" }, | ||
{ src: "/mrnguyen.jpg", alt: "Mr. Nguyen" }, | ||
{ src: "/hackers.jpg", alt: "Hackers" }, | ||
{ src: "/food.jpg", alt: "Food" }, | ||
{ src: "/awards.jpg", alt: "Awards" }, | ||
]; | ||
|
||
export default function Carousel() { | ||
return slider; | ||
const responsive = { | ||
desktop: { | ||
breakpoint: { max: 3000, min: 1024 }, | ||
items: 3, | ||
}, | ||
tablet: { | ||
breakpoint: { max: 1024, min: 464 }, | ||
items: 2, | ||
}, | ||
mobile: { | ||
breakpoint: { max: 464, min: 0 }, | ||
items: 1, | ||
}, | ||
}; | ||
|
||
return ( | ||
<div style={{ margin: "0 auto", maxWidth: "1200px" }}> | ||
<Carousel | ||
responsive={responsive} | ||
infinite | ||
autoPlay | ||
autoPlaySpeed={3000} | ||
arrows | ||
showDots={false} | ||
swipeable | ||
draggable | ||
containerClass="carousel-container" | ||
> | ||
{images.map((image, index) => ( | ||
<div | ||
key={index} | ||
style={{ | ||
padding: "10px", | ||
boxSizing: "border-box", | ||
textAlign: "center", | ||
}} | ||
> | ||
<img | ||
src={image.src} | ||
alt={image.alt} | ||
style={{ | ||
width: "100%", | ||
height: "auto", | ||
borderRadius: "8px", | ||
}} | ||
/> | ||
</div> | ||
))} | ||
</Carousel> | ||
</div> | ||
); | ||
} | ||
|
||
export default ImageCarousel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters