import classNames from "classnames"; import { useCallback } from "react"; import { Icon, Icons } from "@/components/Icon"; import { Transition } from "@/components/utils/Transition"; import { usePlayerStore } from "@/stores/player/store"; function shouldShowSkipButton( currentTime: number, skipTime?: number | null, ): "always" | "hover" | "none" { if (typeof skipTime !== "number") return "none"; // Only show during the first 10 seconds of the intro section if (currentTime >= 0 && currentTime < skipTime) { if (currentTime <= 10) return "always"; return "hover"; } return "none"; } function Button(props: { className: string; onClick?: () => void; children: React.ReactNode; }) { return ( ); } export function SkipIntroButton(props: { controlsShowing: boolean; skipTime?: number | null; inControl: boolean; }) { const time = usePlayerStore((s) => s.progress.time); const status = usePlayerStore((s) => s.status); const display = usePlayerStore((s) => s.display); const showingState = shouldShowSkipButton(time, props.skipTime); const animation = showingState === "hover" ? "slide-up" : "fade"; let bottom = "bottom-[calc(6rem+env(safe-area-inset-bottom))]"; if (showingState === "always") { bottom = props.controlsShowing ? bottom : "bottom-[calc(3rem+env(safe-area-inset-bottom))]"; } const handleSkip = useCallback(() => { if (typeof props.skipTime === "number" && display) { display.setTime(props.skipTime); } }, [props.skipTime, display]); if (!props.inControl) return null; let show = false; if (showingState === "always") show = true; else if (showingState === "hover" && props.controlsShowing) show = true; if (status !== "playing") show = false; return (
); }