mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-09 08:25:44 +00:00
52 lines
1.0 KiB
TypeScript
52 lines
1.0 KiB
TypeScript
import type WebView from "./webview";
|
|
|
|
export interface TabProps {
|
|
role: string;
|
|
icon?: string;
|
|
name: string;
|
|
$root: Element;
|
|
onClick: () => void;
|
|
index: number;
|
|
tabIndex: number;
|
|
onHover?: () => void;
|
|
onHoverOut?: () => void;
|
|
webview: WebView;
|
|
materialIcon?: string;
|
|
onDestroy?: () => void;
|
|
}
|
|
|
|
export default class Tab {
|
|
props: TabProps;
|
|
webview: WebView;
|
|
$el: Element;
|
|
constructor(props: TabProps) {
|
|
this.props = props;
|
|
this.webview = this.props.webview;
|
|
}
|
|
|
|
registerListeners(): void {
|
|
this.$el.addEventListener("click", this.props.onClick);
|
|
this.$el.addEventListener("mouseover", this.props.onHover);
|
|
this.$el.addEventListener("mouseout", this.props.onHoverOut);
|
|
}
|
|
|
|
showNetworkError(): void {
|
|
this.webview.forceLoad();
|
|
}
|
|
|
|
activate(): void {
|
|
this.$el.classList.add("active");
|
|
this.webview.load();
|
|
}
|
|
|
|
deactivate(): void {
|
|
this.$el.classList.remove("active");
|
|
this.webview.hide();
|
|
}
|
|
|
|
destroy(): void {
|
|
this.$el.remove();
|
|
this.webview.$el.remove();
|
|
}
|
|
}
|