diff --git a/components/DarkModeToggle.tsx b/components/DarkModeToggle.tsx new file mode 100644 index 00000000..6a2caad9 --- /dev/null +++ b/components/DarkModeToggle.tsx @@ -0,0 +1,32 @@ +// components/DarkModeToggle.tsx +import { useEffect, useState } from "react"; + +export default function DarkModeToggle() { + const [dark, setDark] = useState(false); + + useEffect(() => { + const isDark = localStorage.theme === "dark"; + setDark(isDark); + document.documentElement.classList.toggle("dark", isDark); + }, []); + + const toggleDark = () => { + const newDark = !dark; + setDark(newDark); + document.documentElement.classList.toggle("dark", newDark); + localStorage.theme = newDark ? "dark" : "light"; + }; + + return ( + + ); +} diff --git a/components/header.tsx b/components/header.tsx index 40855be4..5359b747 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -2,8 +2,10 @@ import Image from "next/image"; import Link from "next/link"; import { useEffect, useState } from "react"; -import sideBySideSvg from "../public/images/sidebyside-transparent.svg" +import sideBySideSvg from "../public/images/sidebyside-transparent.svg"; import { SpringValue, animated } from "@react-spring/web"; +import DarkModeToggle from "./DarkModeToggle"; + const menuItems = [ { text: "Docs", link: "https://keploy.io/docs" }, { text: "Tech Blogs", link: "/technology" }, @@ -11,17 +13,17 @@ const menuItems = [ ]; const formatStars = (num: number) => - Intl.NumberFormat('en-US', { - notation: "compact", - maximumFractionDigits: 1, - }).format(num); + Intl.NumberFormat("en-US", { + notation: "compact", + maximumFractionDigits: 1, + }).format(num); const WaitListBtn = ({ mobile }: { mobile?: Boolean }) => { if (mobile) { return ( Sign In { return ( Sign In @@ -97,7 +99,7 @@ const GithubBtn = () => { const MenuBtn = () => { return ( @@ -114,97 +116,105 @@ export default function Header({ readProgress?: SpringValue; }) { const [toggleMenu, setToggleMenu] = useState(false); + const [isScrolled, setIsScrolled] = useState(false); const toggleMenuHandler = () => { setToggleMenu((prev) => !prev); }; + useEffect(() => { + const handleScroll = () => { + setIsScrolled(window.scrollY > 10); + }; + window.addEventListener("scroll", handleScroll); + return () => window.removeEventListener("scroll", handleScroll); + }, []); + return ( -
-
-
-
-
- - Keploy Logo - -
- - -
- - -
-
- -
- {toggleMenu ? ( - - ) : null} -
-
+
+
+
+
+ + Keploy Logo +
-
- {readProgress && ( -
- v + "%"), - }} + + + +
+ + + +
+ +
+
- )} -
-
+
+
+ + {toggleMenu && ( + + )} + + {readProgress && ( +
+ v + "%"), + }} + > +
+
+ )} + ); } + diff --git a/components/hero-post.tsx b/components/hero-post.tsx index e9bb1388..0799dac4 100644 --- a/components/hero-post.tsx +++ b/components/hero-post.tsx @@ -26,7 +26,7 @@ export default function HeroPost({ return (
-
+
{/* Banner */}
Latest Blog diff --git a/components/layout.tsx b/components/layout.tsx index 1b9538df..701c6fb1 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -1,10 +1,18 @@ import { Post } from "../types/post"; -import Alert from './alert' -import Footer from './footer' -import Meta from './meta' +import Alert from './alert'; +import Footer from './footer'; +import Meta from './meta'; import Script from 'next/script'; import { motion } from "framer-motion"; -export default function Layout({ preview, children, featuredImage, Title, Description }:{ +import Header from './header'; + +export default function Layout({ + preview, + children, + featuredImage, + Title, + Description, +}: { preview: any; Description: any; featuredImage: Post["featuredImage"]["node"]["sourceUrl"]; @@ -23,10 +31,12 @@ export default function Layout({ preview, children, featuredImage, Title, Descri stiffness: 260, damping: 20, }} - className="min-h-screen" + className="min-h-screen bg-white text-black dark:bg-gray-900 dark:text-white transition-colors duration-500" > - {/* */} -
{children}
+
+
+ {children} +