diff --git a/jules-scratch/verification/verify-about.png b/jules-scratch/verification/verify-about.png new file mode 100644 index 00000000..b396ee68 Binary files /dev/null and b/jules-scratch/verification/verify-about.png differ diff --git a/jules-scratch/verification/verify-contact.png b/jules-scratch/verification/verify-contact.png new file mode 100644 index 00000000..9e1811fa Binary files /dev/null and b/jules-scratch/verification/verify-contact.png differ diff --git a/jules-scratch/verification/verify-top.png b/jules-scratch/verification/verify-top.png new file mode 100644 index 00000000..ce547041 Binary files /dev/null and b/jules-scratch/verification/verify-top.png differ diff --git a/jules-scratch/verification/verify-work.png b/jules-scratch/verification/verify-work.png new file mode 100644 index 00000000..03b54fcb Binary files /dev/null and b/jules-scratch/verification/verify-work.png differ diff --git a/jules-scratch/verification/verify_navbar.py b/jules-scratch/verification/verify_navbar.py new file mode 100644 index 00000000..5291ba72 --- /dev/null +++ b/jules-scratch/verification/verify_navbar.py @@ -0,0 +1,51 @@ +import re +from playwright.sync_api import sync_playwright, Page, expect + +def run(playwright): + browser = playwright.chromium.launch(headless=True) + page = browser.new_page() + + try: + # Navigate to the local development server + page.goto("http://localhost:5173") + + # Wait for the page to load by waiting for a known element + page.wait_for_selector("section#about") + + # --- Verify 'About' section --- + # Scroll to the 'about' section to trigger the highlighter + page.evaluate("document.querySelector('section#about').scrollIntoView()") + # Wait for scroll and potential UI update + page.wait_for_timeout(500) + # Check if the 'About' link is active + about_link = page.locator('//ul[contains(@class, "sm:flex")]//a[text()="About"]/parent::li') + expect(about_link).to_have_class(re.compile(r"\btext-white\b")) + page.screenshot(path="jules-scratch/verification/verify-about.png") + + # --- Verify 'Work' section --- + page.evaluate("document.querySelector('section#work').scrollIntoView()") + page.wait_for_timeout(500) + work_link = page.locator('//ul[contains(@class, "sm:flex")]//a[text()="Work"]/parent::li') + expect(work_link).to_have_class(re.compile(r"\btext-white\b")) + page.screenshot(path="jules-scratch/verification/verify-work.png") + + # --- Verify 'Contact' section --- + page.evaluate("document.querySelector('section#contact').scrollIntoView()") + page.wait_for_timeout(500) + contact_link = page.locator('//ul[contains(@class, "sm:flex")]//a[text()="Contact"]/parent::li') + expect(contact_link).to_have_class(re.compile(r"\btext-white\b")) + page.screenshot(path="jules-scratch/verification/verify-contact.png") + + # --- Verify scrolling to top --- + page.evaluate("window.scrollTo(0, 0)") + page.wait_for_timeout(500) + # Check that all links are inactive (i.e., have text-secondary class) + inactive_links = page.locator('//ul[contains(@class, "sm:flex")]//li[contains(@class, "text-secondary")]') + expect(inactive_links).to_have_count(3) + page.screenshot(path="jules-scratch/verification/verify-top.png") + + finally: + browser.close() + +with sync_playwright() as playwright: + run(playwright) \ No newline at end of file diff --git a/src/components/layout/Navbar.tsx b/src/components/layout/Navbar.tsx index 11207693..f5c592b6 100644 --- a/src/components/layout/Navbar.tsx +++ b/src/components/layout/Navbar.tsx @@ -14,18 +14,10 @@ const Navbar = () => { useEffect(() => { const handleScroll = () => { const scrollTop = window.scrollY; - if (scrollTop > 100) { - setScrolled(true); - } else { - setScrolled(false); - setActive(""); - } - }; - - window.addEventListener("scroll", handleScroll); + setScrolled(scrollTop > 100); - const navbarHighlighter = () => { const sections = document.querySelectorAll("section[id]"); + let activeSectionId: string | null = null; sections.forEach((current) => { const sectionId = current.getAttribute("id"); @@ -35,16 +27,17 @@ const Navbar = () => { current.getBoundingClientRect().top - sectionHeight * 0.2; if (sectionTop < 0 && sectionTop + sectionHeight > 0) { - setActive(sectionId); + activeSectionId = sectionId; } }); + + setActive(activeSectionId || ""); }; - window.addEventListener("scroll", navbarHighlighter); + window.addEventListener("scroll", handleScroll); return () => { window.removeEventListener("scroll", handleScroll); - window.removeEventListener("scroll", navbarHighlighter); }; }, []);