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
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CarouselContainer.jsx 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 mainImage1 from "../../assets/images/MAINHEADER-01.webp";
  6. import mainImage2 from "../../assets/images/MAINHEADER-02.webp";
  7. import mainImage3 from "../../assets/images/MAINHEADER-03.webp";
  8. import mainImage4 from "../../assets/images/MAINHEADER-04.webp";
  9. import mainImage5 from "../../assets/images/MAINHEADER-05.webp";
  10. import mainImage6 from "../../assets/images/MAINHEADER-06.webp";
  11. import mainImage8 from "../../assets/images/MAINHEADER-08.webp";
  12. import mainImage10 from "../../assets/images/MAINHEADER-10.png";
  13. import mainImage11 from "../../assets/images/MAINHEADER-11.webp";
  14. import mainImage13 from "../../assets/images/MAINHEADER-13.webp";
  15. import mainImageMobile from "../../assets/images/mainwallpaper-mobile.jpg";
  16. import { Carousel } from 'react-responsive-carousel';
  17. const CarouselContainer = () => {
  18. const baseItems = [
  19. // Banner click targets. Update productType/title/titles here when changing banner destinations.
  20. { img_src: mainImage13, alt_name: "Eid's Time For Love", productType: "Apparel", title: "Eid's Time For Love", titles: ["EID'S TIME FOR LOVE"] },
  21. { img_src: mainImage11, alt_name: "ND X Marii for Amber", productType: "Apparel", title: "ND X Marii for Amber", titles: ["ND X MARII FOR AMBER"] },
  22. { img_src: mainImage10, alt_name: "Oasis Abaya", productType: "Apparel", title: "Oasis abaya", titles: ["OASIS ABAYA COLLECTION", "MIRAGE COLLECTION"] },
  23. { img_src: mainImage8, alt_name: "Somewhere Somehow Someone", productType: "Apparel", title: "Somewhere Somehow Someone", titles: ["SOMEWHERE SOMEHOW SOMEONE"] },
  24. { img_src: mainImage6, alt_name: "Oasis Abaya Collection", productType: "Apparel", title: "Oasis abaya", titles: ["OASIS ABAYA COLLECTION", "MIRAGE COLLECTION"] },
  25. { img_src: mainImage5, alt_name: "Raya Romantics", productType: "Apparel", title: "Raya Romantics", titles: ["RAYA ROMANTICS COLLECTION 2025"] },
  26. // { img_src: mainImage3, alt_name: "Amber Home", productType: "HOME" },
  27. { img_src: mainImage3, alt_name: "Amber Home", clickable: false },
  28. // { img_src: mainImage4, alt_name: "Amber Beauty Fragrance", productType: "BEAUTY", title: "Fragrances", titles: ["FRAGRANCES"] },
  29. { img_src: mainImage4, alt_name: "Amber Beauty Fragrance", clickable: false },
  30. { img_src: mainImage2, alt_name: "Amber Beauty Cosmetics", productType: "BEAUTY", title: "Cosmetics", titles: ["COSMETICS"] },
  31. { img_src: mainImage1, alt_name: "Amber Apparel", clickable: false },
  32. ];
  33. const items = [...baseItems, ...baseItems];
  34. const navigateToBanner = ({ productType, title, titles, img_src }) => {
  35. if (!productType) return;
  36. sessionStorage.setItem("amber-select-product-type", productType);
  37. sessionStorage.removeItem("amber-select-collection");
  38. sessionStorage.removeItem("amber-select-collections");
  39. if (titles?.length > 0) {
  40. sessionStorage.setItem("amber-select-collection", JSON.stringify({
  41. title,
  42. image: {
  43. url: img_src
  44. }
  45. }));
  46. sessionStorage.setItem("amber-select-collections", JSON.stringify(titles));
  47. }
  48. window.location.href = "/products";
  49. };
  50. return (
  51. <Carousel showStatus={false} autoPlay={true} infiniteLoop={true} interval={5000} showIndicators={false} stopOnHover={false}>
  52. {items?.map((item, index) => (
  53. <Box
  54. key={index}
  55. onClick={() => {
  56. if (item.clickable !== false) navigateToBanner(item);
  57. }}
  58. onKeyDown={(event) => {
  59. if (item.clickable !== false && event.key === "Enter") navigateToBanner(item);
  60. }}
  61. role={item.clickable === false ? undefined : "button"}
  62. tabIndex={item.clickable === false ? undefined : 0}
  63. sx={{
  64. width: "100%",
  65. height: "100%",
  66. cursor: item.clickable === false ? "default" : "pointer",
  67. outline: "none"
  68. }}
  69. >
  70. {/*
  71. Old image-click code:
  72. <Box
  73. component="img"
  74. src={item.img_src}
  75. alt={item.alt_name}
  76. onClick={() => navigateToBanner(item)}
  77. sx={{
  78. width: "100%",
  79. height: "100%",
  80. zIndex: 0,
  81. filter: "brightness(0.9)",
  82. cursor: item.clickable === false ? "default" : "pointer"
  83. }}
  84. />
  85. */}
  86. <Box
  87. component="img"
  88. src={item.img_src}
  89. alt={item.alt_name}
  90. sx={{
  91. width: "100%",
  92. height: "100%",
  93. zIndex: 0,
  94. filter: "brightness(0.9)",
  95. pointerEvents: "none"
  96. }}
  97. />
  98. </Box>
  99. ))}
  100. </Carousel>
  101. );
  102. };
  103. export default CarouselContainer;