mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 21:14:14 +00:00
35ad6f3abf
## Description: When purchasing an item, user will be logged in as their email automatically. * Users can be logged in either via discord or email (the top right button has an email or discord icon depending on which is logged in * Created AccountModal to show current login and has option to log in via Discord or send recovery email * Created TokenLoginModal which is triggered during account recovery or after purchase * Update DiscordUserSchema to * Removed choco pattern key listeners, they were causing NPEs when empty input was provided on forms <img width="408" height="479" alt="Screenshot 2025-08-29 at 5 35 31 PM" src="https://github.com/user-attachments/assets/a2be5556-b534-4279-931b-799d8ece122c" /> support email or discord identity <img width="801" height="351" alt="Screenshot 2025-08-29 at 5 38 59 PM" src="https://github.com/user-attachments/assets/9d18ef8f-a6f8-4c22-b583-c31d9b176467" /> <img width="97" height="83" alt="Screenshot 2025-08-29 at 5 39 51 PM" src="https://github.com/user-attachments/assets/994d7ade-fa02-4adb-a6f8-e929af4089b2" /> <img width="102" height="83" alt="Screenshot 2025-08-29 at 5 40 03 PM" src="https://github.com/user-attachments/assets/f829dd49-996b-479d-9b75-d81092e31da4" /> <img width="59" height="43" alt="Screenshot 2025-08-29 at 5 40 19 PM" src="https://github.com/user-attachments/assets/aacf39e7-2528-463b-95cb-a58bc8c2194b" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { LitElement, html } from "lit";
|
|
import { customElement, state } from "lit/decorators.js";
|
|
import { UserSettings } from "../core/game/UserSettings";
|
|
|
|
@customElement("dark-mode-button")
|
|
export class DarkModeButton extends LitElement {
|
|
private userSettings: UserSettings = new UserSettings();
|
|
@state() private darkMode: boolean = this.userSettings.darkMode();
|
|
|
|
createRenderRoot() {
|
|
return this;
|
|
}
|
|
|
|
connectedCallback() {
|
|
super.connectedCallback();
|
|
window.addEventListener("dark-mode-changed", this.handleDarkModeChanged);
|
|
}
|
|
|
|
disconnectedCallback() {
|
|
super.disconnectedCallback();
|
|
window.removeEventListener("dark-mode-changed", this.handleDarkModeChanged);
|
|
}
|
|
|
|
private handleDarkModeChanged = (e: Event) => {
|
|
const event = e as CustomEvent<{ darkMode: boolean }>;
|
|
this.darkMode = event.detail.darkMode;
|
|
};
|
|
|
|
toggleDarkMode() {
|
|
this.userSettings.toggleDarkMode();
|
|
this.darkMode = this.userSettings.darkMode();
|
|
}
|
|
|
|
render() {
|
|
return html`
|
|
<button
|
|
title="Toggle Dark Mode"
|
|
class="absolute top-0 left-0 md:top-[10px] md:left-[10px] border-none bg-none cursor-pointer text-2xl"
|
|
@click=${() => this.toggleDarkMode()}
|
|
>
|
|
${this.darkMode ? "☀️" : "🌙"}
|
|
</button>
|
|
`;
|
|
}
|
|
}
|