diff --git a/README.md b/README.md index 67857a1..884aef4 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,10 @@ This project is a typescript library for electron that allows you to configure a fully customizable title bar. -[![LICENSE](https://img.shields.io/github/license/AlexTorresDev/custom-electron-titlebar.svg)](https://github.com/AlexTorresDev/custom-electron-titlebar/blob/master/LICENSE) -[![NPM Version](https://img.shields.io/npm/v/custom-electron-titlebar.svg)](https://npmjs.org/package/custom-electron-titlebar) -[![install size](https://packagephobia.com/badge?p=custom-electron-titlebar)](https://packagephobia.com/result?p=custom-electron-titlebar) +[![CI](https://badgen.net/github/checks/AlexTorresDev/custom-electron-titlebar?label=CI)](https://github.com/AlexTorresDev/custom-electron-titlebar/actions/workflows/build-release.yml) +[![License](https://badgen.net/github/license/AlexTorresDev/custom-electron-titlebar?label=License)](https://github.com/AlexTorresDev/custom-electron-titlebar/blob/master/LICENSE) +[![NPM](https://badgen.net/npm/v/custom-electron-titlebar?label=NPM)](https://npmjs.org/package/custom-electron-titlebar) +[![Install size](https://badgen.net/packagephobia/install/custom-electron-titlebar?label=Install%20size)](https://packagephobia.com/result?p=custom-electron-titlebar) [📄 Visit Documentation](https://cet.alextrs.dev) @@ -72,12 +73,14 @@ window.addEventListener('DOMContentLoaded', () => { To see the options you can include in the Title Bar constructor, such as color of elements, icons, menu position, and much more, and the methods you can use, go to the [wiki](https://github.com/AlexTorresDev/custom-electron-titlebar/wiki) ## 💰 Support -If you want to support my development, you can do so by donating through [Buy me a coffee](https://www.buymeacoffee.com/AlexTorresDev) +If you want to support my development, you can do so by donating through [💖 Sponsor](https://github.com/sponsors/AlexTorresDev) -## 📝 Collaborators +## 📝 Contributors I would like to express my sincere gratitude to all the people who have collaborated in the development and advancement of this project. I appreciate your contributions. +[![](https://contrib.rocks/image?repo=AlexTorresDev/custom-electron-titlebar)](https://github.com/AlexTorresDev/custom-electron-titlebar/graphs/contributors) + ## ✅ License This project is under the [MIT](https://github.com/AlexTorresDev/custom-electron-titlebar/blob/master/LICENSE) license. diff --git a/src/titlebar/index.ts b/src/titlebar/index.ts index 2916ed7..a99d69d 100644 --- a/src/titlebar/index.ts +++ b/src/titlebar/index.ts @@ -68,7 +68,7 @@ export class CustomTitlebar extends ThemeBar { this.currentOptions = { ...this.currentOptions, ...options } - const jWindowIcons = (menuIcons as any)[PlatformToString(platform).toLocaleLowerCase()] + const jWindowIcons = (menuIcons as any)[PlatformToString(platform)?.toLocaleLowerCase()] this.platformIcons = jWindowIcons this.titlebar = $('.cet-titlebar') @@ -182,7 +182,7 @@ export class CustomTitlebar extends ThemeBar { } private setupMenubar() { - ipcRenderer.invoke('request-application-menu').then((menu?: Menu) => this.updateMenu(menu)) + ipcRenderer.invoke('request-application-menu')?.then((menu?: Menu) => this.updateMenu(menu)) const menuPosition = this.currentOptions.menuPosition @@ -221,9 +221,9 @@ export class CustomTitlebar extends ThemeBar { if (isMacintosh || onlyRendererMenuBar) return - this.createControlButton(this.controls.minimize, this.platformIcons.minimize, tooltips.minimize!, this.currentOptions.minimizable) - this.createControlButton(this.controls.maximize, this.platformIcons.maximize, tooltips.maximize!, this.currentOptions.maximizable) - this.createControlButton(this.controls.close, this.platformIcons.close, tooltips.close!, this.currentOptions.closeable) + this.createControlButton(this.controls.minimize, this.platformIcons?.minimize, tooltips.minimize!, this.currentOptions.minimizable) + this.createControlButton(this.controls.maximize, this.platformIcons?.maximize, tooltips.maximize!, this.currentOptions.maximizable) + this.createControlButton(this.controls.close, this.platformIcons?.close, tooltips.close!, this.currentOptions.closeable) append(this.titlebar, this.controlsContainer) } @@ -246,7 +246,7 @@ export class CustomTitlebar extends ThemeBar { const order = this.currentOptions.order const hasShadow = this.currentOptions.shadow - addClass(this.titlebar, `cet-${PlatformToString(platform).toLocaleLowerCase()}`) + addClass(this.titlebar, `cet-${PlatformToString(platform)?.toLocaleLowerCase()}`) if (order) { addClass(this.titlebar, `cet-${order}`) @@ -550,7 +550,7 @@ export class CustomTitlebar extends ThemeBar { */ public updateBackground(backgroundColor: Color) { this.currentOptions.backgroundColor = backgroundColor - // this.updateStyles() + this.updateStyles() return this } @@ -561,7 +561,7 @@ export class CustomTitlebar extends ThemeBar { */ public updateItemBGColor(itemBGColor: Color) { this.currentOptions.itemBackgroundColor = itemBGColor - // this._updateStyles() + this.updateStyles() return this } @@ -611,4 +611,20 @@ export class CustomTitlebar extends ThemeBar { while (this.container.firstChild) append(document.body, this.container.firstChild) this.container.remove() } + + public get titlebarElement() { + return this.titlebar + } + + public get menubarElement() { + return this.menuBar + } + + public get containerElement() { + return this.container + } + + public get titleElement() { + return this.title + } }