Skip to content

Commit 44c73b9

Browse files
committed
fix dark mode icon
1 parent 9192e27 commit 44c73b9

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/demo/css/toggle-dark.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ a.darkmode {
1515
0 0 3px rgb(0 0 0 / 12%),
1616
0 1px 2px rgb(0 0 0 / 24%);
1717
transition: 0.2s ease-in box-shadow;
18+
text-decoration: none;
1819
}
1920

2021
a.darkmode:hover {

src/demo/index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function camelToSkewer(string $str): string
2222
function ($matches) {
2323
return "-" . strtolower($matches[0]);
2424
},
25-
$str,
25+
$str
2626
);
2727
}
2828
?>
@@ -46,7 +46,6 @@ function gtag() {
4646
gtag('config', 'G-48CYVH0XEF');
4747
</script>
4848
<title>GitHub Readme Streak Stats Demo</title>
49-
<link href="https://css-gg-cdn.pages.dev/css" rel="stylesheet">
5049
<link rel="stylesheet" href="./css/style.css?v=<?= filemtime("./css/style.css") ?>">
5150
<link rel="stylesheet" href="./css/toggle-dark.css?v=<?= filemtime("./css/toggle-dark.css") ?>">
5251

@@ -281,7 +280,13 @@ function gtag() {
281280
</div>
282281

283282
<a href="javascript:toggleTheme()" class="darkmode" title="toggle dark mode">
284-
<i class="<?php echo $darkmode === "on" ? "gg-sun" : "gg-moon"; ?>"></i>
283+
<span id="darkmode-icon">
284+
<?php if ($darkmode === "on"): ?>
285+
🌞
286+
<?php else: ?>
287+
🌙
288+
<?php endif; ?>
289+
</span>
285290
</a>
286291
</body>
287292

src/demo/js/toggle-dark.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function getCookie(name) {
3939
* Turn on dark mode
4040
*/
4141
function darkmode() {
42-
document.querySelector(".darkmode i").className = "gg-sun";
42+
document.querySelector("#darkmode-icon").innerText = "🌞";
4343
setCookie("darkmode", "on", 9999);
4444
document.body.setAttribute("data-theme", "dark");
4545
}
@@ -48,7 +48,7 @@ function darkmode() {
4848
* Turn on light mode
4949
*/
5050
function lightmode() {
51-
document.querySelector(".darkmode i").className = "gg-moon";
51+
document.querySelector("#darkmode-icon").innerText = "🌙";
5252
setCookie("darkmode", "off", 9999);
5353
document.body.removeAttribute("data-theme");
5454
}

0 commit comments

Comments
 (0)