From 6a0722a69783eecc8e8878b763ca86083c778b0a Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sun, 28 Aug 2022 22:50:34 +0100 Subject: [PATCH] fix: translation display bug, marketplace error, cleanup carousel --- .gitignore | 1 + src/components/helpers/carousel/Carousel.jsx | 70 +++++++++++++------ .../helpers/carousel/CarouselButtons.jsx | 14 ---- .../modals/main/settings/sections/Weather.jsx | 2 +- src/index.jsx | 6 +- 5 files changed, 52 insertions(+), 41 deletions(-) delete mode 100644 src/components/helpers/carousel/CarouselButtons.jsx diff --git a/.gitignore b/.gitignore index dfcf9fd0..c6e8c984 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Directories node_modules/ +.history/ .vscode/ build/ .idea/ diff --git a/src/components/helpers/carousel/Carousel.jsx b/src/components/helpers/carousel/Carousel.jsx index 7582f81f..1c223202 100644 --- a/src/components/helpers/carousel/Carousel.jsx +++ b/src/components/helpers/carousel/Carousel.jsx @@ -1,39 +1,47 @@ import React, { useState, useEffect, useCallback, useRef } from 'react'; -import { PrevButton, NextButton } from './CarouselButtons'; +import { MdOutlineArrowForwardIos, MdOutlineArrowBackIos } from 'react-icons/md'; import useEmblaCarousel from 'embla-carousel-react'; import Autoplay from 'embla-carousel-autoplay'; -import './carousel.scss'; -import { FaPhotoVideo } from 'react-icons/fa'; -const EmblaCarousel = ({ data, options = { loop: false } }) => { +import './carousel.scss'; + +export default function EmblaCarousel({ data }) { const autoplay = useRef( Autoplay({ delay: 3000, stopOnInteraction: false }, (emblaRoot) => emblaRoot.parentElement), ); - const [emblaRef, emblaApi] = useEmblaCarousel(options, [autoplay.current]); + const [emblaRef, emblaApi] = useEmblaCarousel({ loop: false }, [autoplay.current]); const [prevBtnEnabled, setPrevBtnEnabled] = useState(false); const [nextBtnEnabled, setNextBtnEnabled] = useState(false); - const scrollNext = useCallback(() => { - if (!emblaApi) return; - emblaApi.scrollNext(); - autoplay.current.reset(); - }, [emblaApi]); + const scroll = useCallback( + (direction) => { + if (!emblaApi) { + return; + } - const scrollPrev = useCallback(() => { - if (!emblaApi) return; - emblaApi.scrollPrev(); - autoplay.current.reset(); - }, [emblaApi]); + if (direction === 'next') { + emblaApi.scrollNext(); + } else { + emblaApi.scrollPrev(); + } + autoplay.current.reset(); + }, + [emblaApi], + ); const onSelect = useCallback(() => { - if (!emblaApi) return; + if (!emblaApi) { + return; + } setPrevBtnEnabled(emblaApi.canScrollPrev()); setNextBtnEnabled(emblaApi.canScrollNext()); }, [emblaApi]); useEffect(() => { - if (!emblaApi) return; + if (!emblaApi) { + return; + } onSelect(); emblaApi.on('select', onSelect); }, [emblaApi, onSelect]); @@ -45,16 +53,32 @@ const EmblaCarousel = ({ data, options = { loop: false } }) => { {data.map((photo, index) => (
- A cool cat. + Marketplace example screenshot
))} - - + + ); -}; - -export default EmblaCarousel; +} diff --git a/src/components/helpers/carousel/CarouselButtons.jsx b/src/components/helpers/carousel/CarouselButtons.jsx deleted file mode 100644 index dc08847d..00000000 --- a/src/components/helpers/carousel/CarouselButtons.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { MdOutlineArrowForwardIos, MdOutlineArrowBackIos } from 'react-icons/md'; - -export const PrevButton = ({ enabled, onClick }) => ( - -); - -export const NextButton = ({ enabled, onClick }) => ( - -); diff --git a/src/components/modals/main/settings/sections/Weather.jsx b/src/components/modals/main/settings/sections/Weather.jsx index c6f453b9..81f322a0 100644 --- a/src/components/modals/main/settings/sections/Weather.jsx +++ b/src/components/modals/main/settings/sections/Weather.jsx @@ -122,7 +122,7 @@ export default class TimeSettings extends PureComponent { category="weather" /> - {localStorage.getItem('weatherType') == 4 && ( + {localStorage.getItem('weatherType') === 4 && ( variables.language.getMessage(variables.languagecode, text); +variables.getMessage = (text, optional) => variables.language.getMessage(variables.languagecode, text, optional || {}); // set html language tag if (variables.languagecode !== 'en_GB' || variables.languagecode !== 'en_US') { @@ -61,4 +61,4 @@ Sentry.init({ autoSessionTracking: false, }); -createRoot(document.getElementById('root')).render(); +render(, document.getElementById('root'));