Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
fix(titlebar): 🩹 Fixed bugs detected by the test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTorresDev committed Jul 24, 2023
1 parent 04e89b8 commit 1a6bbab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
32 changes: 24 additions & 8 deletions src/titlebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
Expand All @@ -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}`)
Expand Down Expand Up @@ -550,7 +550,7 @@ export class CustomTitlebar extends ThemeBar {
*/
public updateBackground(backgroundColor: Color) {
this.currentOptions.backgroundColor = backgroundColor
// this.updateStyles()
this.updateStyles()

return this
}
Expand All @@ -561,7 +561,7 @@ export class CustomTitlebar extends ThemeBar {
*/
public updateItemBGColor(itemBGColor: Color) {
this.currentOptions.itemBackgroundColor = itemBGColor
// this._updateStyles()
this.updateStyles()

return this
}
Expand Down Expand Up @@ -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
}
}

0 comments on commit 1a6bbab

Please sign in to comment.