diff --git a/apps/admin-x-settings/src/components/settings/site/theme/OfficialThemes.tsx b/apps/admin-x-settings/src/components/settings/site/theme/OfficialThemes.tsx index 39ddf9dd37..ae6cb4b915 100644 --- a/apps/admin-x-settings/src/components/settings/site/theme/OfficialThemes.tsx +++ b/apps/admin-x-settings/src/components/settings/site/theme/OfficialThemes.tsx @@ -1,10 +1,9 @@ import Heading from '../../../../admin-x-ds/global/Heading'; import MarketplaceBgImage from '../../../../assets/images/footer-marketplace-bg.png'; import ModalPage from '../../../../admin-x-ds/global/modal/ModalPage'; -import React from 'react'; +import React, {useEffect, useState} from 'react'; import {OfficialTheme, useOfficialThemes} from '../../../providers/ServiceProvider'; import {getGhostPaths, resolveAsset} from '../../../../utils/helpers'; -import {useEffect, useState} from 'react'; const sourceDemos = [ {image: 'Source.png', category: 'News'}, @@ -23,10 +22,16 @@ const OfficialThemes: React.FC<{ const [isHovered, setIsHovered] = useState(false); useEffect(() => { - const interval = setInterval(() => { + const switchSourceDemos = () => { if (isHovered) { setCurrentSourceDemoIndex(prevIndex => (prevIndex + 1) % sourceDemos.length); } + }; + + switchSourceDemos(); + + const interval = setInterval(() => { + switchSourceDemos(); }, 3000); return () => { @@ -34,6 +39,12 @@ const OfficialThemes: React.FC<{ }; }, [isHovered]); + useEffect(() => { + if (!isHovered) { + setCurrentSourceDemoIndex(0); + } + }, [isHovered]); + return (
@@ -43,7 +54,7 @@ const OfficialThemes: React.FC<{ onSelectTheme?.(theme); }}> {/* {theme.name} */} -
setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}> +
theme.name === 'Source' && setIsHovered(true)} onMouseLeave={() => theme.name === 'Source' && setIsHovered(false)}> {theme.name !== 'Source' ? {`${theme.name}{theme.category} : sourceDemos.map((demo, index) => ( - {demo.category} + {demo.category} )) }