npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lytrax/custom-electron-titlebar

v3.1.11

Published

Custom Electron Titlebar is a library for electron that allows you to configure a fully customizable title bar.

Downloads

10

Readme

Custom Electron Titlebar

This project is a typescript library for electron that allows you to configure a fully customizable title bar.

Fork

  1. Fix dispose.
  2. Fix deprecation warnings regarding isMinimizable, isMaximizable and isClosable.

It is a library for electron, it cannot be used on a basic website.

LICENSE NPM Version

Preview 1

Preview 2

Preview 3

Install

npm i @lytrax/custom-electron-titlebar

Or

npm install @lytrax/custom-electron-titlebar

or use the base project cet-quickstart

Usage

In your renderer file or in an HTML script tag add:

const customTitlebar = require('@lytrax/custom-electron-titlebar');

new customTitlebar.Titlebar({
	backgroundColor: customTitlebar.Color.fromHex('#444')
});

if you are using typescript

import { Titlebar, Color } from '@lytrax/custom-electron-titlebar'

new Titlebar({
	backgroundColor: Color.fromHex('#ECECEC')
});

The parameter backgroundColor: Color is required, this should be Color type. (View Update Background for more details).

Options

The interface [TitleBarOptions] is managed, which has the following configurable options for the title bar. Some parameters are optional.

| Parameter | Type | Description | Default | | ------------------------ | ---------------- | ------------------------------------------------------------------------------------- | ------------------------- | | backgroundColor (required) | Color | The background color of the titlebar. | #444444 | | icon | string | The icon shown on the left side of the title bar. | null | | iconsTheme | Theme | Style of the icons. | Themebar.win | | shadow | boolean | The shadow of the titlebar. | false | | drag | boolean | Define whether or not you can drag the window by holding the click on the title bar. | true | | minimizable | boolean | Enables or disables the option to minimize the window by clicking on the corresponding button in the title bar. | true | | maximizable | boolean | Enables or disables the option to maximize and un-maximize the window by clicking on the corresponding button in the title bar. | true | | closeable | boolean | Enables or disables the option of the close window by clicking on the corresponding button in the title bar. | true | | order | string | Set the order of the elements on the title bar. (inverted, first-buttons) | null | | titleHorizontalAlignment | string | Set horizontal alignment of the window title. (left, center, right) | center | | menu | Electron.Menu | The menu to show in the title bar. | Menu.getApplicationMenu() | | menuPosition | string | The position of menubar on titlebar. | left | | enableMnemonics | boolean | Enable the mnemonics on menubar and menu items. | true | | itemBackgroundColor | Color | The background color when the mouse is over the item. | rgba(0, 0, 0, .14) | | hideWhenClickingClose | boolean | When the close button is clicked, the window is hidden instead of closed. | false | | overflow | string | The overflow of the container (auto, visible, hidden) | auto

Methods

Update Background

When this method is executed, as well as when the title bar is created, it is checked whether the color is light or dark, so that the color of the icons adapts to the background of the title bar.

titlebar.updateBackground(new Color(new RGBA(0, 0, 0, .7)));

To assign colors you can use the following options: Color.fromHex(), new Color(new RGBA(r, g, b, a)), new Color(new HSLA(h, s, l, a)), new Color(new HSVA(h, s, v, a)) or Color.BLUE, Color.RED, etc.

Update Title

This method updated the title of the title bar, If you change the content of the title tag, you should call this method for update the title.

document.title = 'My new title';
titlebar.updateTitle();

// Or you can do as follows and avoid writing document.title
titlebar.updateTitle('New Title');

if this method is called and the title parameter is added, the title of the document is changed to that of the parameter.

Update Icon

With this method you can update the icon. This method receives the url of the image (it is advisable to use transparent image formats)

titlebar.updateIcon('./images/my-icon.svg');

Update Menu

This method updates or creates the menu, to create the menu use remote.Menu and remote.MenuItem.

const menu = new Menu();
menu.append(new MenuItem({
	label: 'Item 1',
	submenu: [
		{
			label: 'Subitem 1',
			click: () => console.log('Click on subitem 1')
		},
		{
			type: 'separator'
		}
	]
}));

menu.append(new MenuItem({
	label: 'Item 2',
	submenu: [
		{
			label: 'Subitem checkbox',
			type: 'checkbox',
			checked: true
		},
		{
			type: 'separator'
		},
		{
			label: 'Subitem with submenu',
			submenu: [
				{
					label: 'Submenu &item 1',
					accelerator: 'Ctrl+T'
				}
			]
		}
	]
}));

titlebar.updateMenu(menu);

Update Menu Position

You can change the position of the menu bar. left and bottom are allowed.

titlebar.updateMenuPosition('bottom');

Set Horizontal Alignment

setHorizontalAlignment method was contributed by @MairwunNx :punch:

left, center and right are allowed

titlebar.setHorizontalAlignment('right');

Dispose

This method removes the title bar completely and all recorded events.

titlebar.dispose();

Contributing

Many thanks to all the people who support this project through issues and pull request. If you want to contribute with this project, all the issues and pull request are welcome.

License

This project is under the MIT license.