Skip to content

Commit

Permalink
make the embla carousel responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
S-e-b-a-s committed Sep 10, 2024
1 parent 45a607f commit 75fbbaf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"cally": "^0.7.1",
"depcheck": "^1.4.7",
"embla-carousel-autoplay": "^8.2.1",
"embla-carousel-class-names": "^8.2.1",
"embla-carousel-fade": "^8.2.1",
"embla-carousel-react": "^8.2.1",
"formik": "^2.4.6",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/components/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ const Home = () => {

return (
<>
<Box sx={{ display: "flex", mt: "5.5rem", px: "2rem", textAlign: "center", justifyContent: "center" }}>
{/* <Box sx={{ display: "flex", mt: "5.5rem", px: "2rem", textAlign: "center", justifyContent: "center" }}>
<CarouselComponent items={homeImages} contain={true} height={matches ? "648px" : "480px"} width={matches ? "1152px" : "854px"} />
</Box>
{/* <Box sx={{ mt: "6rem", display: "flex", alignItems: "center", justifyContent: "center" }}>
<EmblaCarousel />
</Box> */}
<Box sx={{ mt: "6rem", display: "flex", alignItems: "center", justifyContent: "center" }}>
<EmblaCarousel />
</Box>
<Container sx={{ display: "flex", flexDirection: "column", gap: "2rem", mt: "2rem" }}>
<Typography
color="primary"
Expand Down
23 changes: 12 additions & 11 deletions src/components/shared/EmblaCarousel.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import React from "react";
// Libraries
import useEmblaCarousel from "embla-carousel-react";
import Autoplay from "embla-carousel-autoplay";

// Images
import depression from "../../images/home-carousel/depression.png";
import password from "../../images/home-carousel/password.png";
import water from "../../images/home-carousel/water.png";
import Autoplay from "embla-carousel-autoplay";
import Fade from "embla-carousel-fade";

export function EmblaCarousel() {
const [emblaRef] = useEmblaCarousel({ loop: true }, [Autoplay({ delay: 4000, stopOnInteraction: false })], [Fade()]);
const [emblaRef] = useEmblaCarousel({ loop: true }, [Autoplay({ delay: 4000, stopOnInteraction: false })]);

return (
<div className="embla" style={{ overflow: "hidden" }} ref={emblaRef}>
<div className="embla" style={{ overflow: "hidden", padding: "2rem" }} ref={emblaRef}>
<div className="embla__container" style={{ display: "flex", maxWidth: "1280px" }}>
<div style={{ flex: "0 0 auto", minWidth: 0, maxWidth: "100%", margin: "20px 20px 0 0" }} className="embla__slide">
<img style={{ borderRadius: "1.8rem" }} src={depression} alt="depression" />
<div style={{ flex: "0 0 auto", minWidth: 0, maxWidth: "100%", margin: "20px 20px 0 0" }} className="embla__slide ">
<img width={"100%"} style={{ borderRadius: "1.8rem" }} src={depression} alt="depression" />
</div>
<div style={{ flex: "0 0 auto", minWidth: 0, maxWidth: "100%", margin: "20px 20px 0 0" }} className="embla__slide">
<img style={{ borderRadius: "1.8rem" }} src={password} alt="password" />
<div style={{ flex: "0 0 auto", minWidth: 0, maxWidth: "100%", margin: "20px 20px 0 0" }} className="embla__slide ">
<img width={"100%"} style={{ borderRadius: "1.8rem" }} src={password} alt="password" />
</div>
<div style={{ flex: "0 0 auto", minWidth: 0, maxWidth: "100%", margin: "20px 20px 0 0" }} className="embla__slide">
<img style={{ borderRadius: "1.8rem" }} src={water} alt="water" />
<div style={{ flex: "0 0 auto", minWidth: 0, maxWidth: "100%", margin: "20px 20px 0 0" }} className="embla__slide ">
<img width={"100%"} style={{ borderRadius: "1.8rem" }} src={water} alt="water" />
</div>
</div>
</div>
Expand Down

0 comments on commit 75fbbaf

Please sign in to comment.