Connect, collaborate, and grow with a community of TypeScript developers
refactor(web): remove some 'use client' to improve perf (#487)
Tom Lienard5cfef0465388
diff --git a/apps/web/src/app/providers.tsx b/apps/web/src/app/providers.tsxindex 1d378f94..82802116 100644--- a/apps/web/src/app/providers.tsx+++ b/apps/web/src/app/providers.tsx@@ -6,7 +6,6 @@ import { TooltipProvider } from '@repo/ui';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import { ThemeProvider } from 'next-themes';import React from 'react';-import { Provider as BalancerProvider } from 'react-wrap-balancer';import { FeatureFlagProvider } from './feature-flag-provider';interface Props {diff --git a/apps/web/src/components/landing/feature-card.tsx b/apps/web/src/components/landing/feature-card.tsxindex 82a0738b..e338d174 100644--- a/apps/web/src/components/landing/feature-card.tsx+++ b/apps/web/src/components/landing/feature-card.tsx@@ -70,7 +70,7 @@ function FeatureCard({<divclassName={clsx('group relative w-full overflow-hidden rounded-3xl border bg-gradient-to-b from-neutral-50/90 to-neutral-100/90 transition duration-300 dark:from-neutral-950/90 dark:to-neutral-800/90',- !isMobile && 'hover:border-transparent',+ 'md:hover:border-transparent',bgClass,)}>@@ -377,7 +377,6 @@ function Badge({ name }: { name: string }) {);}export function CollaborativeEnvironmentCard(props: CardProps) {- const isMobile = useIsMobile();const { ref, inView } = useInView({triggerOnce: true,});@@ -392,7 +391,7 @@ export function CollaborativeEnvironmentCard(props: CardProps) {className={clsx({ comment1: inView },'rounded-l-3xl bg-neutral-500/10 p-4 pt-3 opacity-0 duration-150',- !isMobile && 'hover:bg-neutral-500/20',+ 'md:hover:bg-neutral-500/20',)}><div className="flex items-center gap-2">@@ -405,7 +404,7 @@ export function CollaborativeEnvironmentCard(props: CardProps) {className={clsx({ comment2: inView },'relative ml-12 rounded-l-3xl bg-neutral-500/10 p-4 pt-3 opacity-0 duration-150',- !isMobile && 'hover:bg-neutral-500/20',+ 'md:hover:bg-neutral-500/20',)}><Reply className="absolute -left-8 h-4 w-4 opacity-50" />@@ -420,7 +419,7 @@ export function CollaborativeEnvironmentCard(props: CardProps) {className={clsx({ comment3: inView },'relative ml-12 rounded-tl-3xl bg-neutral-500/10 p-4 pt-3 opacity-0 duration-150',- !isMobile && 'hover:bg-neutral-500/20',+ 'md:hover:bg-neutral-500/20',)}><Reply className="absolute -left-8 h-4 w-4 opacity-50" />diff --git a/apps/web/src/components/landing/features.tsx b/apps/web/src/components/landing/features.tsxindex 3a720c69..ee4549ee 100644--- a/apps/web/src/components/landing/features.tsx+++ b/apps/web/src/components/landing/features.tsx@@ -1,5 +1,3 @@-'use client';-import { Balancer } from 'react-wrap-balancer';import clsx from 'clsx';import {@@ -22,10 +20,8 @@ import Step2Dark1 from '~/assets/images/step2dark1.png';import Step2Dark2 from '~/assets/images/step2dark2.png';import Step3Light from '~/assets/images/step3light.png';import Step3Dark from '~/assets/images/step3dark.png';-import { useIsMobile } from '~/utils/useIsMobile';function Features() {- const isMobile = useIsMobile();return (<section className="relative overflow-hidden" id="features"><div className="container mb-[64px] grid items-center justify-center">@@ -60,12 +56,12 @@ function Features() {imgClass1={clsx('pointer-events-none transition-transform duration-500 bg-neutral-50/30 dark:bg-neutral-800/30','scale-[150%] sm:scale-[110%] md:scale-100 max-md:rounded-sm rounded-xl top-[69%] left-[69px] md:top-auto w-[42%] md:-bottom-[11%] sm:left-[40px] lg:w-[69%]',- !isMobile && 'group-hover:translate-x-2 group-hover:scale-95',+ 'md:group-hover:translate-x-2 md:group-hover:scale-95',)}imgClass2={clsx('pointer-events-none transition-transform duration-500 bg-neutral-50/50 dark:bg-zinc-800/60 backdrop-blur-sm translate-x-0','scale-[190%] sm:scale-[150%] md:scale-100 rounded-2xl max-md:rounded-md left-[50%] top-[69%] md:top-auto w-[50%] sm:left-[39%] md:-bottom-[12%] lg:w-[77%]',- !isMobile && 'group-hover:scale-105 group-hover:-translate-x-2',+ 'md:group-hover:scale-105 md:group-hover:-translate-x-2',)}description="Engage in TypeScript challenges to strengthen your grasp of the type system and advanced features"bgClass="lg:bg-gradient-to-br"@@ -87,22 +83,22 @@ function Features() {step1img1Class={clsx('pointer-events-none w-[50%] border border-zinc-300/50 transition-all duration-500 dark:border-zinc-700/50','max-md:scale-[160%] max-md:rounded-xl rounded-2xl left-[25%] top-[57%] md:left-[35px] md:top-[41%]',- !isMobile && 'group-hover:translate-y-2',+ 'md:group-hover:translate-y-2',)}step1img2Class={clsx('pointer-events-none w-[60%] border border-zinc-300/50 dark:border-zinc-700/50 transition-all duration-500 overflow-hidden','max-md:scale-[160%] rounded-xl max-md:rounded-lg left-[69%] top-[53%] md:top-[41%] md:left-[calc(50%+35px+1rem)]',- !isMobile && 'group-hover:-translate-y-6',+ 'md:group-hover:-translate-y-6',)}step2img1Class={clsx('pointer-events-none w-[50%] rounded-t-xl overflow-hidden border border-zinc-300 transition-all duration-500 dark:border-zinc-700','max-md:scale-[160%] left-[25%] top-[69%] md:left-[35px] md:top-[30%]',- !isMobile && 'group-hover:translate-y-2',+ 'md:group-hover:translate-y-2',)}step2img2Class={clsx('pointer-events-none w-[110%] rounded-t-xl border border-zinc-300 dark:border-zinc-700 transition-all duration-500 rounded-xl overflow-hidden group-hover:-translate-y-6','max-md:scale-[140%] left-[70%] top-[53%] md:top-[30%] md:left-[calc(50%+35px+1rem)]',- !isMobile && 'group-hover:-translate-y-6',+ 'md:group-hover:-translate-y-6',)}step3imgClass={clsx('pointer-events-none w-[90%] border border-zinc-300 dark:border-zinc-700 rounded-t-2xl transition-all duration-500 overflow-hidden',diff --git a/apps/web/src/components/landing/hero-illustration.tsx b/apps/web/src/components/landing/hero-illustration.tsxnew file mode 100644index 00000000..bc1fd546--- /dev/null+++ b/apps/web/src/components/landing/hero-illustration.tsx@@ -0,0 +1,76 @@+'use client';++import { motion } from 'framer-motion';+import { HeroChallengeCard } from '~/components/landing/hero-challenge-card';+import { useIsMobile } from '~/utils/useIsMobile';++export function HeroIllustration() {+ const isMobile = useIsMobile();++ if (isMobile) {+ return null;+ }++ return (+ <div className="relative hidden h-[800px] overflow-visible rounded-full lg:block">+ <div className="absolute -inset-40 top-1/2 -z-30 -translate-y-1/2 translate-x-[-30px] overflow-hidden rounded-full">+ <div className="relative h-full w-full">+ <motion.div+ animate={{ opacity: 1 }}+ className="moving-grid-background absolute h-[200%] w-full"+ initial={{ opacity: 0 }}+ transition={{ duration: 0.6, delay: 0.6 }}+ />+ <div className="shadow-background absolute h-full w-full rounded-full shadow-[inset_0_0_5rem_3rem]" />+ </div>+ </div>+ <motion.div+ animate={{+ y: 140,+ opacity: 1,+ transition: {+ duration: 0.4,+ },+ }}+ className="group"+ initial={{+ y: 150,+ x: 180,+ opacity: 0,+ }}+ >+ <HeroChallengeCard+ username="bigmang"+ className="absolute"+ difficulty="EASY"+ prompt="Implement a union type of number and string"+ title="Implement a union type of number and string"+ />+ </motion.div>+ <motion.div+ animate={{+ y: 260,+ opacity: 1,+ transition: {+ duration: 0.4,+ delay: 0.1,+ },+ }}+ className="group"+ initial={{+ opacity: 0,+ y: 270,+ x: 80,+ }}+ >+ <HeroChallengeCard+ username="matt"+ className="absolute"+ difficulty="HARD"+ prompt="Convert a string literal to a number"+ title="String to Number"+ />+ </motion.div>+ </div>+ );+}diff --git a/apps/web/src/components/landing/hero.tsx b/apps/web/src/components/landing/hero.tsxindex 9ab7c328..156b4c2f 100644--- a/apps/web/src/components/landing/hero.tsx+++ b/apps/web/src/components/landing/hero.tsx@@ -1,12 +1,8 @@-'use client';--import { motion } from 'framer-motion';import { Github, Mail } from '@repo/ui/icons';import Link from 'next/link';import { Balancer } from 'react-wrap-balancer';import { Button } from '@repo/ui';-import { HeroChallengeCard } from '~/components/landing/hero-challenge-card';-import { useIsMobile } from '~/utils/useIsMobile';+import { HeroIllustration } from './hero-illustration';function TypeHeroLogo() {return (@@ -35,7 +31,6 @@ function TypeHeroLogo() {}function Hero() {- const isMobile = useIsMobile();return (<section className="-mt-[56px] min-h-[calc(100vh)] overflow-hidden lg:min-h-0 lg:pt-[56px]"><div className="container grid min-h-screen items-center justify-center lg:min-h-0 lg:grid-cols-2">@@ -104,68 +99,7 @@ function Hero() {</div></div>- {!isMobile && (- <div className="relative hidden h-[800px] overflow-visible rounded-full lg:block">- <div className="absolute -inset-40 top-1/2 -z-30 -translate-y-1/2 translate-x-[-30px] overflow-hidden rounded-full">- <div className="relative h-full w-full">- <motion.div- animate={{ opacity: 1 }}- className="moving-grid-background absolute h-[200%] w-full"- initial={{ opacity: 0 }}- transition={{ duration: 0.6, delay: 0.6 }}- />- <div className="shadow-background absolute h-full w-full rounded-full shadow-[inset_0_0_5rem_3rem]" />- </div>- </div>- <motion.div- animate={{- y: 140,- opacity: 1,- transition: {- duration: 0.4,- },- }}- className="group"- initial={{- y: 150,- x: 180,- opacity: 0,- }}- >- <HeroChallengeCard- username="bigmang"- className="absolute"- difficulty="EASY"- prompt="Implement a union type of number and string"- title="Implement a union type of number and string"- />- </motion.div>- <motion.div- animate={{- y: 260,- opacity: 1,- transition: {- duration: 0.4,- delay: 0.1,- },- }}- className="group"- initial={{- opacity: 0,- y: 270,- x: 80,- }}- >- <HeroChallengeCard- username="matt"- className="absolute"- difficulty="HARD"- prompt="Convert a string literal to a number"- title="String to Number"- />- </motion.div>- </div>- )}+ <HeroIllustration /></div></section>);diff --git a/apps/web/src/components/ui/footsies.tsx b/apps/web/src/components/ui/footsies.tsxindex 171d5611..dab00995 100644--- a/apps/web/src/components/ui/footsies.tsx+++ b/apps/web/src/components/ui/footsies.tsx@@ -1,4 +1,3 @@-'use client';import { Binary } from '@repo/ui/icons';export function Footsies() {