Refactor Game Bar actions

This commit is contained in:
redphx
2024-10-13 19:15:29 +07:00
parent f2bc98229f
commit 6d2e04aff1
8 changed files with 90 additions and 84 deletions

View File

@@ -13,24 +13,17 @@ export class MicrophoneAction extends BaseGameBarAction {
constructor() {
super();
const onClick = (e: Event) => {
BxEvent.dispatch(window, BxEvent.GAME_BAR_ACTION_ACTIVATED);
const enabled = MicrophoneShortcut.toggle(false);
this.$content.dataset.activated = enabled.toString();
};
const $btnDefault = createButton({
style: ButtonStyle.GHOST,
icon: BxIcon.MICROPHONE,
onClick: onClick,
onClick: this.onClick.bind(this),
classes: ['bx-activated'],
});
const $btnMuted = createButton({
style: ButtonStyle.GHOST,
icon: BxIcon.MICROPHONE_MUTED,
onClick: onClick,
onClick: this.onClick.bind(this),
});
this.$content = CE('div', {},
@@ -50,6 +43,12 @@ export class MicrophoneAction extends BaseGameBarAction {
});
}
onClick(e: Event) {
super.onClick(e);
const enabled = MicrophoneShortcut.toggle(false);
this.$content.dataset.activated = enabled.toString();
}
render(): HTMLElement {
return this.$content;
}