From bea597132ba5ed77043c4101d0c3444055fd172f Mon Sep 17 00:00:00 2001 From: Jordan <79342877+Jordan231111@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:06:22 -0400 Subject: [PATCH 1/6] Fixed faq not collpasing --- components/faq/faq.tsx | 53 +++++++++++++++--------------------------- package-lock.json | 2 +- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/components/faq/faq.tsx b/components/faq/faq.tsx index 2980231..78dff20 100644 --- a/components/faq/faq.tsx +++ b/components/faq/faq.tsx @@ -1,5 +1,5 @@ -import React, { useEffect, useState } from "react"; -import "../../app/globals.css"; // Global styles location for tailwind css +import React, { useState } from "react"; +import "../../app/globals.css"; import RegistrationButton from "../nav-bar/registration-button"; type FAQ = { @@ -33,7 +33,7 @@ const faqs: FAQ[] = [ content: (

Click here to register:

- + {/* This is a custom button component will update later */}
), }, @@ -50,7 +50,7 @@ const faqs: FAQ[] = [ { title: "Who else will be there?", content: - "Not only can you meet other RPI students and people from other colleges, but we’ve got wonderful sponsors who make this event possible! You’ll have the opportunity to talk to representatives from a variety of tech companies at career-fair style tables.", + "Not only can you meet other RPI students and people from other colleges, but we've got wonderful sponsors who make this event possible! You'll have the opportunity to talk to representatives from a variety of tech companies at career-fair style tables.", }, { title: "Does HackRPI provide travel reimbursement?", @@ -61,41 +61,21 @@ const faqs: FAQ[] = [ const FAQPage = () => { const [highlightFAQ, setHighlightFAQ] = useState(false); + const [expandedIndex, setExpandedIndex] = useState(null); - useEffect(() => { - // Highlight the FAQ section in the navbar when the user scrolls to it - let faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; - let faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - - // Update whether the faq should be highlighted when the user scrolls - const handleScroll = () => { - setHighlightFAQ(window.scrollY > faqStart && window.scrollY < faqEnd); - faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; - faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - }; - - // Update the faqStart and faqEnd when the user resizes the window - const handleResize = () => { - faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; - faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - }; - window.addEventListener("resize", handleResize); - window.addEventListener("scroll", handleScroll); - return () => { - window.removeEventListener("scroll", handleScroll); - }; - }, []); + const handleToggle = (index: number) => { + setExpandedIndex((prevIndex) => (prevIndex === index ? null : index)); + }; return ( -
+
-

FAQs

+

FAQs

@@ -107,13 +87,18 @@ const FAQPage = () => { index === faqs.length - 1 ? "border-b-2" : "" } border-hackrpi-primary-blue rounded-none`} > - + handleToggle(index)} + />
{faq.title}
{faq.content}
))}
-
+

Feel free to contact us with any other questions at{" "} diff --git a/package-lock.json b/package-lock.json index 534be62..a4e8c33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5318,4 +5318,4 @@ } } } -} \ No newline at end of file +} From 9420202c75549d6b6af2923443e68f25afbed8cb Mon Sep 17 00:00:00 2001 From: Jordan <79342877+Jordan231111@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:12:01 -0400 Subject: [PATCH 2/6] Fix accidentally removed some code --- components/faq/faq.tsx | 129 +++++++++++++++++++++++++---------------- 1 file changed, 79 insertions(+), 50 deletions(-) diff --git a/components/faq/faq.tsx b/components/faq/faq.tsx index 78dff20..28cfcc6 100644 --- a/components/faq/faq.tsx +++ b/components/faq/faq.tsx @@ -1,10 +1,10 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import "../../app/globals.css"; import RegistrationButton from "../nav-bar/registration-button"; type FAQ = { - title: string; - content: React.ReactNode; + title: string; + content: React.ReactNode; }; const faqs: FAQ[] = [ @@ -59,55 +59,84 @@ const faqs: FAQ[] = [ }, ]; + const FAQPage = () => { - const [highlightFAQ, setHighlightFAQ] = useState(false); - const [expandedIndex, setExpandedIndex] = useState(null); + const [highlightFAQ, setHighlightFAQ] = useState(false); + const [expandedIndex, setExpandedIndex] = useState(null); - const handleToggle = (index: number) => { - setExpandedIndex((prevIndex) => (prevIndex === index ? null : index)); - }; + useEffect(() => { + let faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; + let faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - return ( - - ); + const handleScroll = () => { + setHighlightFAQ(window.scrollY > faqStart && window.scrollY < faqEnd); + faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; + faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); + }; + + const handleResize = () => { + faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; + faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); + }; + + window.addEventListener("resize", handleResize); + window.addEventListener("scroll", handleScroll); + + return () => { + window.removeEventListener("resize", handleResize); + window.removeEventListener("scroll", handleScroll); + }; + }, []); + + const handleToggle = (index: number) => { + setExpandedIndex((prevIndex) => (prevIndex === index ? null : index)); + }; + + return ( +
+
+

+ FAQs +

+
+
+
+
+
+ {faqs.map((faq, index) => ( +
+ handleToggle(index)} + /> +
+ {faq.title} +
+
{faq.content}
+
+ ))} +
+
+

+ Feel free to contact us with any other questions at{" "} + + hackrpi@rpi.edu! + +

+
+
+ ); }; -export default FAQPage; +export default FAQPage; \ No newline at end of file From 4001af0bbb4a55c93b2d754e6c6fef0a5374f3b1 Mon Sep 17 00:00:00 2001 From: Jordan231111 Date: Mon, 22 Apr 2024 01:15:01 +0000 Subject: [PATCH 3/6] Prettified Code! --- components/faq/faq.tsx | 141 ++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 73 deletions(-) diff --git a/components/faq/faq.tsx b/components/faq/faq.tsx index 28cfcc6..b91f578 100644 --- a/components/faq/faq.tsx +++ b/components/faq/faq.tsx @@ -3,8 +3,8 @@ import "../../app/globals.css"; import RegistrationButton from "../nav-bar/registration-button"; type FAQ = { - title: string; - content: React.ReactNode; + title: string; + content: React.ReactNode; }; const faqs: FAQ[] = [ @@ -59,84 +59,79 @@ const faqs: FAQ[] = [ }, ]; - const FAQPage = () => { - const [highlightFAQ, setHighlightFAQ] = useState(false); - const [expandedIndex, setExpandedIndex] = useState(null); + const [highlightFAQ, setHighlightFAQ] = useState(false); + const [expandedIndex, setExpandedIndex] = useState(null); - useEffect(() => { - let faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; - let faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); + useEffect(() => { + let faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; + let faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - const handleScroll = () => { - setHighlightFAQ(window.scrollY > faqStart && window.scrollY < faqEnd); - faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; - faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - }; + const handleScroll = () => { + setHighlightFAQ(window.scrollY > faqStart && window.scrollY < faqEnd); + faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; + faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); + }; - const handleResize = () => { - faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; - faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - }; + const handleResize = () => { + faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; + faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); + }; - window.addEventListener("resize", handleResize); - window.addEventListener("scroll", handleScroll); + window.addEventListener("resize", handleResize); + window.addEventListener("scroll", handleScroll); - return () => { - window.removeEventListener("resize", handleResize); - window.removeEventListener("scroll", handleScroll); - }; - }, []); + return () => { + window.removeEventListener("resize", handleResize); + window.removeEventListener("scroll", handleScroll); + }; + }, []); - const handleToggle = (index: number) => { - setExpandedIndex((prevIndex) => (prevIndex === index ? null : index)); - }; + const handleToggle = (index: number) => { + setExpandedIndex((prevIndex) => (prevIndex === index ? null : index)); + }; - return ( -
-
-

- FAQs -

-
-
-
-
-
- {faqs.map((faq, index) => ( -
- handleToggle(index)} - /> -
- {faq.title} -
-
{faq.content}
-
- ))} -
-
-

- Feel free to contact us with any other questions at{" "} - - hackrpi@rpi.edu! - -

-
-
- ); + return ( +
+
+

FAQs

+
+
+
+
+
+ {faqs.map((faq, index) => ( +
+ handleToggle(index)} + /> +
{faq.title}
+
{faq.content}
+
+ ))} +
+
+

+ Feel free to contact us with any other questions at{" "} + + hackrpi@rpi.edu! + +

+
+
+ ); }; -export default FAQPage; \ No newline at end of file +export default FAQPage; From 4b4edfa37a872c7f4c2094476f519a4b7c804c22 Mon Sep 17 00:00:00 2001 From: Jordan <79342877+Jordan231111@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:32:16 -0400 Subject: [PATCH 4/6] add back comments --- components/faq/faq.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/faq/faq.tsx b/components/faq/faq.tsx index b91f578..6d97ee2 100644 --- a/components/faq/faq.tsx +++ b/components/faq/faq.tsx @@ -64,15 +64,19 @@ const FAQPage = () => { const [expandedIndex, setExpandedIndex] = useState(null); useEffect(() => { + // Highlight the FAQ section in the navbar when the user scrolls to it let faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; let faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); + + // Update whether the faq should be highlighted when the user scrolls const handleScroll = () => { setHighlightFAQ(window.scrollY > faqStart && window.scrollY < faqEnd); faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); }; + // Update the faqStart and faqEnd when the user resizes the window const handleResize = () => { faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); From 9b9ccbce53acb21842ff97e4d56fc8189e1a77ab Mon Sep 17 00:00:00 2001 From: Jordan231111 Date: Mon, 22 Apr 2024 01:32:19 +0000 Subject: [PATCH 5/6] Prettified Code! --- components/faq/faq.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/components/faq/faq.tsx b/components/faq/faq.tsx index 6d97ee2..2ca75d0 100644 --- a/components/faq/faq.tsx +++ b/components/faq/faq.tsx @@ -68,7 +68,6 @@ const FAQPage = () => { let faqStart = (document.getElementById("faq")?.offsetTop || window.innerHeight) - 140; let faqEnd = faqStart + (document.getElementById("faq")?.offsetHeight || window.innerHeight); - // Update whether the faq should be highlighted when the user scrolls const handleScroll = () => { setHighlightFAQ(window.scrollY > faqStart && window.scrollY < faqEnd); From 1a26e7f5bc36033a70577df5f7aab8bebd6aea99 Mon Sep 17 00:00:00 2001 From: Cooper Werner Date: Sun, 21 Apr 2024 21:34:10 -0400 Subject: [PATCH 6/6] Fix nav button --- components/mlh-banner/mlh-banner.tsx | 2 +- components/nav-bar/nav-bar.tsx | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/mlh-banner/mlh-banner.tsx b/components/mlh-banner/mlh-banner.tsx index 1509e04..5e1b8f0 100644 --- a/components/mlh-banner/mlh-banner.tsx +++ b/components/mlh-banner/mlh-banner.tsx @@ -6,7 +6,7 @@ export default function MlhBanner() { id="mlh-trust-badge" href="https://mlh.io/na?utm_source=na-hackathon&utm_medium=TrustBadge&utm_campaign=2024-season&utm_content=white" target="_blank" - className="block max-w-[80] desktop:max-w-[100px] min-w-[60px] w-[10%] h-auto fixed right-[25px] desktop:right-[50px] top-0 z-[10000] " + className="block max-w-[80] desktop:max-w-[100px] min-w-[60px] w-[10%] h-auto fixed right-[25px] desktop:right-[75px] top-0 z-[10000] " > + ); @@ -38,6 +40,7 @@ export default function NavBar({ showOnScroll }: { showOnScroll: boolean }) { <>
+
);