Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

feat(landing) waitlist banner & page (#304)

Ernesto Resende8669ec365ea4
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index f7e80743..51648c48 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -321,3 +321,16 @@ model Comment {
@@index([rootChallengeId])
@@index([userId])
}
+
+enum WaitlistIntention {
+ BUILDER // interested in building challenges for the community
+ USER // interested in solving challenges
+ BOTH
+}
+
+model Waitlist {
+ id Int @id @default(autoincrement())
+ name String
+ email String
+ intention WaitlistIntention
+}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 087bd3b9..8a87da71 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -3,6 +3,7 @@ import { Provider as BalancerProvider } from 'react-wrap-balancer';
import Hero from '~/components/landing/hero';
import Features from '~/components/landing/features';
import Community from '~/components/landing/community';
+import Waitlist from '~/components/landing/waitlist/banner';
import { Footsies } from '~/components/ui/footsies';
export default async function Index() {
@@ -20,6 +21,7 @@ export default async function Index() {
<Hero />
<Features />
<Community />
+ <Waitlist />
<Footsies />
</BalancerProvider>
</>
diff --git a/src/app/waitlist/page.tsx b/src/app/waitlist/page.tsx
new file mode 100644
index 00000000..c5bc3d2d
--- /dev/null
+++ b/src/app/waitlist/page.tsx
@@ -0,0 +1,5 @@
+import Waitlist from '~/components/landing/waitlist';
+
+export default async function WaitlistPage() {
+ return <Waitlist />;
+}
diff --git a/src/assets/images/background_pattern.png b/src/assets/images/background_pattern.png
new file mode 100644
index 00000000..b20d82d8
Binary files /dev/null and b/src/assets/images/background_pattern.png differ
diff --git a/src/components/landing/community.tsx b/src/components/landing/community.tsx
index 8fb7d472..c28eea99 100644
--- a/src/components/landing/community.tsx
+++ b/src/components/landing/community.tsx
@@ -28,7 +28,7 @@ const Community = async function () {
const avatars = await getOcto();
return (
- <section className="container mt-[48px] flex min-h-[80lvh] flex-col justify-center lg:flex-row lg:items-center">
+ <section className="container md:mb-[172px] mt-[172px] flex flex-col justify-center lg:flex-row lg:items-center">
<div className="flex flex-1 flex-col items-center pb-36 lg:items-start lg:pb-0">
<h2 className="mb-2 text-center text-4xl font-bold lg:text-left">Built by the community</h2>
<span className="text-neutral-400 dark:text-neutral-600">
diff --git a/src/components/landing/features.tsx b/src/components/landing/features.tsx
index a203569e..713dd1fc 100644
--- a/src/components/landing/features.tsx
+++ b/src/components/landing/features.tsx
@@ -2,6 +2,7 @@ import { FeatureCard } from '~/components/landing/feature-card';
import FeatureCardChallengeDark from '~/assets/images/feature_card_challenge_dark.png';
import FeatureCardChallengeLight from '~/assets/images/feature_card_challenge_light.png';
+import { Balancer } from 'react-wrap-balancer';
const Features = () => {
return (
@@ -9,14 +10,18 @@ const Features = () => {
<div className="container mb-[128px] grid items-center justify-center">
<div className="flex flex-col items-center justify-center gap-16">
<div className="flex flex-col gap-1 text-center">
- <h1 className="text-4xl font-bold">What&apos;s in TypeHero?</h1>
- <p className="text-lg text-zinc-400">All you need to become a TypeScript menace</p>
+ <h1 className="text-4xl font-bold">
+ <Balancer>What&apos;s in TypeHero?</Balancer>
+ </h1>
+ <p className="text-lg text-zinc-400">
+ <Balancer>All you need to become a TypeScript menace</Balancer>
+ </p>
</div>
<div className="relative grid w-full gap-8 lg:grid-cols-2">
<FeatureCard
title="Learn & Excel"
description="Create new challenges with a built-in challenge editor and choose accepted solutions"
- className="group-hover:scale-105 transition-transform duration-300 left-[35px] top-[35%] w-[150%] sm:left-[35px] sm:top-[30%] sm:w-[110%]"
+ className="left-[35px] top-[35%] w-[150%] transition-transform duration-300 group-hover:scale-105 sm:left-[35px] sm:top-[30%] sm:w-[110%]"
image={{
dark: FeatureCardChallengeDark,
light: FeatureCardChallengeLight,
@@ -27,7 +32,7 @@ const Features = () => {
<FeatureCard
title="Learn & Excel"
description="Create new challenges with a built-in challenge editor and choose accepted solutions"
- className="group-hover:scale-105 transition-transform duration-300 left-[35px] top-[35%] w-[150%] sm:left-[35px] sm:top-[30%] sm:w-[110%]"
+ className="left-[35px] top-[35%] w-[150%] transition-transform duration-300 group-hover:scale-105 sm:left-[35px] sm:top-[30%] sm:w-[110%]"
image={{
dark: FeatureCardChallengeDark,
light: FeatureCardChallengeLight,
diff --git a/src/components/landing/hero.tsx b/src/components/landing/hero.tsx
index 7e2a88fc..eccb0ead 100644
--- a/src/components/landing/hero.tsx
+++ b/src/components/landing/hero.tsx
@@ -41,7 +41,7 @@ const Hero = () => (
</filter>
<rect width="100%" height="100%" filter="url(#noise)"></rect>
</svg> */}
- <div className="container mb-[128px] mt-[90px] lg:mt-0 grid items-center justify-center lg:grid-cols-2">
+ <div className="container mb-[64px] mt-[90px] lg:mt-0 grid items-center justify-center lg:grid-cols-2">
<div className="flex w-full flex-col items-center justify-center gap-10 lg:items-start">
<div className="relative flex w-full items-center justify-center gap-4 lg:justify-start">
<div className="absolute left-1/2 top-1/2 -z-10 hidden h-56 w-56 -translate-x-[15%] -translate-y-[50%] rounded-full bg-slate-400/10 blur-3xl dark:block"></div>
diff --git a/src/components/landing/waitlist/banner.tsx b/src/components/landing/waitlist/banner.tsx
new file mode 100644
index 00000000..630c82c4
--- /dev/null
+++ b/src/components/landing/waitlist/banner.tsx
@@ -0,0 +1,43 @@
+import Link from 'next/link';
+import { clsx } from 'clsx';
+
+import { Mail } from 'lucide-react';
+import { Balancer } from 'react-wrap-balancer';
+
+import { Button } from '~/components/ui/button';
+import styles from '~/components/landing/waitlist/waitlist.module.css';
+
+const Waitlist = () => {
+ return (
+ <section className={clsx(styles.backdrop, 'relative overflow-hidden')}>
+ <div className="container relative grid grid-cols-1 items-center justify-center md:grid-cols-2">
+ <div className="flex flex-col gap-8 pb-16 pt-56 md:py-16">
+ <h1 className="text-4xl font-bold">
+ <Balancer>Early birds get the perks</Balancer>
+ </h1>
+ <p className="leading-loose text-zinc-600 dark:text-zinc-400">
+ <Balancer>
+ We’re currently working hard to make TypeHero the perfect place for TypeScript
+ enthusiasts and learners. If you believe TypeHero can help you become a better
+ TypeScript developer in the future, consider joining our waitlist.
+ </Balancer>
+ </p>
+
+ <Button
+ className="font-boldtransition-shadow group relative w-fit overflow-hidden rounded-xl bg-gradient-to-bl from-blue-400 to-emerald-400 px-[2px] py-[2px] duration-200"
+ asChild
+ >
+ <Link href="/waitlist">
+ <span className="group-hover:bg-white group-hover:dark:bg-black inline-flex h-full w-fit items-center gap-1 rounded-[10px] bg-neutral-100 px-4 py-2 font-bold text-black transition-colors duration-200 dark:bg-neutral-900 dark:text-white">
+ <Mail className="h-4 w-4" />
+ Join the Waitlist
+ </span>
+ </Link>
+ </Button>
+ </div>
+ </div>
+ </section>
+ );
+};
+
+export default Waitlist;
diff --git a/src/components/landing/waitlist/create.action.ts b/src/components/landing/waitlist/create.action.ts
new file mode 100644
index 00000000..e9f8951d
--- /dev/null
+++ b/src/components/landing/waitlist/create.action.ts
@@ -0,0 +1,27 @@
+'use server';
+
+import { prisma } from '~/server/db';
+import { type WaitlistFormSchema } from '~/components/landing/waitlist/waitlist-form';
+
+export async function uploadWaitlistEntry(data: WaitlistFormSchema) {
+ const isUser = data.intention === 'user';
+ const isBuilder = data.intention === 'builder';
+
+ const existingEntry = await prisma.waitlist.findFirst({
+ where: {
+ email: data.email,
+ },
+ });
+
+ if (existingEntry) {
+ throw new Error('You are already on the waitlist!');
+ }
+
+ return await prisma.waitlist.create({
+ data: {
+ name: data.name,
+ email: data.email,
+ intention: isUser ? 'USER' : isBuilder ? 'BUILDER' : 'BOTH',
+ },
+ });
+}
diff --git a/src/components/landing/waitlist/index.tsx b/src/components/landing/waitlist/index.tsx
new file mode 100644
index 00000000..9d9d0d1b
--- /dev/null
+++ b/src/components/landing/waitlist/index.tsx
@@ -0,0 +1,35 @@
+import { clsx } from 'clsx';
+import { Balancer } from 'react-wrap-balancer';
+
+import WaitlistForm from '~/components/landing/waitlist/waitlist-form';
+import styles from '~/components/landing/waitlist/waitlist.module.css';
+
+export default function WaitlistPage() {
+ return (
+ <main>
+ <div className="absolute left-0 top-0 -z-10 h-full w-full">
+ <div className={clsx(styles.waitlistBackground)} />
+ </div>
+ <div className="container h-full pt-16">
+ <div className="mx-auto flex max-w-[700px] flex-col items-center justify-center gap-6 text-center">
+ <h1 className="text-3xl font-bold text-neutral-950 dark:text-neutral-50 md:text-5xl">
+ <Balancer>
+ Join the waitlist and be part of the{' '}
+ <span className="bg-gradient-to-r from-[#3178c6] to-black bg-clip-text font-black text-transparent dark:to-white">
+ TypeHero
+ </span>{' '}
+ community
+ </Balancer>
+ </h1>
+ <p className="leading-loose text-zinc-600 dark:text-zinc-300">
+ <Balancer>
+ By signing up to the waitlist you will be among the first to know when we launch and
+ getting early access
+ </Balancer>
+ </p>
+ <WaitlistForm />
+ </div>
+ </div>
+ </main>
+ );
+}
diff --git a/src/components/landing/waitlist/waitlist-form.tsx b/src/components/landing/waitlist/waitlist-form.tsx
new file mode 100644
index 00000000..5e7c19db
--- /dev/null
+++ b/src/components/landing/waitlist/waitlist-form.tsx
@@ -0,0 +1,175 @@
+'use client';
+
+import { useState } from 'react';
+import { z } from 'zod';
+import { zodResolver } from '@hookform/resolvers/zod';
+import { useForm } from 'react-hook-form';
+import { AlertCircle, MailCheck } from 'lucide-react';
+import { Alert, AlertDescription } from '~/components/ui/alert';
+
+import { uploadWaitlistEntry } from '~/components/landing/waitlist/create.action';
+import { Button } from '~/components/ui/button';
+import { Form, FormControl, FormField, FormItem } from '~/components/ui/form';
+import { Input } from '~/components/ui/input';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '~/components/ui/select';
+import clsx from 'clsx';
+
+const waitlistFormSchema = z.object({
+ name: z.string().min(1, 'Please enter your name'),
+ email: z.string().email(),
+ intention: z.string(),
+});
+
+export type WaitlistFormSchema = z.infer<typeof waitlistFormSchema>;
+
+export default function WaitlistForm() {
+ const [state, setState] = useState<'idle' | 'submitting' | 'success' | 'error'>('idle');
+
+ const isSubmitting = state === 'submitting';
+
+ const form = useForm<WaitlistFormSchema>({
+ resolver: zodResolver(waitlistFormSchema),
+ defaultValues: {
+ email: '',
+ name: '',
+ },
+ });
+
+ async function onSubmit(data: WaitlistFormSchema) {
+ try {
+ setState('submitting');
+ await uploadWaitlistEntry(data);
+ setState('success');
+ } catch (e) {
+ setState('error');
+ }
+ }
+
+ return (
+ <div className="w-full py-4 md:w-[350px]">
+ <Form {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-4">
+ <FormField
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <FormItem>
+ <FormControl>
+ <Input
+ className={clsx({
+ 'border border-red-600 dark:border-red-400': form.formState.errors.name,
+ 'border-zinc-300 bg-neutral-50 dark:border-zinc-700 dark:bg-neutral-950':
+ !form.formState.errors.name,
+ })}
+ {...field}
+ id="name"
+ autoComplete="name"
+ placeholder="Your name"
+ />
+ </FormControl>
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <FormItem>
+ <FormControl>
+ <Input
+ className={clsx({
+ 'border border-red-600 dark:border-red-400': form.formState.errors.email,
+ 'border-zinc-300 bg-neutral-50 dark:border-zinc-700 dark:bg-neutral-950':
+ !form.formState.errors.email,
+ })}
+ {...field}
+ id="email"
+ autoComplete="email"
+ placeholder="Your email address"
+ />
+ </FormControl>
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="intention"
+ render={({ field }) => (
+ <FormItem>
+ <Select onValueChange={field.onChange} defaultValue={field.value} {...field}>
+ <FormControl>
+ <SelectTrigger
+ className={clsx({
+ 'border border-red-600 dark:border-red-400':
+ form.formState.errors.intention,
+ 'border-zinc-300 bg-neutral-50 dark:border-zinc-700 dark:bg-neutral-950':
+ !form.formState.errors.intention,
+ })}
+ >
+ <SelectValue placeholder="Why are you interested in TypeHero?" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ <SelectItem value="user">I want to solve type challenges</SelectItem>
+ <SelectItem value="builder">I want to build type challenges</SelectItem>
+ <SelectItem value="both">Both</SelectItem>
+ </SelectContent>
+ </Select>
+ </FormItem>
+ )}
+ />
+
+ <Button
+ type="submit"
+ disabled={isSubmitting}
+ className="font-boldtransition-shadow group relative w-full overflow-hidden rounded-xl bg-gradient-to-bl from-blue-400 to-emerald-400 px-[2px] py-[2px] duration-200"
+ >
+ <span className="h-full w-full rounded-[10px] bg-white px-4 py-2 text-center font-bold text-black transition-colors duration-200 group-hover:bg-neutral-100 dark:bg-black dark:text-white group-hover:dark:bg-neutral-900">
+ {isSubmitting ? 'Submitting...' : 'Join the waitlist'}
+ </span>
+ </Button>
+ </form>
+ </Form>
+ <div className="mt-3">
+ {state === 'success' && <AlertSuccess />}
+ {state === 'error' && <AlertDestructive />}
+ </div>
+ </div>
+ );
+}
+
+export function AlertDestructive() {
+ // destructive:
+ // 'destructive group border-destructive bg-destructive text-destructive-foreground',
+ return (
+ <Alert variant="destructive" className="dark:bg-[#230808]">
+ <AlertCircle className="h-4 w-4" />
+ <AlertDescription className="text-left text-black dark:text-white">
+ Something went wrong. Please try again.
+ </AlertDescription>
+ </Alert>
+ );
+}
+
+export function AlertSuccess() {
+ return (
+ <Alert variant="success">
+ <MailCheck className="h-4 w-4" />
+ <AlertDescription className="text-left text-black dark:text-white">
+ Thanks for signing up for the waitlist! Consider{' '}
+ <a target="_blank" className="underline" href="https://twitter.com/typeheroapp">
+ following us on twitter
+ </a>{' '}
+ for general updates.
+ </AlertDescription>
+ </Alert>
+ );
+}
diff --git a/src/components/landing/waitlist/waitlist.module.css b/src/components/landing/waitlist/waitlist.module.css
new file mode 100644
index 00000000..644b9611
--- /dev/null
+++ b/src/components/landing/waitlist/waitlist.module.css
@@ -0,0 +1,50 @@
+/* The module for the Waitlist page background */
+.waitlistBackground {
+ position: relative;
+ top: -56px;
+ min-height: calc(100vh - 56px);
+ background: linear-gradient(0deg, hsl(var(--background)) 0%, rgba(9, 9, 11, 0) 100%),
+ linear-gradient(
+ 270deg,
+ rgba(59, 131, 199, 0) 44.51%,
+ rgba(59, 131, 199, 0.17) 75.5%,
+ rgba(49, 120, 198, 0.3) 100%
+ ),
+ linear-gradient(
+ 90deg,
+ rgba(59, 199, 182, 0) 22.98%,
+ rgba(59, 182, 199, 0.17) 67.78%,
+ rgba(49, 189, 198, 0.3) 100%
+ );
+}
+
+/* The module for the background of the banner on the landing page */
+.backdrop {
+ background: linear-gradient(0deg, hsl(var(--background)) 5%, rgba(0, 0, 0, 0) 100%),
+ linear-gradient(
+ 225deg,
+ rgba(59, 131, 199, 0) 44.51%,
+ rgba(59, 131, 199, 0.17) 75.5%,
+ rgba(49, 120, 198, 0.3) 100%
+ ),
+ url('../../../assets/images/background_pattern.png');
+ background-size: cover;
+ background-position-x: center;
+ background-repeat: no-repeat;
+}
+@media (max-width: 1280px) {
+ .backdrop {
+ background-position-x: 50%;
+ background-size: 1800px;
+ }
+}
+@media (max-width: 768px) {
+ .backdrop {
+ background-position-x: 60%;
+ }
+}
+@media (max-width: 480px) {
+ .backdrop {
+ background-position-x: 70%;
+ }
+}
diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsx
index 71f90e5e..64a25464 100644
--- a/src/components/ui/alert.tsx
+++ b/src/components/ui/alert.tsx
@@ -11,6 +11,8 @@ const alertVariants = cva(
default: 'bg-background text-foreground',
destructive:
'border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive bg-red-100',
+ success:
+ 'border-[#101b15]/50 dark:text-green-700 dark:border-[#101b15] [&>svg]:text-green-300 bg-green-700 dark:bg-[#101b15]',
},
},
defaultVariants: {
diff --git a/src/components/ui/footsies.tsx b/src/components/ui/footsies.tsx
index e3a6922b..84aa2f79 100644
--- a/src/components/ui/footsies.tsx
+++ b/src/components/ui/footsies.tsx
@@ -4,30 +4,6 @@ import { Keyboard as KeyboardIcon } from 'lucide-react';
export function Footsies() {
return (
<footer className="flex flex-col items-center text-sm font-light">
- {/* squiggly divider line */}
- <svg
- aria-hidden="true"
- width="100%"
- height="8"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <pattern id="a" width="91" height="8" patternUnits="userSpaceOnUse">
- <g clipPath="url(#clip0_2426_11367)">
- <path
- d="M114 4c-5.067 4.667-10.133 4.667-15.2 0S88.667-.667 83.6 4 73.467 8.667 68.4 4 58.267-.667 53.2 4 43.067 8.667 38 4 27.867-.667 22.8 4 12.667 8.667 7.6 4-2.533-.667-7.6 4s-10.133 4.667-15.2 0S-32.933-.667-38 4s-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0-10.133-4.667-15.2 0-10.133 4.667-15.2 0"
- strokeLinecap="square"
- className="stroke-neutral-400 dark:stroke-neutral-700"
- />
- </g>
- </pattern>
- <rect width="100%" height="100%" fill="url(#a)" />
- </svg>
- {/* <h2 className="text-4xl font-bold">Early birds get the perks</h2>
- <p className="max-w-[50ch] bg-transparent px-8 lg:px-0 text-center lg:text-left text-black/50 dark:text-white/50">
- TypeHero is currently under construction. We’ll
- let you know as soon as it’s ready!
- </p> */}
<div className="container my-12 flex flex-col justify-between gap-6 px-10 pb-2 lg:flex-row">
<div className="space-x-2">
Built with <KeyboardIcon className="inline-block h-4 w-4 text-blue-500" /> by the Trash
diff --git a/src/components/ui/navigation.tsx b/src/components/ui/navigation.tsx
index 5e805f4c..1222f432 100644
--- a/src/components/ui/navigation.tsx
+++ b/src/components/ui/navigation.tsx
@@ -126,7 +126,7 @@ export function Navigation() {
};
return (
- <header className="w-full">
+ <header className="w-full z-10">
<nav
className={`flex h-14 items-center ${
pathname.startsWith('/challenge') || pathname.startsWith('/admin/challenge')