mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-04 22:13:13 +00:00
And enable the import/unambiguous ESLint rule as a check on our
partition between scripts and modules. After this commit, if you add
a new file and get this error:
✖ 1:1 This module could be parsed as a valid script. import/unambiguous
* For a module, add an `import` or `export` declaration to make the
file unambiguously a module (the empty `export {};` declaration
suffices).
* For a script, add the file to the xo overrides section of
package.json that marks it "sourceType": "script", and add a 'use
strict' declaration.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import Tab from './tab';
|
|
|
|
export default class FunctionalTab extends Tab {
|
|
$closeButton: Element;
|
|
template(): string {
|
|
return `<div class="tab functional-tab" data-tab-id="${this.props.tabIndex}">
|
|
<div class="server-tab-badge close-button">
|
|
<i class="material-icons">close</i>
|
|
</div>
|
|
<div class="server-tab">
|
|
<i class="material-icons">${this.props.materialIcon}</i>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
|
|
// TODO: Typescript - This type for props should be TabProps
|
|
constructor(props: any) {
|
|
super(props);
|
|
this.init();
|
|
}
|
|
|
|
init(): void {
|
|
this.$el = this.generateNodeFromTemplate(this.template());
|
|
if (this.props.name !== 'Settings') {
|
|
this.props.$root.append(this.$el);
|
|
this.$closeButton = this.$el.querySelectorAll('.server-tab-badge')[0];
|
|
this.registerListeners();
|
|
}
|
|
}
|
|
|
|
registerListeners(): void {
|
|
super.registerListeners();
|
|
|
|
this.$el.addEventListener('mouseover', () => {
|
|
this.$closeButton.classList.add('active');
|
|
});
|
|
|
|
this.$el.addEventListener('mouseout', () => {
|
|
this.$closeButton.classList.remove('active');
|
|
});
|
|
|
|
this.$closeButton.addEventListener('click', (e: Event) => {
|
|
this.props.onDestroy();
|
|
e.stopPropagation();
|
|
});
|
|
}
|
|
}
|