|
1 | | -import { IoIosClose } from 'react-icons/io' |
2 | | -import { useLocalStorage } from '~/utils/useLocalStorage' |
3 | | -import { useClientOnlyRender } from '~/utils/useClientOnlyRender' |
| 1 | +import { useEffect, useState } from 'react' |
| 2 | +import headerCourse from '~/images/query-header-course.svg' |
| 3 | +import cornerTopLeft from '~/images/query-corner-top-left.svg' |
| 4 | +import cornerTopRight from '~/images/query-corner-top-right.svg' |
| 5 | +import cornerFishBottomRight from '~/images/query-corner-fish-bottom-right.svg' |
| 6 | +import { useQueryGGPPPDiscount } from '~/hooks/useQueryGGPPPDiscount' |
4 | 7 |
|
5 | 8 | export function QueryGGBanner() { |
6 | | - const [hidden, setHidden] = useLocalStorage('pppbanner-hidden', false) |
| 9 | + const ppp = useQueryGGPPPDiscount() |
7 | 10 |
|
8 | | - if (!useClientOnlyRender()) { |
9 | | - return null |
| 11 | + let body = ( |
| 12 | + <> |
| 13 | + <p className="text-lg"> |
| 14 | + “If you're serious about *really* understanding React Query, there's no |
| 15 | + better way than with query.gg” |
| 16 | + </p> |
| 17 | + <p className="mt-2"> —Tanner Linsley</p> |
| 18 | + </> |
| 19 | + ) |
| 20 | + |
| 21 | + if (ppp) { |
| 22 | + body = ( |
| 23 | + <> |
| 24 | + <p className="text-lg font-bold mb-2"> |
| 25 | + We noticed you’re in {ppp.flag} {ppp.country} |
| 26 | + </p> |
| 27 | + <p> |
| 28 | + To help make query.gg more globally accessible, you can enable a |
| 29 | + regional discount of {ppp.discount * 100}% off. |
| 30 | + </p> |
| 31 | + </> |
| 32 | + ) |
10 | 33 | } |
11 | 34 |
|
12 | 35 | return ( |
13 | | - <> |
14 | | - {!hidden && ( |
15 | | - <div className="w-full bg-gradient-to-r from-red-500 to-amber-500 text-black text-sm text-center py-2 relative flex items-center justify-center"> |
16 | | - <p> |
17 | | - Want to <span className="italic">skip the docs?</span> Check out{' '} |
18 | | - <a href="https://query.gg?s=tanstack"> |
19 | | - <strong>query.gg</strong> |
20 | | - </a>{' '} |
21 | | - – the simplest way to master React Query. |
22 | | - </p> |
23 | | - <button |
24 | | - onClick={() => setHidden(true)} |
25 | | - className="absolute right-0" |
26 | | - aria-label="Hide Banner" |
27 | | - > |
28 | | - <IoIosClose size={30} className="text-black" /> |
29 | | - </button> |
| 36 | + <aside className="mx-auto w-full max-w-[1200px] p-8 flex justify-between items-center"> |
| 37 | + <div className="w-full xl:flex xl:gap-6 bg-[#f9f4da] border-4 border-[#231f20] relative"> |
| 38 | + <a |
| 39 | + href="https://query.gg?s=tanstack" |
| 40 | + className="xl:w-7/12 pb-4 grid grid-cols-[70px_1fr_70px] sm:grid-cols-[100px_1fr_100px] md:grid-cols-[140px_1fr_140px] xl:grid-cols-[110px_1fr] 2xl:grid-cols-[150px_1fr]" |
| 41 | + > |
| 42 | + <img src={cornerTopLeft} alt="sun" className="" /> |
| 43 | + <img |
| 44 | + src={headerCourse} |
| 45 | + alt="Query.gg - The Official React Query Course" |
| 46 | + className="-mt-[1px] w-10/12 max-w-[350px] justify-self-center" |
| 47 | + /> |
| 48 | + <img src={cornerTopRight} alt="moon" className="xl:hidden" /> |
| 49 | + </a> |
| 50 | + <div className="hidden xl:block w-[80px] mr-[-55px] bg-[#231f20] border-4 border-r-0 border-[#f9f4da] border-s-[#f9f4da] shadow-[-4px_0_0_#231f20] -skew-x-[15deg] z-0"></div> |
| 51 | + <div className="xl:w-5/12 py-2 xl:pb-0 grid xl:grid-cols-[1fr_90px] 2xl:grid-cols-[1fr_120px] justify-center bg-[#231f20] border-2 xl:border-4 xl:border-l-0 border-[#f9f4da] text-[#f9f4da] z-10"> |
| 52 | + <div className="my-2 text-center place-self-center"> |
| 53 | + {body} |
| 54 | + <a |
| 55 | + href="https://query.gg?s=tanstack" |
| 56 | + className="mt-4 mb-1 xl:mb-2 px-6 py-2 inline-block bg-[#fcba28] text-[#231f20] rounded-full uppercase border border-black cursor-pointer font-black" |
| 57 | + > |
| 58 | + {ppp?.discount ? `Get ${ppp.discount * 100}% off` : 'Join now'} |
| 59 | + </a> |
| 60 | + </div> |
| 61 | + <img |
| 62 | + src={cornerFishBottomRight} |
| 63 | + alt="mutated fish" |
| 64 | + className="hidden xl:block self-end" |
| 65 | + /> |
30 | 66 | </div> |
31 | | - )} |
32 | | - </> |
| 67 | + </div> |
| 68 | + </aside> |
33 | 69 | ) |
34 | 70 | } |
0 commit comments