added additionalTabClass for Tab Class

This commit is contained in:
Christopher Liedelt 2021-01-20 16:16:44 +01:00
parent 986f762ae1
commit 91a87b7d76
3 changed files with 6 additions and 0 deletions

View file

@ -101,6 +101,7 @@ Add a new tab to the tab group and returns a `Tab` instance.
* `visible` (default: `true`): set this to `false` if you don't want to display the tab once it is loaded. If set to `false` then you will need to call `tab.show()` to display the tab.
* `active` (default: `false`): set this to `true` if you want to activate the tab once it is loaded. Otherwise you will need to call `tab.activate()`.
* `ready`: a callback function to call once the tab is ready. The `Tab` instance is passed as the only parameter.
* `additionalTabClass`: optional css class which is added to a single tab.
#### `tabGroup.getTab(id)`

1
index.d.ts vendored
View file

@ -39,6 +39,7 @@ declare namespace ElectronTabs {
webviewAttributes?: {[key: string]: any};
visible?: boolean;
active?: boolean;
additionalTabClass?: string;
ready?: (tab: Tab) => void;
}

View file

@ -180,6 +180,7 @@ class Tab extends EventEmitter {
this.closable = args.closable === false ? false : true;
this.webviewAttributes = args.webviewAttributes || {};
this.webviewAttributes.src = args.src;
this.additionalTabClass = args.additionalTabClass;
this.tabElements = {};
TabPrivate.initTab.bind(this)();
TabPrivate.initWebview.bind(this)();
@ -375,6 +376,9 @@ const TabPrivate = {
// Create tab element
let tab = this.tab = document.createElement("div");
tab.classList.add(tabClass);
if(this.additionalTabClass) {
tab.classList.add(this.additionalTabClass);
}
for (let el of ["icon", "title", "buttons", "badge"]) {
let span = tab.appendChild(document.createElement("span"));
span.classList.add(`${tabClass}-${el}`);