Merge v25 into main

This commit is contained in:
Scott Anderson
2025-08-06 22:43:14 -04:00
18 changed files with 211 additions and 25 deletions
+2 -3
View File
@@ -41,9 +41,8 @@ export async function handlePurchase(priceId: string) {
},
body: JSON.stringify({
priceId: priceId,
successUrl: `${window.location.href}purchase-success`,
cancelUrl: `${window.location.href}purchase-cancel`,
successUrl: `${window.location.origin}#purchase-completed=true`,
cancelUrl: `${window.location.origin}#purchase-completed=false`,
}),
},
);
+15
View File
@@ -11,6 +11,21 @@ export class DarkModeButton extends LitElement {
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();
+1 -1
View File
@@ -47,7 +47,7 @@ export class HostLobbyModal extends LitElement {
@state() private copySuccess = false;
@state() private clients: ClientInfo[] = [];
@state() private useRandomMap: boolean = false;
@state() private disabledUnits: UnitType[] = [UnitType.Factory];
@state() private disabledUnits: UnitType[] = [];
@state() private lobbyCreatorClientID: string = "";
@state() private lobbyIdVisible: boolean = true;
+18
View File
@@ -423,8 +423,25 @@ class Client {
private handleHash() {
const { hash } = window.location;
const alertAndStrip = (message: string) => {
alert(message);
history.replaceState(
null,
"",
window.location.pathname + window.location.search,
);
};
if (hash.startsWith("#")) {
const params = new URLSearchParams(hash.slice(1));
if (params.get("purchase-completed") === "true") {
alertAndStrip("purchase succeeded");
return;
} else if (params.get("purchase-completed") === "false") {
alertAndStrip("purchase failed");
return;
}
const lobbyId = params.get("join");
if (lobbyId && ID.safeParse(lobbyId).success) {
this.joinModal.open(lobbyId);
@@ -475,6 +492,7 @@ class Client {
"territory-patterns-modal",
"language-modal",
"news-modal",
"flag-input-modal",
].forEach((tag) => {
const modal = document.querySelector(tag) as HTMLElement & {
close?: () => void;
+1 -1
View File
@@ -43,7 +43,7 @@ export class SinglePlayerModal extends LitElement {
@state() private gameMode: GameMode = GameMode.FFA;
@state() private teamCount: TeamCountConfig = 2;
@state() private disabledUnits: UnitType[] = [UnitType.Factory];
@state() private disabledUnits: UnitType[] = [];
private userSettings: UserSettings = new UserSettings();
+8
View File
@@ -95,6 +95,14 @@ export class UserSettingModal extends LitElement {
document.documentElement.classList.remove("dark");
}
this.dispatchEvent(
new CustomEvent("dark-mode-changed", {
detail: { darkMode: enabled },
bubbles: true,
composed: true,
}),
);
console.log("🌙 Dark Mode:", enabled ? "ON" : "OFF");
}
@@ -26,7 +26,6 @@ export class OModal extends LitElement {
}
.c-modal__wrapper {
background: #23232382;
border-radius: 8px;
min-width: 340px;
max-width: 860px;
@@ -62,6 +61,7 @@ export class OModal extends LitElement {
}
.c-modal__content {
background: #23232382;
position: relative;
color: #fff;
padding: 1.4rem;
-4
View File
@@ -442,10 +442,6 @@
document.documentElement.classList.remove("preload");
});
});
window.addEventListener("beforeunload", function (e) {
e.preventDefault();
e.returnValue = "Are you sure you want to leave?";
});
</script>
<!-- Playwire ads -->