Skip to content

Commit 75ca7b1

Browse files
feat: improve emoji panel UI and UX (openfrontio#2383)
Added some basic fixes: - Add backdrop overlay with outside-click-to-close - Reduce emoji button sizes to fit all emojis without scrolling - Update styling to match player info panel theme ## Description: I updated the emoji panel such as reducing the size so it fits on the screen without scrolling for emojis, and ability to close the panel by clicking outside of it. Previously you couldn't close the panel by clicking outside of it, and this was inconsistent with the rest of the UI. I also updated the styling to match the panel before that (the player info panel). ## Please complete the following: - [x] I have added screenshots for all UI updates - [ ] I process any text displayed to the user through translateText() and I've added it to the en.json file - [ ] 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: insane.p <img width="1237" height="874" alt="image" src="https://github.com/user-attachments/assets/5c0bd229-0f9b-489d-bc34-a4a70021b78d" /> --------- Co-authored-by: Evan <evanpelle@gmail.com>
1 parent 25ea111 commit 75ca7b1

1 file changed

Lines changed: 51 additions & 34 deletions

File tree

src/client/graphics/layers/EmojiTable.ts

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,67 @@ export class EmojiTable extends LitElement {
5757

5858
private onEmojiClicked: (emoji: string) => void = () => {};
5959

60+
private handleBackdropClick = (e: MouseEvent) => {
61+
const panelContent = this.querySelector(
62+
'div[class*="bg-zinc-900"]',
63+
) as HTMLElement;
64+
if (panelContent && !panelContent.contains(e.target as Node)) {
65+
this.hideTable();
66+
}
67+
};
68+
6069
render() {
6170
if (!this.isVisible) {
6271
return null;
6372
}
6473

6574
return html`
6675
<div
67-
class="bg-slate-800 max-w-[95vw] max-h-[95vh] pt-[15px] pb-[15px] fixed flex flex-col -translate-x-1/2 -translate-y-1/2
68-
items-center rounded-[10px] z-[9999] top-[50%] left-[50%] justify-center"
69-
@contextmenu=${(e: MouseEvent) => e.preventDefault()}
70-
@wheel=${(e: WheelEvent) => e.stopPropagation()}
76+
class="fixed inset-0 bg-black/15 backdrop-brightness-110 flex items-center justify-center z-[9998]"
77+
@click=${this.handleBackdropClick}
7178
>
72-
<!-- Close button -->
73-
<button
74-
class="absolute -top-2 -right-2 w-6 h-6 flex items-center justify-center
75-
bg-red-500 hover:bg-red-900 text-white rounded-full
76-
text-sm font-bold transition-colors"
77-
@click=${this.hideTable}
78-
>
79-
80-
</button>
8179
<div
82-
class="flex flex-col overflow-y-auto"
83-
style="scrollbar-gutter: stable both-edges;"
80+
class="bg-zinc-900/95 p-[6px] flex items-center justify-center rounded-[10px] z-[9999] relative shadow-2xl shadow-black/50 ring-1 ring-white/5"
81+
style="
82+
width: min(410px, calc(100vw - 60px), calc((100vh - 40px) * 215 / 449));
83+
aspect-ratio: 215 / 449;
84+
container-type: size;
85+
"
86+
@contextmenu=${(e: MouseEvent) => e.preventDefault()}
87+
@wheel=${(e: WheelEvent) => e.stopPropagation()}
88+
@click=${(e: MouseEvent) => e.stopPropagation()}
8489
>
85-
${emojiTable.map(
86-
(row) => html`
87-
<div class="w-full justify-center flex">
88-
${row.map(
89-
(emoji) => html`
90-
<button
91-
class="flex transition-transform duration-300 ease justify-center items-center cursor-pointer
92-
border border-solid border-slate-500 rounded-[12px] bg-slate-700 hover:bg-slate-600 active:bg-slate-500
93-
md:m-[8px] md:text-[60px] md:w-[80px] md:h-[80px] hover:scale-[1.1] active:scale-[0.95]
94-
sm:w-[60px] sm:h-[60px] sm:text-[32px] sm:m-[5px] text-[28px] w-[50px] h-[50px] m-[3px]"
95-
@click=${() => this.onEmojiClicked(emoji)}
96-
>
97-
${emoji}
98-
</button>
99-
`,
100-
)}
101-
</div>
102-
`,
103-
)}
90+
<!-- Close button -->
91+
<button
92+
class="absolute -top-3 -right-3 w-7 h-7 flex items-center justify-center
93+
bg-zinc-700 hover:bg-red-500 text-white rounded-full shadow transition-colors z-[10000]"
94+
@click=${this.hideTable}
95+
>
96+
97+
</button>
98+
<div
99+
class="flex flex-col"
100+
style="transform: scale(calc(100cqw / 215px)); transform-origin: center;"
101+
>
102+
${emojiTable.map(
103+
(row) => html`
104+
<div class="flex justify-center">
105+
${row.map(
106+
(emoji) => html`
107+
<button
108+
class="flex transition-transform duration-300 ease justify-center items-center cursor-pointer
109+
border border-solid border-zinc-600 rounded-[8px] bg-zinc-800 hover:bg-zinc-700 active:bg-zinc-600
110+
m-[2px] text-[25px] w-[35px] h-[35px] hover:scale-[1.1] active:scale-[0.95]"
111+
@click=${() => this.onEmojiClicked(emoji)}
112+
>
113+
${emoji}
114+
</button>
115+
`,
116+
)}
117+
</div>
118+
`,
119+
)}
120+
</div>
104121
</div>
105122
</div>
106123
`;

0 commit comments

Comments
 (0)