diff --git a/components/Header/header.js b/components/Header/header.js index dc651469..35ea77a9 100644 --- a/components/Header/header.js +++ b/components/Header/header.js @@ -2,7 +2,7 @@ import React from 'react'; import Heading from '../Typography/heading'; import Paragraph from '../Typography/paragraph'; import Button from '../Buttons/button'; -import ReactSlider from '../Slider/slider'; +import EmblaCarousel from '../Slider/slider'; import cities from '../../config/city-lists.json'; import Venue from '../Venue/venue'; import Announcement from '../announcement'; @@ -11,6 +11,10 @@ import { useMediaQuery } from 'react-responsive'; function Header() { const isMobile = useMediaQuery({ maxWidth: '590px' }); + const SLIDES = cities.map((city) => { + return ; + }) + return (
@@ -46,11 +50,7 @@ function Header() {
- - {cities.map((city) => { - return ; - })} - +
); diff --git a/components/Slider/slider.js b/components/Slider/slider.js index 0b46545e..b4d4aa14 100644 --- a/components/Slider/slider.js +++ b/components/Slider/slider.js @@ -1,39 +1,44 @@ -import Slider from 'react-slick'; -import Arrow from '../illustration/arrow'; -import React, { useEffect, useState, useRef } from 'react'; +import React, { useCallback, useEffect, useState } from 'react' +import useEmblaCarousel from 'embla-carousel-react' +import AutoScroll from 'embla-carousel-auto-scroll' import { useMediaQuery } from 'react-responsive'; -function ReactSlider({ children }) { + +function EmblaCarousel({ slides }) { const isMobile = useMediaQuery({ maxWidth: '590px' }); - const [slides, setSlides] = useState(1); + + const scrollOptions = { + playOnInit: true, + stopOnInteraction: false, + stopOnMouseEnter: true, + startDelay: 200, + speed: 1 + } - useEffect(() => { - if (isMobile) { - setSlides(1); - } - }, [isMobile]); - const slider = useRef(null); - const settings = { - slidesToScroll: slides, - infinite: true, - autoplay: true, - speed: 10000, - autoplaySpeed: 0, - centerMode: true, - cssEase: 'linear', - variableWidth: isMobile ? false : true, - arrows: false, - }; + const options = { + loop: true, + dragFree: true + } + + const [emblaRef] = useEmblaCarousel({ ...options }, [ + AutoScroll({ ...scrollOptions }) + ]); return ( <> - { children.length > 4 || isMobile ? - ( - {children} - ):( -
{children}
)} - + {slides.length > 4 || isMobile ? ( +
+
+ {slides.map((item, idx) => ( +
{item}
+ ))} +
+
+ ) : ( +
{slides}
+ )} + ); } -export default ReactSlider; +export default EmblaCarousel; diff --git a/package-lock.json b/package-lock.json index ec36abc8..d9c650b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ "@googleapis/sheets": "^7.0.0", "axios": "^1.7.4", "d3": "^7.8.5", + "embla-carousel-auto-scroll": "^8.5.1", + "embla-carousel-react": "^8.5.1", "lucide-react": "^0.350.0", "net": "^1.0.2", "next": "^14.2.10", @@ -26,7 +28,6 @@ "react-hot-toast": "^2.4.1", "react-responsive": "^9.0.0", "react-select": "^5.7.5", - "react-slick": "^0.29.0", "react-youtube-embed": "^1.0.3", "slick-carousel": "^1.8.1" }, @@ -2100,10 +2101,6 @@ "node": ">=8" } }, - "node_modules/classnames": { - "version": "2.3.2", - "license": "MIT" - }, "node_modules/clean-stack": { "version": "2.2.0", "dev": true, @@ -2900,6 +2897,42 @@ "dev": true, "license": "ISC" }, + "node_modules/embla-carousel": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.5.1.tgz", + "integrity": "sha512-JUb5+FOHobSiWQ2EJNaueCNT/cQU9L6XWBbWmorWPQT9bkbk+fhsuLr8wWrzXKagO3oWszBO7MSx+GfaRk4E6A==" + }, + "node_modules/embla-carousel-auto-scroll": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/embla-carousel-auto-scroll/-/embla-carousel-auto-scroll-8.5.1.tgz", + "integrity": "sha512-fbkZ5+kPHJnJ0aVhRClodnBuaWp8RvV/AW4ex+YhXtvkTld9ApAxmyKQsZzycQc24uz15kzyRjSTNfEvzXPYuQ==", + "license": "MIT", + "peerDependencies": { + "embla-carousel": "8.5.1" + } + }, + "node_modules/embla-carousel-react": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/embla-carousel-react/-/embla-carousel-react-8.5.1.tgz", + "integrity": "sha512-z9Y0K84BJvhChXgqn2CFYbfEi6AwEr+FFVVKm/MqbTQ2zIzO1VQri6w67LcfpVF0AjbhwVMywDZqY4alYkjW5w==", + "license": "MIT", + "dependencies": { + "embla-carousel": "8.5.1", + "embla-carousel-reactive-utils": "8.5.1" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.1 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" + } + }, + "node_modules/embla-carousel-reactive-utils": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/embla-carousel-reactive-utils/-/embla-carousel-reactive-utils-8.5.1.tgz", + "integrity": "sha512-n7VSoGIiiDIc4MfXF3ZRTO59KDp820QDuyBDGlt5/65+lumPHxX2JLz0EZ23hZ4eg4vZGUXwMkYv02fw2JVo/A==", + "license": "MIT", + "peerDependencies": { + "embla-carousel": "8.5.1" + } + }, "node_modules/emoji-regex": { "version": "9.2.2", "dev": true, @@ -2924,10 +2957,6 @@ "node": ">=10.13.0" } }, - "node_modules/enquire.js": { - "version": "2.1.6", - "license": "MIT" - }, "node_modules/enquirer": { "version": "2.4.1", "dev": true, @@ -4852,13 +4881,6 @@ "dev": true, "license": "ISC" }, - "node_modules/json2mq": { - "version": "0.2.0", - "license": "MIT", - "dependencies": { - "string-convert": "^0.2.0" - } - }, "node_modules/json5": { "version": "1.0.2", "dev": true, @@ -5049,10 +5071,6 @@ "version": "4.17.21", "license": "MIT" }, - "node_modules/lodash.debounce": { - "version": "4.0.8", - "license": "MIT" - }, "node_modules/lodash.merge": { "version": "4.6.2", "dev": true, @@ -6136,21 +6154,6 @@ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, - "node_modules/react-slick": { - "version": "0.29.0", - "license": "MIT", - "dependencies": { - "classnames": "^2.2.5", - "enquire.js": "^2.1.6", - "json2mq": "^0.2.0", - "lodash.debounce": "^4.0.8", - "resize-observer-polyfill": "^1.5.0" - }, - "peerDependencies": { - "react": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^0.14.0 || ^15.0.1 || ^16.0.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", @@ -6332,10 +6335,6 @@ "dev": true, "license": "MIT" }, - "node_modules/resize-observer-polyfill": { - "version": "1.5.1", - "license": "MIT" - }, "node_modules/resolve": { "version": "1.22.8", "license": "MIT", @@ -6676,10 +6675,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/string-convert": { - "version": "0.2.1", - "license": "MIT" - }, "node_modules/string-hash": { "version": "1.1.3", "license": "CC0-1.0" diff --git a/package.json b/package.json index 153155e4..2c5bfdbe 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "@googleapis/sheets": "^7.0.0", "axios": "^1.7.4", "d3": "^7.8.5", + "embla-carousel-auto-scroll": "^8.5.1", + "embla-carousel-react": "^8.5.1", "lucide-react": "^0.350.0", "net": "^1.0.2", "next": "^14.2.10", @@ -32,7 +34,6 @@ "react-hot-toast": "^2.4.1", "react-responsive": "^9.0.0", "react-select": "^5.7.5", - "react-slick": "^0.29.0", "react-youtube-embed": "^1.0.3", "slick-carousel": "^1.8.1" }, diff --git a/styles/globals.css b/styles/globals.css index 4b9c83b3..0bede338 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -69,6 +69,17 @@ body { bottom: 0 !important; } +.embla { + overflow: hidden; +} +.embla__container { + display: flex; +} +.embla__slide { + flex: 0 0 75%; + min-width: 0; +} + .gradient-bg { background-image: linear-gradient(225deg, #2DCCFD 9.35%, #AD20E2 88.41%) !important; -webkit-mask-image: linear-gradient(45deg,#000 25%,rgba(0,0,0,.2) 50%,#000 75%);