mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 14:41:35 +00:00
0421c4e958
## Description: 1. Changed default difficulty in singleplayer / host lobby to Easy (to synchronize the settings with the public lobby settings) 2. Switch bot count in singleplayer / host lobby to 100 after selecting "compact map" (to synchronize the settings with the public lobby settings) (and back to 400 after deselcting) 3. Some little padding optimizations, for example for the modal title: <img width="961" height="190" alt="Screenshot 2026-01-14 163837" src="https://github.com/user-attachments/assets/1ecca3e9-8daf-4bed-a75a-c8e840051601" /> 4. Refreshed images for the help page:        ## 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: FloPinguin
109 lines
3.3 KiB
TypeScript
109 lines
3.3 KiB
TypeScript
import { LitElement, html, unsafeCSS } from "lit";
|
|
import { customElement, property, state } from "lit/decorators.js";
|
|
import tailwindStyles from "../../styles.css?inline";
|
|
|
|
@customElement("o-modal")
|
|
export class OModal extends LitElement {
|
|
static styles = [unsafeCSS(tailwindStyles)];
|
|
|
|
@state() public isModalOpen = false;
|
|
|
|
static openCount = 0;
|
|
|
|
@property({ type: Boolean })
|
|
public inline = false;
|
|
|
|
@property({ type: Boolean })
|
|
public alwaysMaximized = false;
|
|
|
|
@property({ type: Boolean })
|
|
public hideCloseButton = false;
|
|
|
|
@property({ type: String })
|
|
public title = "";
|
|
|
|
@property({ type: Boolean })
|
|
public hideHeader = false;
|
|
|
|
public onClose?: () => void;
|
|
|
|
public open() {
|
|
if (!this.isModalOpen) {
|
|
if (!this.inline) {
|
|
OModal.openCount = OModal.openCount + 1;
|
|
if (OModal.openCount === 1) document.body.style.overflow = "hidden";
|
|
}
|
|
this.isModalOpen = true;
|
|
}
|
|
}
|
|
|
|
public close() {
|
|
if (this.isModalOpen) {
|
|
this.isModalOpen = false;
|
|
this.onClose?.();
|
|
if (!this.inline) {
|
|
OModal.openCount = Math.max(0, OModal.openCount - 1);
|
|
if (OModal.openCount === 0) document.body.style.overflow = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
disconnectedCallback() {
|
|
// Ensure global counter is decremented if this modal is removed while open.
|
|
if (this.isModalOpen && !this.inline) {
|
|
OModal.openCount = Math.max(0, OModal.openCount - 1);
|
|
if (OModal.openCount === 0) document.body.style.overflow = "";
|
|
}
|
|
super.disconnectedCallback();
|
|
}
|
|
|
|
render() {
|
|
const backdropClass = this.inline
|
|
? "relative z-10 w-full h-full flex items-stretch bg-transparent"
|
|
: "fixed inset-0 z-[9999] bg-black/70 flex items-center justify-center overflow-hidden";
|
|
|
|
const wrapperClass = this.inline
|
|
? "relative flex flex-col w-full h-full m-0 max-w-full max-h-none shadow-none"
|
|
: `relative flex flex-col w-[90%] min-w-[400px] max-w-[900px] m-8 rounded-lg shadow-[0_20px_60px_rgba(0,0,0,0.8)] max-h-[calc(100vh-4rem)] ${
|
|
this.alwaysMaximized ? "h-auto" : ""
|
|
}`;
|
|
|
|
return html`
|
|
${this.isModalOpen
|
|
? html`
|
|
<aside
|
|
class="${backdropClass}"
|
|
@click=${this.inline ? null : () => this.close()}
|
|
>
|
|
<div
|
|
@click=${(e: Event) => e.stopPropagation()}
|
|
class="${wrapperClass}"
|
|
>
|
|
${this.inline || this.hideCloseButton
|
|
? html``
|
|
: html`<div
|
|
class="absolute top-5 right-5 z-10 text-white cursor-pointer"
|
|
@click=${() => this.close()}
|
|
>
|
|
✕
|
|
</div>`}
|
|
${!this.hideHeader && this.title
|
|
? html`<div
|
|
class="px-[1.4rem] py-[1rem] pt-0 text-2xl font-bold text-white"
|
|
>
|
|
${this.title}
|
|
</div>`
|
|
: html``}
|
|
<section
|
|
class="relative flex-1 min-h-0 p-[1.4rem] text-white bg-[#23232382] backdrop-blur-md rounded-lg overflow-y-auto"
|
|
>
|
|
<slot></slot>
|
|
</section>
|
|
</div>
|
|
</aside>
|
|
`
|
|
: html``}
|
|
`;
|
|
}
|
|
}
|