No href="#" / redirect ?today to today's game / color-scheme: dark
This commit is contained in:
@@ -142,6 +142,7 @@ table.Game-rows > tbody {
|
|||||||
body.dark {
|
body.dark {
|
||||||
background-color: #404040;
|
background-color: #404040;
|
||||||
color: #e0e0e0;
|
color: #e0e0e0;
|
||||||
|
color-scheme: dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
body.dark .Game-keyboard-button {
|
body.dark .Game-keyboard-button {
|
||||||
@@ -247,11 +248,15 @@ a:active {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.emoji-link {
|
.emoji-link {
|
||||||
font-size: 150%;
|
font-size: 24px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.top-right a + a {
|
.top-right > * + * {
|
||||||
margin-inline-start: 8px;
|
margin-inline-start: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
src/App.tsx
22
src/App.tsx
@@ -1,5 +1,5 @@
|
|||||||
import "./App.css";
|
import "./App.css";
|
||||||
import { maxGuesses, seed } from "./util";
|
import { maxGuesses, seed, urlParam } from "./util";
|
||||||
import Game from "./Game";
|
import Game from "./Game";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { About } from "./About";
|
import { About } from "./About";
|
||||||
@@ -26,6 +26,8 @@ function useSetting<T>(
|
|||||||
return [current, setSetting];
|
return [current, setSetting];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const todaySeed = new Date().toISOString().replace(/-/g, "").slice(0, 8);
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
type Page = "game" | "about" | "settings";
|
type Page = "game" | "about" | "settings";
|
||||||
const [page, setPage] = useState<Page>("game");
|
const [page, setPage] = useState<Page>("game");
|
||||||
@@ -43,6 +45,9 @@ function App() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.body.className = dark ? "dark" : "";
|
document.body.className = dark ? "dark" : "";
|
||||||
|
if (urlParam("today") !== null || urlParam("todas") !== null) {
|
||||||
|
document.location = "?seed=" + todaySeed;
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Avoid transition on page load
|
// Avoid transition on page load
|
||||||
document.body.style.transition = "0.3s background-color ease-out";
|
document.body.style.transition = "0.3s background-color ease-out";
|
||||||
@@ -50,15 +55,14 @@ function App() {
|
|||||||
}, [dark]);
|
}, [dark]);
|
||||||
|
|
||||||
const link = (emoji: string, label: string, page: Page) => (
|
const link = (emoji: string, label: string, page: Page) => (
|
||||||
<a
|
<button
|
||||||
className="emoji-link"
|
className="emoji-link"
|
||||||
href="#"
|
|
||||||
onClick={() => setPage(page)}
|
onClick={() => setPage(page)}
|
||||||
title={label}
|
title={label}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
>
|
>
|
||||||
{emoji}
|
{emoji}
|
||||||
</a>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -92,15 +96,7 @@ function App() {
|
|||||||
visibility: page === "game" ? "visible" : "hidden",
|
visibility: page === "game" ? "visible" : "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<a
|
<a href={seed ? "?random" : "?seed=" + todaySeed}>
|
||||||
href="#"
|
|
||||||
onClick={() =>
|
|
||||||
(document.location = seed
|
|
||||||
? "?"
|
|
||||||
: "?seed=" +
|
|
||||||
new Date().toISOString().replace(/-/g, "").slice(0, 8))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{seed ? "Random" : "Today's"}
|
{seed ? "Random" : "Today's"}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user