import { EmblaCarouselType } from "embla-carousel"; import { ArrowRightIcon, CloudLightningIcon, LucideIcon, ShieldCheckIcon, WalletIcon, } from "lucide-react"; import React, { ReactElement } from "react"; import { useNavigate } from "react-router"; import Cloud from "src/assets/images/cloud.png"; import Cloud2 from "src/assets/images/cloud2.png"; import { Button } from "src/components/ui/button"; import { Carousel, CarouselApi, CarouselContent, CarouselItem, } from "src/components/ui/carousel"; import { CarouselDotButton, CarouselDots, } from "src/components/ui/custom/carousel-dots"; import { useDotButton } from "src/components/ui/custom/useDotButton"; import { useTheme } from "src/components/ui/theme-provider"; import { useInfo } from "src/hooks/useInfo"; import { cn } from "src/lib/utils"; export function Intro() { const { data: info } = useInfo(); const navigate = useNavigate(); const [api, setApi] = React.useState(); const [progress, setProgress] = React.useState(0); const { selectedIndex, scrollSnaps, onDotButtonClick } = useDotButton(api); const { setDarkMode } = useTheme(); const windowWidth = useWindowWidth(); React.useEffect(() => { // Force dark mode on intro screen setDarkMode("dark"); return () => { // Revert to default after exiting intro setDarkMode("system"); }; }, [setDarkMode]); React.useEffect(() => { if (!info?.setupCompleted) { return; } navigate("/"); }, [info, navigate]); React.useEffect(() => { api?.on("scroll", (x) => { setProgress(x.scrollProgress()); }); }, [api]); const cloudDesktopSizePositionModifier = Math.floor( Math.max(1920 - windowWidth, 0) * 0.1 ); return ( <> Welcome ยท Alby Hub
Welcome to Alby Hub
A powerful, all-in-one bitcoin lightning wallet with the superpower of connecting to applications.
{scrollSnaps.map((_, index) => ( onDotButtonClick(index)} aria-label={`Go to slide ${index + 1}`} /> ))}
); } function Slide({ api, title, description, icon: Icon, }: { api: EmblaCarouselType | undefined; title: string; description: string; icon: LucideIcon; button?: ReactElement; }) { const navigate = useNavigate(); const slideNext = function () { if (api?.canScrollNext()) { api.scrollNext(); } else { navigate("/welcome"); } }; return (
{title}
{description}
); } function useWindowWidth() { const [width, setWidth] = React.useState(window.innerWidth); React.useLayoutEffect(() => { function updateSize() { setWidth(window.innerWidth); } window.addEventListener("resize", updateSize); updateSize(); return () => window.removeEventListener("resize", updateSize); }, []); return width; }