mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:40:46 +00:00
999fd9157c
## Description: Improved dark mode styling for #1681 Old: <img width="536" height="565" alt="image" src="https://github.com/user-attachments/assets/8b7b5cc5-aa74-4e9b-a814-635c4373d5ab" /> New Look: <img width="766" height="925" alt="image" src="https://github.com/user-attachments/assets/acd00f2b-7248-4b63-b5c4-a345195d4414" /> ## 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 - [x] I have read and accepted the CLA agreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: DISCORD_USERNAME totalfailure
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { LitElement, html } from "lit";
|
|
import { customElement, property, state } from "lit/decorators.js";
|
|
import megaphone from "../../../resources/images/Megaphone.svg";
|
|
import version from "../../../resources/version.txt";
|
|
import { NewsModal } from "../NewsModal";
|
|
import { translateText } from "../Utils";
|
|
|
|
@customElement("news-button")
|
|
export class NewsButton extends LitElement {
|
|
@property({ type: Boolean }) hidden = false;
|
|
@state() private isActive = false;
|
|
|
|
connectedCallback() {
|
|
super.connectedCallback();
|
|
this.checkForNewVersion();
|
|
}
|
|
|
|
private checkForNewVersion() {
|
|
try {
|
|
const lastSeenVersion = localStorage.getItem("version");
|
|
this.isActive = lastSeenVersion !== version;
|
|
} catch (error) {
|
|
// Fallback to NOT showing notification if localStorage fails
|
|
this.isActive = false;
|
|
}
|
|
}
|
|
|
|
private handleClick() {
|
|
localStorage.setItem("version", version);
|
|
this.isActive = false;
|
|
|
|
const newsModal = document.querySelector("news-modal") as NewsModal;
|
|
if (newsModal) {
|
|
newsModal.open();
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return html`
|
|
<div
|
|
class="flex relative ${this.hidden ? "parent-hidden" : ""} ${this
|
|
.isActive
|
|
? "active"
|
|
: ""}"
|
|
>
|
|
<button
|
|
class="border p-[4px] rounded-lg flex cursor-pointer border-black/30 dark:border-gray-300/60 bg-white/70 dark:bg-[rgba(55,65,81,0.7)]"
|
|
@click=${this.handleClick}
|
|
>
|
|
<img
|
|
class="size-[48px] dark:invert"
|
|
src="${megaphone}"
|
|
alt=${translateText("news.title")}
|
|
/>
|
|
</button>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
createRenderRoot() {
|
|
return this;
|
|
}
|
|
}
|