Skip to content

Commit

Permalink
fix(theme): fix theme button
Browse files Browse the repository at this point in the history
Signed-off-by: loongtao.zhang <loongtao.zhang@outlook.com>
  • Loading branch information
cathaysia committed Dec 8, 2024
1 parent 3a4b58b commit f552f9e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions theme/layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</head>

<body class="article antialiased text-slate-500 dark:text-slate-400 bg-white dark:bg-slate-900 font-serif">
<script type="module" src="@/main.jsx"></script>
<script type="module" src="../src/main.jsx"></script>
<nav class="flex px-5 py-3 text-gray-700 border border-gray-200 rounded-none bg-gray-50 dark:bg-gray-800 dark:border-gray-700 fixed w-full z-50 justify-between"
aria-label="Breadcrumb">
<ol class="inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse">
Expand Down Expand Up @@ -84,7 +84,7 @@ <h1 class="mt-16">{{ title }}</h1>
</div>
</div>
{% endif %}
<script type="module" src="@/tail.jsx"></script>
<script type="module" src="../src/tail.jsx"></script>
</body>

</html>
23 changes: 19 additions & 4 deletions theme/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions theme/src/tail.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hljs from "highlight.js";

import { Moon, Sun } from "lucide-react";
import React from "react";
import React, { useEffect, useState } from "react";
import reactDom from "react-dom/client";

if (!hljs.initHighlighting.called) {
Expand All @@ -22,6 +22,7 @@ function ThemeButton() {
"dark",
localStorage.theme === "dark",
);
const [isDark, setIsdark] = useState(localStorage.them === "dark");

return (
<div
Expand All @@ -32,9 +33,10 @@ function ThemeButton() {
"dark",
localStorage.theme === "dark",
);
setIsdark(localStorage.theme === "dark");
}}
>
{localStorage.theme === "dark" ? (
{isDark ? (
<Moon className="h-[1.2rem] w-[1.2rem]" />
) : (
<Sun className="h-[1.2rem] w-[1.2rem]" />
Expand Down

0 comments on commit f552f9e

Please sign in to comment.