Skip to content

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

Add features section to landing page (#283)

Ernesto Resendee5f039b5bdf6
diff --git a/package.json b/package.json
index 53f0b484..0c3cf613 100644
--- a/package.json
+++ b/package.json
@@ -62,6 +62,7 @@
"react-intersection-observer": "^9.5.2",
"react-markdown": "^8.0.7",
"react-syntax-highlighter": "^15.5.0",
+ "react-wrap-balancer": "^1.0.0",
"remark-gfm": "^3.0.1",
"simple-git": "^3.19.1",
"superjson": "1.12.4",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c5e555a4..120ff0ff 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -148,6 +148,9 @@ dependencies:
react-syntax-highlighter:
specifier: ^15.5.0
version: 15.5.0([email protected])
+ react-wrap-balancer:
+ specifier: ^1.0.0
+ version: 1.0.0([email protected])
remark-gfm:
specifier: ^3.0.1
version: 3.0.1
@@ -286,6 +289,7 @@ packages:
/@emotion/[email protected]:
resolution: {integrity: sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==}
+ requiresBuild: true
dev: false
optional: true
@@ -6061,6 +6065,14 @@ packages:
refractor: 3.6.0
dev: false
+ resolution: {integrity: sha512-yjDH+I8WGyDfh95gKhX/6ckfSBAltwQkxiYxtLPlyIRQNUVSjvz1uHR6Hpy+zHyOkJQw6GEC5RPglA41QXvzyw==}
+ peerDependencies:
+ react: '>=16.8.0 || ^17.0.0 || ^18'
+ dependencies:
+ react: 18.2.0
+ dev: false
+
resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}
engines: {node: '>=0.10.0'}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 2f47630d..087bd3b9 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,4 +1,5 @@
import Head from 'next/head';
+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';
@@ -15,10 +16,12 @@ export default async function Index() {
/>
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
</Head>
- <Hero />
- <Features />
- <Community />
- <Footsies />
+ <BalancerProvider>
+ <Hero />
+ <Features />
+ <Community />
+ <Footsies />
+ </BalancerProvider>
</>
);
}
diff --git a/src/assets/images/feature_card_challenge_dark.png b/src/assets/images/feature_card_challenge_dark.png
new file mode 100644
index 00000000..30918c44
Binary files /dev/null and b/src/assets/images/feature_card_challenge_dark.png differ
diff --git a/src/assets/images/feature_card_challenge_light.png b/src/assets/images/feature_card_challenge_light.png
new file mode 100644
index 00000000..0addbc95
Binary files /dev/null and b/src/assets/images/feature_card_challenge_light.png differ
diff --git a/src/components/landing/community.tsx b/src/components/landing/community.tsx
index 4e2612f8..8fb7d472 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 flex min-h-[80lvh] flex-col justify-center lg:flex-row lg:items-center">
+ <section className="container mt-[48px] flex min-h-[80lvh] 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/feature-card.tsx b/src/components/landing/feature-card.tsx
new file mode 100644
index 00000000..c7a068cc
--- /dev/null
+++ b/src/components/landing/feature-card.tsx
@@ -0,0 +1,100 @@
+'use client';
+
+import Image from 'next/image';
+import { type StaticImageData } from 'next/image';
+import { useTheme } from 'next-themes';
+import { useEffect, type CSSProperties, type MouseEvent, useState } from 'react';
+import {
+ motion,
+ useMotionTemplate,
+ useMotionValue,
+ type MotionStyle,
+ type MotionValue,
+} from 'framer-motion';
+
+type WrapperStyle = MotionStyle & {
+ '--x': MotionValue<string>;
+ '--y': MotionValue<string>;
+};
+
+export const FeatureCard = ({
+ title,
+ description,
+ className,
+ image,
+}: {
+ title: string;
+ description: string;
+ className?: string;
+ image: {
+ dark: StaticImageData;
+ light: StaticImageData;
+ alt: string;
+ };
+}) => {
+ const { resolvedTheme } = useTheme();
+ const [mounted, setMounted] = useState(false);
+ const mouseX = useMotionValue(0);
+ const mouseY = useMotionValue(0);
+
+ function handleMouseMove({ currentTarget, clientX, clientY }: MouseEvent) {
+ const { left, top } = currentTarget.getBoundingClientRect();
+
+ mouseX.set(clientX - left);
+ mouseY.set(clientY - top);
+ }
+
+ useEffect(() => {
+ setMounted(true);
+ }, []);
+
+ return (
+ <motion.div
+ className="animated-feature-cards h-full w-full drop-shadow-[0_0_15px_rgba(49,49,49,0.2)] dark:drop-shadow-[0_0_15px_rgba(49,49,49,0.2)]"
+ onMouseMove={handleMouseMove}
+ style={
+ {
+ '--x': useMotionTemplate`${mouseX}px`,
+ '--y': useMotionTemplate`${mouseY}px`,
+ } as WrapperStyle
+ }
+ >
+ <motion.div className="group b-black/90 relative h-full w-full overflow-hidden rounded-xl border bg-gradient-to-b from-neutral-50/90 to-neutral-100/90 backdrop-blur-2xl transition duration-300 hover:border-transparent dark:from-neutral-950/90 dark:to-neutral-800/90">
+ <div className="mx-10 my-10 min-h-[450px] w-full">
+ <div className="flex w-4/6 flex-col gap-3">
+ <h2 className="text-xl font-bold tracking-tight md:text-xl">{title}</h2>
+ <p className="text-base leading-7 text-zinc-600 dark:text-zinc-400">{description}</p>
+ </div>
+ {mounted && (
+ <>
+ {resolvedTheme === 'light' && (
+ <Image
+ src={image.light}
+ alt={image.alt}
+ className={className}
+ style={{
+ position: 'absolute',
+ userSelect: 'none',
+ maxWidth: 'unset',
+ }}
+ />
+ )}
+ {resolvedTheme === 'dark' && (
+ <Image
+ src={image.dark}
+ alt={image.alt}
+ className={className}
+ style={{
+ position: 'absolute',
+ userSelect: 'none',
+ maxWidth: 'unset',
+ }}
+ />
+ )}
+ </>
+ )}
+ </div>
+ </motion.div>
+ </motion.div>
+ );
+};
diff --git a/src/components/landing/features.tsx b/src/components/landing/features.tsx
index 7dbbfcee..a203569e 100644
--- a/src/components/landing/features.tsx
+++ b/src/components/landing/features.tsx
@@ -1,2 +1,43 @@
-const Features = () => <></>;
+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';
+
+const Features = () => {
+ return (
+ <section className="relative overflow-hidden border-b bg-gradient-to-t from-neutral-400/10 to-transparent">
+ <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>
+ </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%]"
+ image={{
+ dark: FeatureCardChallengeDark,
+ light: FeatureCardChallengeLight,
+ alt: 'Something',
+ }}
+ />
+
+ <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%]"
+ image={{
+ dark: FeatureCardChallengeDark,
+ light: FeatureCardChallengeLight,
+ alt: 'Something',
+ }}
+ />
+ </div>
+ </div>
+ </div>
+ </section>
+ );
+};
export default Features;
diff --git a/src/components/landing/hero.tsx b/src/components/landing/hero.tsx
index c72bbb00..7e2a88fc 100644
--- a/src/components/landing/hero.tsx
+++ b/src/components/landing/hero.tsx
@@ -1,5 +1,6 @@
'use client';
+import { Balancer } from 'react-wrap-balancer';
import { Github } from 'lucide-react';
import { motion } from 'framer-motion';
import { Button } from '~/components/ui/button';
@@ -40,7 +41,7 @@ const Hero = () => (
</filter>
<rect width="100%" height="100%" filter="url(#noise)"></rect>
</svg> */}
- <div className="container mb-[56px] grid min-h-[calc(100lvh_-_112px)] items-center justify-center lg:grid-cols-2">
+ <div className="container mb-[128px] 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>
@@ -53,9 +54,11 @@ const Hero = () => (
</h1>
</div>
- <p className="max-w-[50ch] bg-transparent px-8 text-center leading-8 text-black/50 dark:text-white/50 lg:px-0 lg:text-left">
- Connect, collaborate, and grow with a community of TypeScript developers. Elevate your
- skills trough interactive coding challenges, discussions, and knowledge sharing
+ <p className="bg-transparent px-8 text-center font-medium leading-8 text-zinc-600 dark:text-zinc-300 lg:px-0 lg:text-left">
+ <Balancer>
+ Connect, collaborate, and grow with a community of TypeScript developers. Elevate your
+ skills trough interactive coding challenges, discussions, and knowledge sharing
+ </Balancer>
</p>
<div className="flex gap-3">
<Button
@@ -78,12 +81,12 @@ const Hero = () => (
</div>
<div className="relative hidden h-[800px] overflow-visible rounded-full lg:block">
- <div className="absolute -inset-40 top-1/2 -z-30 aspect-square -translate-y-1/2 translate-x-[-30px] overflow-hidden rounded-full">
+ <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
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
- transition={{ duration: 0.6, delay: 0.3 }}
+ transition={{ duration: 0.6, delay: 0.6 }}
className="moving-grid-background absolute h-[200%] w-full"
/>
<div className="absolute h-full w-full rounded-full shadow-[inset_0_0_5rem_3rem] shadow-background" />
@@ -91,13 +94,16 @@ const Hero = () => (
</div>
<motion.div
initial={{
- y: 80,
- x: 140,
+ y: 150,
+ x: 180,
opacity: 0,
}}
animate={{
- y: 70,
+ y: 140,
opacity: 1,
+ transition: {
+ duration: 0.4,
+ }
}}
className="group"
>
@@ -111,13 +117,14 @@ const Hero = () => (
initial={{
opacity: 0,
y: 270,
- x: 20,
+ x: 80,
}}
animate={{
y: 260,
opacity: 1,
transition: {
- duration: 0.5,
+ duration: 0.4,
+ delay: 0.1,
},
}}
className="group"
diff --git a/src/styles/globals.css b/src/styles/globals.css
index e9e209ac..356f4016 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -155,12 +155,41 @@ main {
.moving-grid-background {
will-change: transform;
- background-size: 2.5rem 2.5rem;
+ background-size: 3rem 3rem;
background-image: linear-gradient(to right, #8882 1px, transparent 1px),
linear-gradient(to bottom, #8882 1px, transparent 1px);
animation: movingbackground 90s linear infinite !important;
}
+.features-background-mask {
+ mask-image: linear-gradient(
+ rgba(0, 0, 0, 0) 0%,
+ rgba(0, 0, 0, 0) 50%,
+ rgba(0, 0, 0, 1) 100%
+ );
+ -webkit-mask-image: linear-gradient(
+ rgba(0, 0, 0, 0) 0%,
+ rgba(0, 0, 0, 0) 50%,
+ rgba(0, 0, 0, 1) 100%
+ );
+}
+
+.animated-feature-cards::before {
+ @apply pointer-events-none absolute select-none rounded-xl opacity-0 transition-opacity duration-300 hover:opacity-100;
+ background: radial-gradient(
+ 1000px circle at var(--x) var(--y),
+ #5295dc 0,
+ rgba(255, 255, 255, 0) 50%,
+ transparent 80%
+ );
+ z-index: -1;
+ content: '';
+ top: -1px;
+ bottom: -1px;
+ left: -1px;
+ right: -1px;
+}
+
@keyframes movingbackground {
0% {
transform: translate(0, 0);