diff --git a/frontend/src/pages/home_page.tsx b/frontend/src/pages/home_page.tsx index 10d27a5..32ee14a 100644 --- a/frontend/src/pages/home_page.tsx +++ b/frontend/src/pages/home_page.tsx @@ -70,6 +70,7 @@ export default function HomePage() { function HomeHeader() { const [pinnedResources, setPinnedResources] = useState([]); const [statistic, setStatistic] = useState(null); + const [currentIndex, setCurrentIndex] = useState(0); const navigator = useNavigator(); const appContext = useAppContext(); @@ -127,13 +128,30 @@ function HomeHeader() { fetchStatistics(); }, [appContext, navigator]); + // Auto-scroll carousel every 5 seconds + useEffect(() => { + if (pinnedResources.length <= 1) { + return; + } + + const interval = setInterval(() => { + setCurrentIndex((prevIndex) => (prevIndex + 1) % pinnedResources.length); + }, 5000); + + return () => clearInterval(interval); + }, [pinnedResources.length, currentIndex]); + if (pinnedResources.length == 0 || statistic == null) { return <>; } return (
- +

{app.appName}

@@ -145,6 +163,49 @@ function HomeHeader() { ); } +function PinnedResourcesCarousel({ + resources, + currentIndex, + onIndexChange, +}: { + resources: Resource[]; + currentIndex: number; + onIndexChange: (index: number) => void; +}) { + return ( +
+
+
+ {resources.map((resource) => ( +
+ +
+ ))} +
+
+ {resources.length > 1 && ( +
+ {resources.map((_, index) => ( +
+ )} +
+ ); +} + function PinnedResourceItem({ resource }: { resource: Resource }) { const navigate = useNavigate();