From e1de9fa161e56a3c499e66ce2a1f9e784c20328d Mon Sep 17 00:00:00 2001 From: defiQUG Date: Sat, 4 Oct 2025 20:52:35 -0700 Subject: [PATCH] feat: implement 3D parallax effects and floating particles in the main app layout; enhance Tailwind CSS configuration with perspective utilities --- src/App.tsx | 227 +++++++++++++++++++++++++++++++++++++++----- tailwind.config.cjs | 18 ++++ 2 files changed, 222 insertions(+), 23 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 742290d..9cf66e8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ -import React, { useState, useEffect } from 'react' -import { motion, useMotionValue, useSpring, useTransform } from 'framer-motion' +import React, { useState, useEffect, useRef } from 'react' +import { motion, useMotionValue, useSpring, useTransform, useScroll } from 'framer-motion' import { ArrowRight, Backpack, @@ -64,6 +64,7 @@ interface CalloutProps { href: string accent: string icon: React.ComponentType + index?: number } interface PageShellProps { @@ -86,6 +87,71 @@ interface PolicySectionProps { children: React.ReactNode } +/* ===================== 3D Parallax Components ===================== */ + +// 3D Parallax Container Component +interface ParallaxContainerProps { + children: React.ReactNode + depth?: number + className?: string +} + +function ParallaxContainer({ children, depth = 1, className = '' }: ParallaxContainerProps) { + const ref = useRef(null) + const { scrollYProgress } = useScroll({ + target: ref, + offset: ['start end', 'end start'] + }) + + const y = useTransform(scrollYProgress, [0, 1], [0, -50 * depth]) + const rotateX = useTransform(scrollYProgress, [0, 1], [0, 5 * depth]) + const scale = useTransform(scrollYProgress, [0, 0.5, 1], [0.8, 1, 1.1]) + + return ( + + {children} + + ) +} + +// Floating Particles Background +function FloatingParticles() { + const particles = Array.from({ length: 50 }, (_, i) => i) + + return ( +
+ {particles.map((i) => ( + + ))} +
+ ) +} + /* ===================== Router ===================== */ function useHashRoute() { const parse = () => (window.location.hash?.slice(1) || "/") @@ -252,16 +318,38 @@ function HomePage() { } function Hero() { + const containerRef = useRef(null) + const { scrollYProgress } = useScroll({ + target: containerRef, + offset: ['start start', 'end start'] + }) + + const backgroundY = useTransform(scrollYProgress, [0, 1], ['0%', '50%']) + const contentY = useTransform(scrollYProgress, [0, 1], ['0%', '100%']) + return ( -
-
-
+
+ {/* 3D Background Layer */} + + + + + {/* Content Layer with Parallax */} + + Equipping kids for success— school supplies, clothing, & more @@ -287,10 +375,51 @@ function Hero() {
  • Donations tax-deductible
  • Community-driven impact
  • -
    -
    + + + -
    + + + + {/* 3D Floating Elements */} +
    + + + + + + + + +
    ) @@ -421,12 +550,30 @@ function Impact() { ] return ( -
    +
    - + + + +
    {stats.map((s, i) => ( - + + + + + ))}
    @@ -549,30 +696,64 @@ function GetInvolved() { ] return ( -
    +
    - + + + +
    - {options.map((o, i) => ())} + {options.map((o, i) => ( + + + + ))}
    ) } -function Callout({ title, body, href, accent, icon: Icon }: CalloutProps) { +function Callout({ title, body, href, accent, icon: Icon, index = 0 }: CalloutProps) { return ( -
    -
    -
    + +
    + + -
    +
    +
    {title}

    {body}

    - + + Learn more - -
    + + ) } diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 774830e..bb73c4e 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -62,9 +62,27 @@ module.exports = { backdropBlur: { xs: '2px', }, + perspective: { + '300': '300px', + '500': '500px', + '1000': '1000px', + '2000': '2000px', + }, }, }, plugins: [ require('@tailwindcss/typography'), + function({ addUtilities }) { + addUtilities({ + '.perspective-300': { perspective: '300px' }, + '.perspective-500': { perspective: '500px' }, + '.perspective-1000': { perspective: '1000px' }, + '.perspective-2000': { perspective: '2000px' }, + '.transform-style-preserve-3d': { 'transform-style': 'preserve-3d' }, + '.transform-style-flat': { 'transform-style': 'flat' }, + '.backface-hidden': { 'backface-visibility': 'hidden' }, + '.backface-visible': { 'backface-visibility': 'visible' }, + }) + } ], } \ No newline at end of file