From 7ade9eae450842feeb01822e8883dcac2003955e Mon Sep 17 00:00:00 2001 From: DWE-CLOUD <85799123+DWE-CLOUD@users.noreply.github.com> Date: Sun, 22 Sep 2024 00:07:26 +0530 Subject: [PATCH] Feat: Fixed apply now and Added Logic --- client/src/components/domains/lightbox.tsx | 47 +++++-- .../src/components/domainsections/domain.tsx | 69 ++++++--- client/src/components/home/domain-cards.tsx | 16 ++- client/src/components/home/header.tsx | 133 ++++++++++++++---- 4 files changed, 202 insertions(+), 63 deletions(-) diff --git a/client/src/components/domains/lightbox.tsx b/client/src/components/domains/lightbox.tsx index 39e3c08..50a1005 100644 --- a/client/src/components/domains/lightbox.tsx +++ b/client/src/components/domains/lightbox.tsx @@ -1,5 +1,5 @@ "use client"; -import React, { memo } from 'react'; +import React, { memo, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import Image from 'next/image'; import { AiOutlineClose } from 'react-icons/ai'; @@ -26,6 +26,24 @@ const Lightbox: React.FC = ({ showForm, setShowForm, }) => { + + useEffect(() => { + if (domain) { + const currentPath = window.location.pathname.toLowerCase(); + const domainTitle = domain.title.toLowerCase(); + + // Only for use using the debug timings + console.log("Current Path: ", currentPath); + console.log("Domain Title: ", domainTitle); + + + if (currentPath.includes(domainTitle)) { + console.log(`Path matches domain ${domain.title}, showing form.`); + setShowForm(true); + } + } + }, [domain, setShowForm]); + if (!domain) return null; const containerVariants = { @@ -42,12 +60,12 @@ const Lightbox: React.FC = ({ return ( = ({ animate="animate" exit="exit" layout - transition={{ layout: { duration: 0.6, ease: 'easeInOut' } }} + transition={{layout: {duration: 0.6, ease: 'easeInOut'}}} > @@ -74,7 +92,7 @@ const Lightbox: React.FC = ({

{domain.title}

-

{domain.description}

{/* Added padding (px-6) here */} +

{domain.description}

@@ -85,21 +103,21 @@ const Lightbox: React.FC = ({ animate="animate" exit="exit" variants={contentVariants} - transition={{ duration: 0.4, ease: 'easeOut' }} + transition={{duration: 0.4, ease: 'easeOut'}} className="flex space-x-4" - style={{ minHeight: "35px" }} + style={{minHeight: "35px"}} > setShowForm(true)} > APPLY (window.location.href = `/${domain.title.toLowerCase()}`) @@ -115,9 +133,9 @@ const Lightbox: React.FC = ({ animate="animate" exit="exit" variants={contentVariants} - transition={{ duration: 0.4, ease: 'easeOut' }} + transition={{duration: 0.4, ease: 'easeOut'}} className="w-full" - style={{ minHeight: "50vh" }} + style={{minHeight: "50vh"}} >
= ({
+ ); }; diff --git a/client/src/components/domainsections/domain.tsx b/client/src/components/domainsections/domain.tsx index d80ad38..5846652 100644 --- a/client/src/components/domainsections/domain.tsx +++ b/client/src/components/domainsections/domain.tsx @@ -11,31 +11,59 @@ type DomainProps = { sections: { heading: string; content: string }[]; }; -export default function Domain({ imgSrc, altText, sections }: DomainProps) { +export default function Domain({ imgSrc, sections }: DomainProps) { const [hasAnimated, setHasAnimated] = useState(false); + const iconVariants = { + initial: { opacity: 0, x: -50, y: -50, rotate: 0 }, + animate: { + opacity: 1, + x: 0, + y: 0, + rotate: [0, 10, -10, 0], + transition: { + type: "spring", + stiffness: 200, + damping: 10, + duration: 1, + ease: "easeInOut", + repeat: Infinity, + repeatType: "mirror" as "mirror", //eslint-disable-line @typescript-eslint/prefer-as-const + }, + }, + }; + return ( -
-
-
- - {altText} - +
+ + Icon + +
+
{sections.map((section, index) => ( { @@ -60,7 +88,6 @@ export default function Domain({ imgSrc, altText, sections }: DomainProps) { animate={{ opacity: 1 }} transition={{ duration: 0.5, delay: lineIndex * 0.1 }} > - {line}
@@ -69,7 +96,7 @@ export default function Domain({ imgSrc, altText, sections }: DomainProps) { ))}
-
+
); -} +} \ No newline at end of file diff --git a/client/src/components/home/domain-cards.tsx b/client/src/components/home/domain-cards.tsx index c4f83ef..bb5a8da 100644 --- a/client/src/components/home/domain-cards.tsx +++ b/client/src/components/home/domain-cards.tsx @@ -76,10 +76,10 @@ const DomainCard: React.FC = ({
-

+

{domain.title}

-

+

{domain.description}

@@ -89,17 +89,25 @@ const DomainCard: React.FC = ({ ); + const Button: React.FC<{ onClick: () => void }> = ({ onClick }) => ( APPLY NOW ); + + const DomainsComponent = () => { const [selectedDomain, setSelectedDomain] = useState(null); const [showForm, setShowForm] = useState(false); diff --git a/client/src/components/home/header.tsx b/client/src/components/home/header.tsx index 2802a5b..1adbc3e 100644 --- a/client/src/components/home/header.tsx +++ b/client/src/components/home/header.tsx @@ -1,8 +1,51 @@ "use client"; -import React from 'react'; +import React, { useState } from 'react'; import Image from 'next/image'; import Logo from './colour.svg'; import { motion } from 'framer-motion'; +import Lightbox from '@/components/domains/lightbox'; +//import DomainsComponent from './domain-cards'; +interface Domain { + title: string; + description: string; + image: string; + gradient: string; + subdomains: string[]; +} + + +const domains: Domain[] = [ + { + title: 'Technical', + description: 'Level Up Your Skills, Unlock New Worlds', + image: '/1.png', + gradient: 'from-purple-900 to-purple-800', + subdomains: ['Ai/ML', 'App Dev', 'Web Dev'], + }, + { + title: 'Research', + description: + "It's about seeing what everybody else has seen and thinking what nobody else has thought", + image: '/2.png', + gradient: 'from-fuchsia-900 to-fuchsia-800', + subdomains: ['Research'], + }, + { + title: 'Creatives', + description: 'Everything you can imagine is real', + image: '/3.png', + gradient: 'from-pink-900 to-pink-800', + subdomains: ['UI/UX', 'Photography', 'VFX'], + }, + { + title: 'Corporate', + description: + 'Master the game of business with strategy, connections, and vision', + image: '/4.png', + gradient: 'from-blue-900 to-blue-800', + subdomains: ['Content', 'PR & Events', 'Sponsorship'], + }, +]; const Header: React.FC = () => { const scrollToDomain = () => { @@ -13,7 +56,35 @@ const Header: React.FC = () => { }; const navigateHome = () => { - window.location.href = '/'; // N + window.location.href = '/'; + }; + + const [selectedDomain, setSelectedDomain] = useState(null); + + const handleApplyNowClick = () => { + const currentPath = window.location.pathname; + if (currentPath === '/technical' || currentPath === '/creatives' || currentPath === '/research'|| currentPath === '/corporate') { + let domain: Domain | undefined; + if (currentPath === '/technical') { + domain = domains.find((d) => d.title === 'Technical'); + } else if (currentPath === '/creatives') { + domain = domains.find((d) => d.title === 'Creatives'); + } else if (currentPath === '/research') { + domain = domains.find((d) => d.title === 'Research'); + }else if (currentPath === '/corporate') { + domain = domains.find((d) => d.title === 'Corporate'); + } + + if (domain) { + setSelectedDomain(domain); + } + } else { + scrollToDomain(); + } + }; + + const closeLightbox = () => { + setSelectedDomain(null); }; return ( @@ -23,53 +94,67 @@ const Header: React.FC = () => {
- Logo + Logo Data Science -
+
Community{" "} SRM
- - {/* Enhanced "Apply Now" Button */} - + + Apply Now + +
+ { + }} + />
); }; -export default Header; +export default Header; \ No newline at end of file