|
| 1 | +/* eslint-disable @typescript-eslint/no-unused-vars */ |
| 2 | +"use client" |
| 3 | + |
| 4 | +import { X } from "lucide-react" |
| 5 | +import Link from "next/link" |
| 6 | +import { useMemo } from "react" |
| 7 | +import { CloudflareImage, type CloudflareImageId } from "~/components/CloudflareImage" |
| 8 | +import { useLocalStorage } from "~/hooks/util/useLocalStorage" |
| 9 | + |
| 10 | +const eventName = "Bungie Day 2025" |
| 11 | +const localStorageKey = "bungieDay2025BannerDismissDate" |
| 12 | +const campaignUrl = "https://tiltify.com/@raidhub/bungie-day-2025" |
| 13 | +const donateUrl = "https://donate.tiltify.com/917cb375-cc2a-4377-9ee6-5e75600b9567/incentives" |
| 14 | +const banner: CloudflareImageId = "bungieFoundation" |
| 15 | + |
| 16 | +// const allG2GEmblems = o.entries(VaultEmblems) |
| 17 | + |
| 18 | +export const BungieFoundationBanner = () => { |
| 19 | + // const [randomIdx, setRandomIdx] = useState( |
| 20 | + // () => 1 + Math.floor(Math.random() * (allG2GEmblems.length - 1)) |
| 21 | + // ) |
| 22 | + |
| 23 | + // useInterval(15_000, () => { |
| 24 | + // setRandomIdx(old => 1 + ((old + 1) % (allG2GEmblems.length - 1))) |
| 25 | + // }) |
| 26 | + |
| 27 | + const [g2gBannerDismissDate, setG2gBannerDismissDate] = useLocalStorage<string | null>( |
| 28 | + localStorageKey, |
| 29 | + null |
| 30 | + ) |
| 31 | + |
| 32 | + const dismissedBannerDate = useMemo( |
| 33 | + () => (g2gBannerDismissDate ? new Date(g2gBannerDismissDate) : new Date(0)), |
| 34 | + [g2gBannerDismissDate] |
| 35 | + ) |
| 36 | + |
| 37 | + const oneWeekAgo = useMemo(() => { |
| 38 | + const d = new Date() |
| 39 | + d.setDate(d.getDate() - 7) |
| 40 | + return d |
| 41 | + }, []) |
| 42 | + |
| 43 | + const shouldShowBanner = dismissedBannerDate < oneWeekAgo |
| 44 | + |
| 45 | + if (!shouldShowBanner) return null |
| 46 | + |
| 47 | + return ( |
| 48 | + <div className="border-border-dark bg-background/30 text-primary relative w-full border px-2 py-2 text-sm font-semibold tracking-wide sm:text-base"> |
| 49 | + <div className="mx-auto flex max-w-screen-xl flex-wrap items-center gap-8 px-6"> |
| 50 | + <div className="max-w-150 basis-100"> |
| 51 | + <a href={campaignUrl} target="_blank"> |
| 52 | + <CloudflareImage |
| 53 | + cloudflareId={banner} |
| 54 | + priority |
| 55 | + alt={eventName} |
| 56 | + height={500} |
| 57 | + width={1500} |
| 58 | + /> |
| 59 | + </a> |
| 60 | + <DonateButton /> |
| 61 | + </div> |
| 62 | + |
| 63 | + <div className="min-w-[320px] flex-2 space-y-4"> |
| 64 | + <div className="flex flex-wrap gap-8 font-normal max-sm:flex-col max-sm:gap-4"> |
| 65 | + <p className="min-w-30 flex-1"> |
| 66 | + This year, as a part of <strong>{eventName}</strong>, RaidHub is raising |
| 67 | + money for the{" "} |
| 68 | + <Link |
| 69 | + href="https://bungiefoundation.org/" |
| 70 | + className="underline underline-offset-2"> |
| 71 | + Bungie Foundation |
| 72 | + </Link> |
| 73 | + . Click the "donate" button to see the specific Bungie rewards |
| 74 | + and incentives available. |
| 75 | + </p> |
| 76 | + <p className="min-w-30 flex-1"> |
| 77 | + This year, we are collaborating with other Destiny 2 API developers to |
| 78 | + offer the{" "} |
| 79 | + <a |
| 80 | + className="text-yellow-300" |
| 81 | + href="https://donate.tiltify.com/917cb375-cc2a-4377-9ee6-5e75600b9567/incentives?rewardPublicId=a20d75dc-5d22-49cf-b507-a802d66d0d63" |
| 82 | + target="_blank"> |
| 83 | + D2 DEVS MEGAPACK!!!! |
| 84 | + </a> |
| 85 | + , a bundle of unique perks across all your favorite D2 API tools, |
| 86 | + including <span className="text-blue-300">GM Report</span>,{" "} |
| 87 | + <span className="text-red-300">Trials Report</span>,{" "} |
| 88 | + <span className="text-pink-300">Braytech</span>, and more! |
| 89 | + </p> |
| 90 | + <p className="min-w-30 flex-1"> |
| 91 | + As a form of gratitude, all those who choose to donate through |
| 92 | + RaidHub's fundraiser will also be eligible to receive a{" "} |
| 93 | + <strong>profile badge</strong> at the end of the event. |
| 94 | + </p> |
| 95 | + </div> |
| 96 | + |
| 97 | + {/* emblem carousel */} |
| 98 | + {/* <div className="flex items-center gap-4"> |
| 99 | + <div className="relative hidden aspect-[474/96] min-h-8 flex-1 md:block"> |
| 100 | + <CloudflareImage |
| 101 | + cloudflareId="darkHeroNameplate" |
| 102 | + fill |
| 103 | + alt="Dark Hero Nameplate" |
| 104 | + /> |
| 105 | + </div> |
| 106 | +
|
| 107 | + <DonateButton /> |
| 108 | + |
| 109 | + <m.div |
| 110 | + key={allG2GEmblems[randomIdx][0]} |
| 111 | + className="relative hidden aspect-[474/96] min-h-8 flex-1 md:block" |
| 112 | + initial={{ opacity: 0 }} |
| 113 | + animate={{ |
| 114 | + opacity: Array(26).fill(1).concat([0]) |
| 115 | + }} |
| 116 | + transition={{ |
| 117 | + duration: 15, |
| 118 | + repeat: Infinity, |
| 119 | + ease: "easeInOut" |
| 120 | + }}> |
| 121 | + <CloudflareImage |
| 122 | + cloudflareId={allG2GEmblems[randomIdx][0]} |
| 123 | + fill |
| 124 | + alt={allG2GEmblems[randomIdx][0]} |
| 125 | + /> |
| 126 | + </m.div> |
| 127 | + </div> */} |
| 128 | + </div> |
| 129 | + |
| 130 | + <X |
| 131 | + onClick={() => setG2gBannerDismissDate(new Date().toISOString())} |
| 132 | + className="absolute top-0 right-0 size-8 cursor-pointer rounded p-2 text-white hover:bg-white/10" |
| 133 | + /> |
| 134 | + </div> |
| 135 | + </div> |
| 136 | + ) |
| 137 | +} |
| 138 | + |
| 139 | +const DonateButton = () => ( |
| 140 | + <Link |
| 141 | + href={donateUrl} |
| 142 | + className="bg-blue-600 px-4 py-2 text-lg font-semibold text-white uppercase transition hover:bg-blue-700"> |
| 143 | + Donate |
| 144 | + </Link> |
| 145 | +) |
0 commit comments