Amber Shopify Project created using ReactJS+React-Redux with GraphQL API integration. Storefront Shopify API: https://github.com/Shopify/shopify-app-js/tree/main/packages/api-clients/storefront-api-client#readme
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CarouselContainer.jsx 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React from "react";
  2. import { Box, IconButton } from "@mui/material";
  3. import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
  4. import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
  5. import mainImage2 from "../../assets/images/MAINHEADER-02.webp";
  6. import mainImage5 from "../../assets/images/MAINHEADER-05.webp";
  7. import mainImage6 from "../../assets/images/MAINHEADER-06.webp";
  8. import mainImage8 from "../../assets/images/MAINHEADER-08.webp";
  9. import mainImage11 from "../../assets/images/MAINHEADER-11.webp";
  10. import mainImage13 from "../../assets/images/MAINHEADER-13.webp";
  11. import mainImage14 from "../../assets/images/MAINHEADER-14.jpeg";
  12. import mainImageMobile from "../../assets/images/mainwallpaper-mobile.jpg";
  13. import { Carousel } from 'react-responsive-carousel';
  14. const CarouselContainer = () => {
  15. const baseItems = [
  16. { img_src: mainImage14, alt_name: "Essentials", productType: "BEAUTY" },
  17. { img_src: mainImage13, alt_name: "Eid's Time For Love", productType: "Apparel", title: "Eid's Time For Love", titles: ["EID'S TIME FOR LOVE"] },
  18. { img_src: mainImage11, alt_name: "ND X Marii for Amber", productType: "Apparel", title: "ND X Marii for Amber", titles: ["DENIM ND X MARII FOR AMBER", "ND X MARII FOR AMBER"] },
  19. { img_src: mainImage8, alt_name: "Somewhere Somehow Someone", productType: "Apparel", title: "Somewhere Somehow Someone", titles: ["SOMEWHERE SOMEHOW SOMEONE"] },
  20. { img_src: mainImage6, alt_name: "Oasis Abaya Collection", productType: "Apparel", title: "Oasis abaya", titles: ["OASIS ABAYA COLLECTION", "OASIS ABAYA"] },
  21. { img_src: mainImage5, alt_name: "Raya Romantics", productType: "Apparel", title: "Raya Romantics", titles: ["RAYA ROMANTICS", "RAYA ROMANTICS COLLECTION 2025"] },
  22. { img_src: mainImage2, alt_name: "Amber Beauty Cosmetics", productType: "BEAUTY", title: "Cosmetics", titles: ["COSMETICS"] },
  23. ];
  24. const items = [...baseItems, ...baseItems];
  25. const navigateToBanner = ({ productType, title, titles, img_src }) => {
  26. if (!productType) return;
  27. sessionStorage.setItem("amber-select-product-type", productType);
  28. sessionStorage.removeItem("amber-select-collection");
  29. sessionStorage.removeItem("amber-select-collections");
  30. if (titles?.length > 0) {
  31. sessionStorage.setItem("amber-select-collection", JSON.stringify({
  32. title,
  33. image: {
  34. url: img_src
  35. }
  36. }));
  37. sessionStorage.setItem("amber-select-collections", JSON.stringify(titles));
  38. }
  39. window.location.href = "/products";
  40. };
  41. return (
  42. <Carousel showStatus={false} autoPlay={true} infiniteLoop={true} interval={5000} showIndicators={false} stopOnHover={false}>
  43. {items?.map((item, index) => (
  44. <Box
  45. key={index}
  46. onClick={() => {
  47. if (item.clickable !== false) navigateToBanner(item);
  48. }}
  49. onKeyDown={(event) => {
  50. if (item.clickable !== false && event.key === "Enter") navigateToBanner(item);
  51. }}
  52. role={item.clickable === false ? undefined : "button"}
  53. tabIndex={item.clickable === false ? undefined : 0}
  54. sx={{
  55. width: "100%",
  56. height: "100%",
  57. cursor: item.clickable === false ? "default" : "pointer",
  58. outline: "none"
  59. }}
  60. >
  61. <Box
  62. component="img"
  63. src={item.img_src}
  64. alt={item.alt_name}
  65. sx={{
  66. width: "100%",
  67. height: "100%",
  68. zIndex: 0,
  69. filter: "brightness(0.9)",
  70. pointerEvents: "none"
  71. }}
  72. />
  73. </Box>
  74. ))}
  75. </Carousel>
  76. );
  77. };
  78. export default CarouselContainer;