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

Commit 8eaad25

Browse files
committed
Merge branch 'develop'
2 parents 7694f09 + 5495179 commit 8eaad25

32 files changed

+8572
-2539
lines changed

.npmignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
.idea/
55

66
# for npm
7+
.vscode/
8+
.github/
79
node_modules/
810
npm-shrinkwrap.json
911

@@ -13,8 +15,8 @@ typings/
1315
espowered/
1416

1517
# for https://github.com/Microsoft/TypeScript/issues/4667
16-
lib/**/*.ts
17-
!lib/**/*.d.ts
18+
dist/**/*.ts
19+
!dist/**/*.d.ts
1820

1921
# codes
2022
test/

.vscode/tasks.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
{
77
"label": "electron-debug",
88
"type": "process",
9-
"command": "./node_modules/.bin/tsc",
9+
"command": "./node_modules/.bin/webpack",
1010
"windows": {
11-
"command": "./node_modules/.bin/tsc.cmd"
11+
"command": "./node_modules/.bin/webpack.cmd"
1212
},
13-
"isBackground": true,
14-
// "args": [],
13+
"args": [
14+
"--config",
15+
"./webpack.config.js",
16+
"--mode",
17+
"development"
18+
],
1519
"problemMatcher": {
1620
"owner": "custom",
1721
"pattern": {

README.md

Lines changed: 10 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -10,213 +10,20 @@ This project is a typescript library for electron that allows you to configure a
1010
[![LICENSE](https://img.shields.io/github/license/AlexTorresSk/custom-electron-titlebar.svg)](https://github.com/AlexTorresSk/custom-electron-titlebar/blob/master/LICENSE)
1111
[![NPM Version](https://img.shields.io/npm/v/custom-electron-titlebar.svg)](https://npmjs.org/package/custom-electron-titlebar)
1212

13-
![Preview 1](screenshots/window_1.png)
13+
![Screenshot 1](screenshots/cet-001.jpg)
1414

15-
![Preview 2](screenshots/window_2.png)
15+
![Screenshot 2](screenshots/cet-002.jpg)
1616

17-
![Preview 3](screenshots/window_3.png)
18-
19-
## Install
20-
21-
```
22-
npm i custom-electron-titlebar
23-
```
24-
25-
or use example folder to init basic electron project with this titlebar.
26-
27-
## Usage
28-
29-
#### Step 1
30-
In your **renderer** file or in an **HTML script tag** add:
31-
32-
```js
33-
const customTitlebar = require('custom-electron-titlebar');
34-
35-
new customTitlebar.Titlebar({
36-
backgroundColor: customTitlebar.Color.fromHex('#444')
37-
});
38-
```
39-
40-
> if you are using _typescript_
41-
```ts
42-
import { Titlebar, Color } from 'custom-electron-titlebar'
43-
44-
new Titlebar({
45-
backgroundColor: Color.fromHex('#ECECEC')
46-
});
17+
## 🟢 Install
4718
```
48-
49-
The parameter `backgroundColor: Color` is required, this should be `Color` type.
50-
(View [Update Background](#update-background) for more details).
51-
52-
#### Step 2
53-
Update the code that launches browser window
54-
```js
55-
var mainWindow = new BrowserWindow({
56-
width: 1000,
57-
height: 600,
58-
titleBarStyle: "hidden", // add this line
59-
});
19+
npm install custom-electron-titlebar
6020
```
6121

62-
## Options
63-
64-
The interface [`TitleBarOptions`] is managed, which has the following configurable options for the title bar. Some parameters are optional.
65-
66-
| Parameter | Type | Description | Default |
67-
| ------------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
68-
| backgroundColor **(required)** | Color | The background color of the titlebar. | #444444 |
69-
| icon | string | The icon shown on the left side of the title bar. | null |
70-
| iconsTheme | Theme | Style of the icons. | Themebar.win |
71-
| shadow | boolean | The shadow of the titlebar. | false |
72-
| drag | boolean | Define whether or not you can drag the window by holding the click on the title bar. | true |
73-
| minimizable | boolean | Enables or disables the option to minimize the window by clicking on the corresponding button in the title bar. | true |
74-
| 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 |
75-
| closeable | boolean | Enables or disables the option of the close window by clicking on the corresponding button in the title bar. | true |
76-
| order | string | Set the order of the elements on the title bar. (`inverted`, `first-buttons`) | null |
77-
| titleHorizontalAlignment | string | Set horizontal alignment of the window title. (`left`, `center`, `right`) | center |
78-
| menu | Electron.Menu | The menu to show in the title bar. | Menu.getApplicationMenu() |
79-
| menuPosition | string | The position of menubar on titlebar. | left |
80-
| enableMnemonics | boolean | Enable the mnemonics on menubar and menu items. | true |
81-
| itemBackgroundColor | Color | The background color when the mouse is over the item. | rgba(0, 0, 0, .14) |
82-
| hideWhenClickingClose | boolean | When the close button is clicked, the window is hidden instead of closed. | false |
83-
| overflow | string | The overflow of the container (`auto`, `visible`, `hidden`) | auto |
84-
| unfocusEffect | boolean | Enables or disables the blur option in the title bar. | false |
85-
86-
## Methods
87-
88-
### Update Background
89-
90-
This change the color of titlebar and it's checked whether the color is light or dark, so that the color of the icons adapts to the background of the title bar.
91-
92-
```js
93-
titlebar.updateBackground(new Color(new RGBA(0, 0, 0, .7)));
94-
```
95-
96-
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.
97-
98-
### Update Items Background Color
99-
100-
This method change background color on hover of items of menubar.
101-
102-
```js
103-
titlebar.updateItemBGColor(new Color(new RGBA(0, 0, 0, .7)));
104-
```
105-
106-
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.
107-
108-
### Update Title
109-
110-
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.
111-
112-
```js
113-
document.title = 'My new title';
114-
titlebar.updateTitle();
115-
116-
// Or you can do as follows and avoid writing document.title
117-
titlebar.updateTitle('New Title');
118-
```
119-
120-
if this method is called and the title parameter is added, the title of the document is changed to that of the parameter.
121-
122-
### Update Icon
123-
124-
With this method you can update the icon. This method receives the url of the image _(it is advisable to use transparent image formats)_
125-
126-
```js
127-
titlebar.updateIcon('./images/my-icon.svg');
128-
```
129-
130-
### Update Menu
131-
132-
This method updates or creates the menu, to create the menu use remote.Menu and remote.MenuItem.
133-
134-
```js
135-
const menu = new Menu();
136-
menu.append(new MenuItem({
137-
label: 'Item 1',
138-
submenu: [
139-
{
140-
label: 'Subitem 1',
141-
click: () => console.log('Click on subitem 1')
142-
},
143-
{
144-
type: 'separator'
145-
}
146-
]
147-
}));
148-
149-
menu.append(new MenuItem({
150-
label: 'Item 2',
151-
submenu: [
152-
{
153-
label: 'Subitem checkbox',
154-
type: 'checkbox',
155-
checked: true
156-
},
157-
{
158-
type: 'separator'
159-
},
160-
{
161-
label: 'Subitem with submenu',
162-
submenu: [
163-
{
164-
label: 'Submenu &item 1',
165-
accelerator: 'Ctrl+T'
166-
}
167-
]
168-
}
169-
]
170-
}));
171-
172-
titlebar.updateMenu(menu);
173-
```
174-
175-
### Update Menu Position
176-
177-
You can change the position of the menu bar. `left` and `bottom` are allowed.
178-
179-
```js
180-
titlebar.updateMenuPosition('bottom');
181-
```
182-
183-
### Set Horizontal Alignment
184-
185-
> setHorizontalAlignment method was contributed by [@MairwunNx](https://github.com/MairwunNx) :punch:
186-
187-
`left`, `center` and `right` are allowed
188-
189-
```js
190-
titlebar.setHorizontalAlignment('right');
191-
```
192-
193-
### Dispose
194-
195-
This method removes the title bar completely and all recorded events.
196-
197-
```js
198-
titlebar.dispose();
199-
```
200-
201-
## CSS Classes
202-
The following CSS classes exist and can be used to customize the titlebar
203-
204-
| Class name | Description |
205-
| --------------------------- | -----------------------------------------------------------------|
206-
| .titlebar | Styles the titlebar. |
207-
| .window-appicon | Styles the app icon on the titlebar. |
208-
| .window-title | Styles the window title. (Example: font-size) |
209-
| .window-controls-container | Styles the window controls section. |
210-
| .resizer top | Styles the resizer invisible top bar |
211-
| .resizer left | Styles the resizer invisible left bar |
212-
| .menubar | Styles the top menus |
213-
| .menubar-menu-button | Styles the main menu elements. (Example: color) |
214-
| .menubar-menu-button open | Styles the main menu elements when open menu. (Example: color) |
215-
| .menubar-menu-title | Description missing |
216-
| .action-item | Description missing |
217-
| .action-menu-item | Styles action menu elements. (Example: color) |
218-
219-
220-
## License
22+
## 🚀 Usage
23+
To see the documentation on how to use the title bar, visit the [Wiki](https://github.com/AlexTorresSk/custom-electron-titlebar/wiki)
22124

25+
## ✅ License
22226
This project is under the [MIT](https://github.com/AlexTorresSk/custom-electron-titlebar/blob/master/LICENSE) license.
27+
28+
## 💰 Support
29+
If you want to support my development, you can do so by donating through [Buy me a coffee](https://www.buymeacoffee.com/AlexTorresSk), [Paypal](https://www.paypal.com/paypalme/hapovedat) or [Patreon](https://www.patreon.com/AlexTorresSk)

example/assets/images/icon.svg

Lines changed: 3 additions & 0 deletions
Loading

example/images/icon.png

-1.38 KB
Binary file not shown.

example/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<head>
55
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
67
<title>Hello World!</title>
78
<style>
89
html {

0 commit comments

Comments
 (0)