Skip to content

Commit e607a9f

Browse files
committed
Fixed "Meet the Execs!" not switching to dark mode
Had to make the header into a component...
1 parent 65ff455 commit e607a9f

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"use client";
2+
import { useEffect, useState } from "react";
3+
4+
export default function ExecsHeader() {
5+
const [isDark, setIsDark] = useState(false);
6+
7+
useEffect(() => {
8+
const saved = localStorage.getItem("darkMode") === "true";
9+
setIsDark(saved);
10+
11+
const onThemeChange = (e: Event) => {
12+
const { isDark } = (e as CustomEvent).detail ?? {};
13+
if (typeof isDark === "boolean") setIsDark(isDark);
14+
};
15+
window.addEventListener("themechange", onThemeChange);
16+
17+
const onStorage = (e: StorageEvent) => {
18+
if (e.key === "darkMode" && e.newValue != null) {
19+
setIsDark(e.newValue === "true");
20+
}
21+
};
22+
window.addEventListener("storage", onStorage);
23+
24+
return () => {
25+
window.removeEventListener("themechange", onThemeChange);
26+
window.removeEventListener("storage", onStorage);
27+
};
28+
}, []);
29+
30+
const textColor = isDark ? "#F4EFFF" : "#5f249f";
31+
32+
return (
33+
<h2
34+
className="mt-22 text-3xl md:text-5xl font-bold font-[Montserrat] mb-3 text-center p-6"
35+
style={{ color: textColor }}
36+
>
37+
Meet the Exec Team!
38+
</h2>
39+
);
40+
}

src/app/(frontend)/page.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Image from "next/image";
22
import { getPayload } from "payload";
33
import React from "react";
4-
import type { Media } from '../../payload-types'; // adjust path to your generated types
4+
import type { Media } from '../../payload-types';
55

66
import HomePageBanner from "./components/HomePageBanner";
77
import ScrollingGallery from "./components/ScrollingGallery";
@@ -13,6 +13,7 @@ import SocialsBar from "./components/SocialsBar";
1313
import AboutUsSection from "./components/AboutUsSection";
1414
import SectionHeader from "./components/SectionHeader";
1515
import SectionDivider from "./components/SectionDivider";
16+
import ExecsHeader from "./components/ExecsHeader";
1617

1718
import config from "@/payload.config";
1819

@@ -73,9 +74,7 @@ export default async function HomePage() {
7374
<AboutUsSection aboutus={aboutus} />
7475

7576
{/*================================MEET THE EXECS================================*/}
76-
<h2 className="mt-22 text-3xl md:text-5xl text-[#5f249f] font-bold font-[Montserrat] mb-3 text-center p-6">
77-
Meet the Exec Team!
78-
</h2>
77+
<ExecsHeader />
7978
<div className="grid grid-cols-2 lg:grid-cols-3 gap-10">
8079
{execs.docs.map((exec) => (
8180
<ExecCard

0 commit comments

Comments
 (0)