Add Game Bar action to toggle renderer's visibility

This commit is contained in:
redphx
2024-10-13 17:05:27 +07:00
parent c129feaf2d
commit d012d96675
8 changed files with 126 additions and 9 deletions

View File

@@ -0,0 +1,47 @@
import { BxEvent } from "@utils/bx-event";
import { BxIcon } from "@utils/bx-icon";
import { createButton, ButtonStyle, CE } from "@utils/html";
import { BaseGameBarAction } from "./action-base";
import { RendererShortcut } from "../shortcuts/shortcut-renderer";
export class RendererAction extends BaseGameBarAction {
$content: HTMLElement;
constructor() {
super();
const onClick = (e: Event) => {
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
this.$content.dataset.enabled = RendererShortcut.toggleVisibility().toString();
};
const $btnDefault = createButton({
style: ButtonStyle.GHOST,
icon: BxIcon.EYE,
onClick: onClick,
});
const $btnActivated = createButton({
style: ButtonStyle.GHOST,
icon: BxIcon.EYE_SLASH,
onClick: onClick,
classes: ['bx-activated'],
});
this.$content = CE('div', {},
$btnDefault,
$btnActivated,
);
this.reset();
}
render(): HTMLElement {
return this.$content;
}
reset(): void {
this.$content.dataset.enabled = 'true';
}
}