Skip to content

Commit 135c0a8

Browse files
committed
No href="#" / redirect ?today to today's game / color-scheme: dark
1 parent 05ff73d commit 135c0a8

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/App.css

+7-2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ table.Game-rows > tbody {
142142
body.dark {
143143
background-color: #404040;
144144
color: #e0e0e0;
145+
color-scheme: dark;
145146
}
146147

147148
body.dark .Game-keyboard-button {
@@ -247,11 +248,15 @@ a:active {
247248
}
248249

249250
.emoji-link {
250-
font-size: 150%;
251+
font-size: 24px;
251252
text-decoration: none;
253+
background: none;
254+
border: none;
255+
padding: 0;
256+
cursor: pointer;
252257
}
253258

254-
.top-right a + a {
259+
.top-right > * + * {
255260
margin-inline-start: 8px;
256261
}
257262

src/App.tsx

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "./App.css";
2-
import { maxGuesses, seed } from "./util";
2+
import { maxGuesses, seed, urlParam } from "./util";
33
import Game from "./Game";
44
import { useEffect, useState } from "react";
55
import { About } from "./About";
@@ -26,6 +26,8 @@ function useSetting<T>(
2626
return [current, setSetting];
2727
}
2828

29+
const todaySeed = new Date().toISOString().replace(/-/g, "").slice(0, 8);
30+
2931
function App() {
3032
type Page = "game" | "about" | "settings";
3133
const [page, setPage] = useState<Page>("game");
@@ -43,22 +45,24 @@ function App() {
4345

4446
useEffect(() => {
4547
document.body.className = dark ? "dark" : "";
48+
if (urlParam("today") !== null || urlParam("todas") !== null) {
49+
document.location = "?seed=" + todaySeed;
50+
}
4651
setTimeout(() => {
4752
// Avoid transition on page load
4853
document.body.style.transition = "0.3s background-color ease-out";
4954
}, 1);
5055
}, [dark]);
5156

5257
const link = (emoji: string, label: string, page: Page) => (
53-
<a
58+
<button
5459
className="emoji-link"
55-
href="#"
5660
onClick={() => setPage(page)}
5761
title={label}
5862
aria-label={label}
5963
>
6064
{emoji}
61-
</a>
65+
</button>
6266
);
6367

6468
return (
@@ -92,15 +96,7 @@ function App() {
9296
visibility: page === "game" ? "visible" : "hidden",
9397
}}
9498
>
95-
<a
96-
href="#"
97-
onClick={() =>
98-
(document.location = seed
99-
? "?"
100-
: "?seed=" +
101-
new Date().toISOString().replace(/-/g, "").slice(0, 8))
102-
}
103-
>
99+
<a href={seed ? "?random" : "?seed=" + todaySeed}>
104100
{seed ? "Random" : "Today's"}
105101
</a>
106102
</div>

0 commit comments

Comments
 (0)