mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 21:04:14 +00:00
70f2abb181
## Description: Update UI check https://homepageupdate.openfront.dev/ Improved mobile UI (now fills whole screen for all modals) e.g.: <img width="432" height="852" alt="image" src="https://github.com/user-attachments/assets/56de40af-4137-4c57-96b7-3910c9a665b8" /> Converted PublicLobby to be "GameModeSelector" to get a nicer 4x4 grid div, where <GameModeSelector> now handles all the username validation now (removed redundant code from modals such as matchmaking) also fixed a bug where someone could have "[XX] X" as thier username (when the minimum should be 3 chars for their name) Now visually displays the 3 lobbies ffa/team/special (which is a continuation from the work done in: #3196 ) <img width="818" height="563" alt="image" src="https://github.com/user-attachments/assets/a15cd31b-6061-4fb8-83ee-ffde6225cfa7" /> updated the background: <img width="1919" height="807" alt="image" src="https://github.com/user-attachments/assets/358a7434-51b8-4540-baf2-d1be05053c44" /> slightly updated the glassy-look to be less glassy: <img width="825" height="729" alt="image" src="https://github.com/user-attachments/assets/1801871b-bbf8-43db-ac53-489337ae80a5" /> ## 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: w.o.n
138 lines
4.4 KiB
TypeScript
138 lines
4.4 KiB
TypeScript
import { html } from "lit";
|
|
import { customElement, query, state } from "lit/decorators.js";
|
|
import Countries from "resources/countries.json" with { type: "json" };
|
|
import { translateText } from "./Utils";
|
|
import { BaseModal } from "./components/BaseModal";
|
|
import { modalHeader } from "./components/ui/ModalHeader";
|
|
|
|
@customElement("flag-input-modal")
|
|
export class FlagInputModal extends BaseModal {
|
|
@query("#flag-input-modal") private modalRef!: HTMLElement;
|
|
|
|
@state() private search = "";
|
|
public returnTo = "";
|
|
|
|
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
super.updated(changedProperties);
|
|
}
|
|
|
|
render() {
|
|
const content = html`
|
|
<div class="${this.modalContainerClass}">
|
|
<div
|
|
class="relative flex flex-col border-b border-white/10 pb-4 shrink-0"
|
|
>
|
|
${modalHeader({
|
|
title: translateText("flag_input.title"),
|
|
onBack: () => this.close(),
|
|
ariaLabel: translateText("common.back"),
|
|
})}
|
|
|
|
<div class="md:flex items-center gap-2 justify-center mt-4">
|
|
<input
|
|
class="h-12 w-full max-w-md border border-white/10 bg-black/60
|
|
rounded-xl shadow-inner text-xl text-center focus:outline-none
|
|
focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500 text-white placeholder-white/30 transition-all"
|
|
type="text"
|
|
placeholder=${translateText("flag_input.search_flag")}
|
|
@change=${this.handleSearch}
|
|
@keyup=${this.handleSearch}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
class="flex-1 overflow-y-auto px-6 pb-6 scrollbar-thin scrollbar-thumb-white/20 scrollbar-track-transparent mr-1"
|
|
>
|
|
<div class="pt-2 flex flex-wrap justify-center gap-4 min-h-min">
|
|
${Countries.filter(
|
|
(country) =>
|
|
!country.restricted && this.includedInSearch(country),
|
|
).map(
|
|
(country) => html`
|
|
<button
|
|
@click=${() => {
|
|
this.setFlag(country.code);
|
|
this.close();
|
|
}}
|
|
class="group relative flex flex-col items-center gap-2 p-3 rounded-xl border border-white/5 bg-white/5 hover:bg-white/10 hover:border-white/20 transition-all cursor-pointer
|
|
w-[100px] sm:w-[120px]"
|
|
>
|
|
<img
|
|
class="w-full h-auto rounded shadow-sm group-hover:scale-105 transition-transform duration-200"
|
|
src="/flags/${country.code}.svg"
|
|
loading="lazy"
|
|
@error=${(e: Event) => {
|
|
const img = e.currentTarget as HTMLImageElement;
|
|
const fallback = "/flags/xx.svg";
|
|
if (img.src && !img.src.endsWith(fallback)) {
|
|
img.src = fallback;
|
|
}
|
|
}}
|
|
/>
|
|
<span
|
|
class="text-xs font-bold text-gray-300 group-hover:text-white text-center leading-tight w-full whitespace-normal break-words"
|
|
>${country.name}</span
|
|
>
|
|
</button>
|
|
`,
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
if (this.inline) {
|
|
return content;
|
|
}
|
|
|
|
return html`
|
|
<o-modal
|
|
id="flag-input-modal"
|
|
title=${translateText("flag_input.title")}
|
|
?inline=${this.inline}
|
|
hideHeader
|
|
hideCloseButton
|
|
>
|
|
${content}
|
|
</o-modal>
|
|
`;
|
|
}
|
|
|
|
private includedInSearch(country: { name: string; code: string }): boolean {
|
|
return (
|
|
country.name.toLowerCase().includes(this.search.toLowerCase()) ||
|
|
country.code.toLowerCase().includes(this.search.toLowerCase())
|
|
);
|
|
}
|
|
|
|
private handleSearch(event: Event) {
|
|
this.search = (event.target as HTMLInputElement).value;
|
|
}
|
|
|
|
private setFlag(flag: string) {
|
|
localStorage.setItem("flag", flag);
|
|
this.dispatchEvent(
|
|
new CustomEvent("flag-change", {
|
|
detail: { flag },
|
|
bubbles: true,
|
|
composed: true,
|
|
}),
|
|
);
|
|
}
|
|
|
|
protected onOpen(): void {
|
|
// No custom logic needed
|
|
}
|
|
|
|
protected onClose(): void {
|
|
if (this.returnTo) {
|
|
const returnEl = document.querySelector(this.returnTo) as any;
|
|
if (returnEl?.open) {
|
|
returnEl.open();
|
|
}
|
|
this.returnTo = "";
|
|
}
|
|
}
|
|
}
|