Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Move winning chances to hook

Terry Sutton5df35a114a91
diff --git a/apps/www/components/LaunchWeek/ReferralIndicator.tsx b/apps/www/components/LaunchWeek/ReferralIndicator.tsx
index ee31e495f50..294bf8d4990 100644
--- a/apps/www/components/LaunchWeek/ReferralIndicator.tsx
+++ b/apps/www/components/LaunchWeek/ReferralIndicator.tsx
@@ -1,37 +1,20 @@
import React from 'react'
import useConfData from '~/components/LaunchWeek/Ticket//hooks/use-conf-data'
-
-function calculateWinChances(
- sharedOnLinkedIn: string | undefined,
- sharedOnTwitter: string | undefined
-) {
- let numChances = 1
-
- let chancesText = 'chances'
-
- if (sharedOnLinkedIn) {
- numChances++
- }
- if (sharedOnTwitter) {
- numChances++
- }
-
- if (numChances === 1) {
- chancesText = 'chance'
- }
-
- return `${numChances}x ${chancesText}`
-}
+import useWinningChances from './Ticket/hooks/useWinningChances'
export default function ReferralIndicator() {
- const { userData } = useConfData()
- const { sharedOnLinkedIn, sharedOnTwitter } = userData
- const computedWinningOdds = calculateWinChances(sharedOnLinkedIn, sharedOnTwitter)
+ const winningChances = useWinningChances()
return (
<div className="bg-[#EAEAEA75] rounded-full mt-4 flex">
- <span className="bg-gradient-to-l from-[#A141E4] to-[#6300F569] rounded-full pl-4 pr-6 py-1.5 text-xs">
- {computedWinningOdds}
+ <span
+ className={[
+ 'bg-gradient-to-l from-[#A141E4] to-[#6300F569] rounded-full pl-4 pr-6 py-1.5 text-xs',
+ winningChances === 2 ? 'w-1/2' : '',
+ winningChances === 3 ? 'w-full' : '',
+ ].join(' ')}
+ >
+ {winningChances}x {winningChances > 1 ? 'chances' : 'chance'}
</span>
</div>
)
diff --git a/apps/www/components/LaunchWeek/Ticket/hooks/useWinningChances.ts b/apps/www/components/LaunchWeek/Ticket/hooks/useWinningChances.ts
new file mode 100644
index 00000000000..b843fd0f5fe
--- /dev/null
+++ b/apps/www/components/LaunchWeek/Ticket/hooks/useWinningChances.ts
@@ -0,0 +1,25 @@
+import { UserData } from './use-conf-data'
+import useConfData from '~/components/LaunchWeek/Ticket//hooks/use-conf-data'
+
+function calculateWinChances(userData: UserData): number {
+ // Just signing up gives you 1
+ // Then signing up with LinkedIn and Twitter get you one more each for a total of 3
+ // When the chance === 3, you have a golden ticket
+ let numChances = 1
+
+ if (userData.sharedOnLinkedIn) {
+ numChances++
+ }
+ if (userData.sharedOnTwitter) {
+ numChances++
+ }
+
+ return numChances
+}
+
+export default function useWinningChances() {
+ const { userData } = useConfData()
+
+ const chances = calculateWinChances(userData)
+ return chances
+}
diff --git a/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx b/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx
index d2afdfe8977..6ea0746c729 100644
--- a/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx
+++ b/apps/www/components/LaunchWeek/Ticket/ticket-actions.tsx
@@ -55,14 +55,16 @@ export default function TicketActions({ username, golden = false }: Props) {
</div>
<div
className={`rounded-md ${
- userData.sharedOnTwitter ? 'bg-[#E6E8EB]' : ''
+ userData.sharedOnTwitter ? 'bg-[#E6E8EB] text-scale-500' : 'text-white'
} text-scale-500 py-1 px-3 border border-scale-1100 text-xs mb-1 transition-all ease-out hover:bg-[#dfe1e3]`}
>
<a
href={tweetUrl}
rel="noopener noreferrer"
target="_blank"
- className="flex items-center justify-center gap-2"
+ className={`flex items-center justify-center gap-2 ${
+ userData.sharedOnTwitter ? 'text-scale-500' : 'text-white hover:text-scale-500'
+ }`}
>
{userData.sharedOnTwitter && (
<div className="text-scale-900">
@@ -75,13 +77,15 @@ export default function TicketActions({ username, golden = false }: Props) {
<div
className={`rounded-md ${
userData.sharedOnLinkedIn ? 'bg-[#E6E8EB] text-scale-500' : 'text-white'
- } py-1 px-3 border border-scale-1100 text-xs mb-1 transition-all ease-out hover:bg-[#dfe1e3] hover:text-scale-500`}
+ } text-scale-500 py-1 px-3 border border-scale-1100 text-xs mb-1 transition-all ease-out hover:bg-[#dfe1e3]`}
>
<a
href={linkedInUrl}
rel="noopener noreferrer"
target="_blank"
- className="flex items-center justify-center gap-2"
+ className={`flex items-center justify-center gap-2 ${
+ userData.sharedOnLinkedIn ? 'text-scale-500' : 'text-white hover:text-scale-500'
+ }`}
>
{userData.sharedOnLinkedIn && (
<div className="text-scale-900">
diff --git a/apps/www/components/LaunchWeek/Ticket/ticket-form.tsx b/apps/www/components/LaunchWeek/Ticket/ticket-form.tsx
index 3b03311384e..4efc4886137 100644
--- a/apps/www/components/LaunchWeek/Ticket/ticket-form.tsx
+++ b/apps/www/components/LaunchWeek/Ticket/ticket-form.tsx
@@ -11,8 +11,6 @@ import formStyles from './form.module.css'
import ticketFormStyles from './ticket-form.module.css'
import { Button, IconCheck, IconCheckCircle, IconLoader } from 'ui'
-console.log('SITE_ORIGIN', SITE_ORIGIN)
-
type FormState = 'default' | 'loading' | 'error'
type TicketGenerationState = 'default' | 'loading'
diff --git a/apps/www/components/LaunchWeek/Ticket/ticket.tsx b/apps/www/components/LaunchWeek/Ticket/ticket.tsx
index 89813f45000..c5568aba82e 100644
--- a/apps/www/components/LaunchWeek/Ticket/ticket.tsx
+++ b/apps/www/components/LaunchWeek/Ticket/ticket.tsx
@@ -14,8 +14,10 @@ import { DATE, SITE_NAME } from '~/lib/constants'
import Form from './form'
import { UserData } from './hooks/use-conf-data'
import ReferralIndicator from '../ReferralIndicator'
+import useWinningChances from './hooks/useWinningChances'
type TicketGenerationState = 'default' | 'loading'
+
type Props = {
username: UserData['username']
ticketNumber: UserData['ticketNumber']
@@ -37,6 +39,7 @@ export default function Ticket({
const [ticketGenerationState, setTicketGenerationState] =
useState<TicketGenerationState>('default')
const divRef = useRef<HTMLDivElement>(null)
+ const winningChances = useWinningChances()
useEffect(() => {
if (ticketRef.current && !window.matchMedia('(pointer: coarse)').matches) {
@@ -114,12 +117,27 @@ export default function Ticket({
>
<h1 className={cn(styleUtils.appear, styleUtils['appear-first'], 'text-xl xl:text-3xl')}>
{name ? (
- <p className="text-2xl dark:text-scale-1200 tracking-[0.02rem]">
- You're <span className="gradient-text-purple-500">in the draw!</span> <br />
- Now make it gold.
- </p>
- ) : golden ? (
- <p className="text-xl dark:text-scale-1200 tracking-[0.02rem]">Congratulations!</p>
+ <>
+ {winningChances === 1 && (
+ <p className="text-2xl dark:text-scale-1200 tracking-[0.02rem]">
+ You're <span className="gradient-text-purple-500">in the draw!</span> <br />
+ Now make it gold.
+ </p>
+ )}
+ {winningChances === 2 && (
+ <p className="text-2xl dark:text-scale-1200 tracking-[0.02rem]">
+ You've <span className="gradient-text-purple-500">doubled</span> your
+ <br />
+ chance! Almost gold.
+ </p>
+ )}
+ {winningChances === 3 && (
+ <p className="text-2xl dark:text-scale-1200 tracking-[0.02rem]">
+ You're <span className="gradient-text-gold-500">gold</span>!<br />
+ You've maxed your <br /> chances of winning!
+ </p>
+ )}
+ </>
) : (
<p className="text-2xl dark:text-scale-1200 tracking-[0.02rem]">
Generate your ticket. <br />
@@ -128,11 +146,7 @@ export default function Ticket({
)}
</h1>
<h2 className="text-base max-w-[520px]">
- {sharePage ? (
- <p>
- Join {name ?? 'us'} on {DATE}.
- </p>
- ) : golden ? (
+ {golden ? (
<>
<p>
You got a Golden ticket. This means you’re in, and you also won a Supabase sticker
diff --git a/apps/www/public/planetpg-bo_lu-rss.xml b/apps/www/public/planetpg-bo_lu-rss.xml
new file mode 100644
index 00000000000..16f75abaa7e
--- /dev/null
+++ b/apps/www/public/planetpg-bo_lu-rss.xml
@@ -0,0 +1,19 @@
+
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+ <channel>
+ <title>'Postgres | Supabase Blog</title>
+ <link>https://supabase.com/blog</link>
+ <description>Latest Postgres news from Bo Lu at Supabase</description>
+ <language>en</language>
+ <lastBuildDate>Wed, 14 Dec 2022 03:03:30 +0000</lastBuildDate>
+ <atom:link href="https://supabase.com/planetpg-bo_lu-rss.xml" rel="self" type="application/rss+xml"/>
+ <item>
+ <guid>https://supabase.com/blog/postgres-foreign-data-wrappers-rust</guid>
+ <title>Supabase Wrappers, a Postgres FDW framework written in Rust</title>
+ <link>https://supabase.com/blog/postgres-foreign-data-wrappers-rust</link>
+ <description>A framework for building Postgres Foreign Data Wrappers which connects to Stripe, Firebase, Clickhouse, and more.</description>
+ <pubDate>Wed, 14 Dec 2022 03:03:30 +0000</pubDate>
+</item>
+
+ </channel>
+ </rss>
diff --git a/apps/www/styles/index.css b/apps/www/styles/index.css
index 4258d101be7..4a6a4c6f379 100644
--- a/apps/www/styles/index.css
+++ b/apps/www/styles/index.css
@@ -696,6 +696,10 @@ launch week
background-image: -webkit-linear-gradient(45deg, #902dfb 17%, #d87bf5 97%);
}
+ .gradient-text-gold-500 {
+ background-image: -webkit-linear-gradient(45deg, #e4b641 100%, #f5bf0069 41%);
+ }
+
.radial-gradient-text-scale-500 {
background: radial-gradient(45% 100% at 50% 50%, #fff 30%, hsla(0, 0%, 100%, 0.35) 100%);
}