Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export function Header() {
);

const rightContent = (
<nav className="flex items-center gap-2">
<div className="flex items-center gap-4">
<nav className="flex items-center gap-1 justify-center">
<div className="flex items-center gap-3">
<Link href="/blog">
<Button variant="text" className="text-sm p-0">
Blog
Expand Down
30 changes: 20 additions & 10 deletions apps/web/src/components/theme-toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
"use client";

import { Button } from "./ui/button";
import { Sun, Moon } from "lucide-react";
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


interface ThemeToggleProps {
className?: string;
}

export function ThemeToggle({ className }: ThemeToggleProps) {
const { theme, setTheme } = useTheme();
const [isClient, setIsClient] = useState(false);

useEffect(() => {
setIsClient(true)
}, []) // this will see that the client side is rendered or not.

// if the client side is rendered then only render the button
return (
<Button
size="icon"
variant="text"
className="h-7"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
>
<Sun className="!size-[1.1rem]" />
<span className="sr-only">{theme === "dark" ? "Light" : "Dark"}</span>
</Button>
<>
{
isClient && <Button
size="icon"
variant="text"
className="h-7"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
>
{theme === "dark" ? <Sun className="!size-[1.1rem]" /> : <Moon className="!size-[1.1rem]" />}
<span className="sr-only">{theme === "dark" ? "Light" : "Dark"}</span>
</Button>
}
</>
);
}