fix: add theme icon to index page

This commit is contained in:
trafficlunar 2025-01-02 20:59:42 +00:00
parent 8a43d9978b
commit 2df5496b46
2 changed files with 37 additions and 3 deletions

View file

@ -0,0 +1,31 @@
import { useContext } from "react";
import { ThemeContext } from "@/context/Theme";
import { MoonIcon, SunIcon, SunMoonIcon } from "lucide-react";
function ThemeIcon() {
const { theme, setTheme } = useContext(ThemeContext);
const onClick = () => {
const nextTheme = theme === "light" ? "dark" : theme === "dark" ? "system" : "light";
setTheme(nextTheme);
};
const getIcon = () => {
switch (theme) {
case "light":
return <SunIcon size={30} />;
case "dark":
return <MoonIcon size={30} />;
case "system":
return <SunMoonIcon size={30} />;
}
};
return (
<button onClick={onClick} title={theme} className="text-white">
{getIcon()}
</button>
);
}
export default ThemeIcon;

View file

@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
import BlockmaticLogo from "@/assets/blockmatic.svg?react"; import BlockmaticLogo from "@/assets/blockmatic.svg?react";
import GithubIcon from "@/assets/github.svg?react"; import GithubIcon from "@/assets/github.svg?react";
import ThemeIcon from "@/components/home/ThemeIcon";
import AppPreview from "@/components/home/AppPreview"; import AppPreview from "@/components/home/AppPreview";
import ImageComparison from "@/components/home/ImageComparison"; import ImageComparison from "@/components/home/ImageComparison";
@ -15,13 +16,15 @@ function IndexPage() {
<header className="w-full flex justify-evenly p-8"> <header className="w-full flex justify-evenly p-8">
<BlockmaticLogo className="h-16 w-max" fill={"white"} /> <BlockmaticLogo className="h-16 w-max" fill={"white"} />
<div className="flex items-center gap-8"> <div className="flex items-center gap-2">
<Button variant="link" asChild> <Button className="bg-white text-black hover:bg-zinc-50/90 mr-4" asChild>
<Link to={{ pathname: "/app" }}>Go to app</Link> <Link to={{ pathname: "/app" }}>Go to app</Link>
</Button> </Button>
<a href="https://github.com/trafficlunar/blockmatic" className="w-6">
<a href="https://github.com/trafficlunar/blockmatic" className="w-8">
<GithubIcon fill="white" /> <GithubIcon fill="white" />
</a> </a>
<ThemeIcon />
</div> </div>
</header> </header>