Skip to content

Commit f18a74d

Browse files
Update query.gg callouts (#294)
1 parent c7a4688 commit f18a74d

File tree

8 files changed

+119
-96
lines changed

8 files changed

+119
-96
lines changed
Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
import { LogoQueryGGSmall } from '~/components/LogoQueryGGSmall'
2+
import { useQueryGGPPPDiscount } from '~/hooks/useQueryGGPPPDiscount'
3+
4+
export function DocsCalloutQueryGG() {
5+
const ppp = useQueryGGPPPDiscount()
26

3-
export function DocsCalloutQueryGG(props: React.HTMLProps<HTMLDivElement>) {
47
return (
5-
<div {...props}>
8+
<a
9+
target="_blank"
10+
className="cursor-pointer"
11+
href="https://query.gg?s=tanstack"
12+
>
613
<div className="space-y-3">
714
<h6 className="text-[.7rem] uppercase font-black opacity-50">
815
Want to Skip the Docs?
916
</h6>
1017
<LogoQueryGGSmall className="w-full" />
1118

12-
<blockquote className="text-xs -indent-[.45em] pl-2">
13-
This course is the best way to learn how to use React Query in
14-
real-world applications.
19+
<blockquote className="text-sm -indent-[.45em] pl-2">
20+
If you're serious about *really* understanding React Query, there's
21+
no better way than with query.gg
1522
<cite className="italic block text-right">—Tanner Linsley</cite>
1623
</blockquote>
17-
<a
18-
className="block m-1 px-4 py-2 bg-gradient-to-r from-rose-500 to-violet-500 text-white rounded uppercase font-bold text-sm text-center"
19-
href="https://query.gg?s=tanstack"
20-
target="_blank"
21-
>
22-
Get the course
23-
</a>
24+
25+
{ppp && (
26+
<>
27+
<p className="text-sm pl-2 py-2">
28+
To help make query.gg more accessible, you can enable a regional
29+
discount of {ppp.discount * 100}% off for being in {ppp.flag}{' '}
30+
{ppp.country}.
31+
</p>
32+
</>
33+
)}
34+
<button className="block m-1 w-full mx-auto px-4 py-2 rounded uppercase font-bold text-sm text-center hover:bg-gray-100/70 dark:hover:bg-gray-800 cursor-default border-2 dark:border-gray-700/80">
35+
{ppp ? ` Get ${ppp.discount * 100}% off ${ppp.flag}` : 'Learn More'}
36+
</button>
2437
</div>
25-
</div>
38+
</a>
2639
)
2740
}

app/components/QueryGGBanner.tsx

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,70 @@
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'
47

58
export function QueryGGBanner() {
6-
const [hidden, setHidden] = useLocalStorage('pppbanner-hidden', false)
9+
const ppp = useQueryGGPPPDiscount()
710

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+
)
1033
}
1134

1235
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+
/>
3066
</div>
31-
)}
32-
</>
67+
</div>
68+
</aside>
3369
)
3470
}

app/hooks/useQueryGGPPPDiscount.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useState, useEffect } from 'react'
2+
3+
type Discount = {
4+
code: string
5+
country: string
6+
discount: number
7+
flag: string
8+
}
9+
10+
export function useQueryGGPPPDiscount() {
11+
const [ppp, setPPP] = useState<Discount | null>(null)
12+
13+
useEffect(() => {
14+
const handleFetch = async () => {
15+
try {
16+
const res = await fetch('https://ppp.uidotdev.workers.dev/')
17+
const data = await res.json()
18+
setPPP(data)
19+
} catch (e) {
20+
setPPP(null)
21+
}
22+
}
23+
24+
handleFetch()
25+
}, [])
26+
27+
return ppp
28+
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)