custom-electron-titlebar 3.2.10 → 4.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +32 -96
  2. package/{build → dist}/browser/browser.d.ts +0 -0
  3. package/{build → dist}/browser/event.d.ts +0 -0
  4. package/{build → dist}/browser/iframe.d.ts +0 -0
  5. package/{build → dist}/browser/keyboardEvent.d.ts +0 -0
  6. package/{build → dist}/browser/mouseEvent.d.ts +0 -0
  7. package/{build → dist}/common/arrays.d.ts +0 -0
  8. package/{build → dist}/common/async.d.ts +0 -0
  9. package/{build → dist}/common/charCode.d.ts +0 -0
  10. package/{build → dist}/common/color.d.ts +0 -0
  11. package/{build → dist}/common/dom.d.ts +0 -0
  12. package/{build → dist}/common/event.d.ts +0 -0
  13. package/{build → dist}/common/iterator.d.ts +0 -0
  14. package/{build → dist}/common/keyCodes.d.ts +0 -0
  15. package/{build → dist}/common/lifecycle.d.ts +0 -0
  16. package/{build → dist}/common/linkedList.d.ts +0 -0
  17. package/{build → dist}/common/platform.d.ts +0 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.js +453 -0
  20. package/dist/interfaces.d.ts +96 -0
  21. package/{build → dist}/menu/menu.d.ts +3 -1
  22. package/{build → dist}/menu/menuitem.d.ts +3 -4
  23. package/{build → dist}/menubar.d.ts +1 -24
  24. package/dist/titlebar.d.ts +69 -0
  25. package/package.json +22 -14
  26. package/webpack.config.js +37 -0
  27. package/.github/FUNDING.yml +0 -1
  28. package/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
  29. package/.vscode/launch.json +0 -49
  30. package/.vscode/tasks.json +0 -34
  31. package/build/browser/browser.js +0 -157
  32. package/build/browser/browser.js.map +0 -1
  33. package/build/browser/event.js +0 -30
  34. package/build/browser/event.js.map +0 -1
  35. package/build/browser/iframe.js +0 -110
  36. package/build/browser/iframe.js.map +0 -1
  37. package/build/browser/keyboardEvent.js +0 -226
  38. package/build/browser/keyboardEvent.js.map +0 -1
  39. package/build/browser/mouseEvent.js +0 -110
  40. package/build/browser/mouseEvent.js.map +0 -1
  41. package/build/common/arrays.js +0 -18
  42. package/build/common/arrays.js.map +0 -1
  43. package/build/common/async.js +0 -95
  44. package/build/common/async.js.map +0 -1
  45. package/build/common/charCode.js +0 -7
  46. package/build/common/charCode.js.map +0 -1
  47. package/build/common/color.js +0 -494
  48. package/build/common/color.js.map +0 -1
  49. package/build/common/dom.js +0 -984
  50. package/build/common/dom.js.map +0 -1
  51. package/build/common/event.js +0 -611
  52. package/build/common/event.js.map +0 -1
  53. package/build/common/iterator.js +0 -164
  54. package/build/common/iterator.js.map +0 -1
  55. package/build/common/keyCodes.js +0 -268
  56. package/build/common/keyCodes.js.map +0 -1
  57. package/build/common/lifecycle.js +0 -63
  58. package/build/common/lifecycle.js.map +0 -1
  59. package/build/common/linkedList.js +0 -139
  60. package/build/common/linkedList.js.map +0 -1
  61. package/build/common/platform.js +0 -115
  62. package/build/common/platform.js.map +0 -1
  63. package/build/index.d.ts +0 -3
  64. package/build/index.js +0 -20
  65. package/build/index.js.map +0 -1
  66. package/build/menu/menu.js +0 -538
  67. package/build/menu/menu.js.map +0 -1
  68. package/build/menu/menuitem.js +0 -339
  69. package/build/menu/menuitem.js.map +0 -1
  70. package/build/menubar.js +0 -608
  71. package/build/menubar.js.map +0 -1
  72. package/build/themebar.d.ts +0 -20
  73. package/build/themebar.js +0 -568
  74. package/build/themebar.js.map +0 -1
  75. package/build/titlebar.d.ts +0 -135
  76. package/build/titlebar.js +0 -453
  77. package/build/titlebar.js.map +0 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Custom Electron Titlebar
1
+ # Custom Electron Titlebar 4
2
2
 
3
3
  This project is a typescript library for electron that allows you to configure a fully customizable title bar.
4
4
 
@@ -9,8 +9,6 @@ This project is a typescript library for electron that allows you to configure a
9
9
 
10
10
  ![Preview 2](screenshots/window_2.png)
11
11
 
12
- ![Preview 3](screenshots/window_3.png)
13
-
14
12
  ## Install
15
13
 
16
14
  ```
@@ -22,17 +20,19 @@ or use example folder to init basic electron project with this titlebar.
22
20
  ## Usage
23
21
 
24
22
  #### Step 1
25
- In your **renderer** file or in an **HTML script tag** add:
23
+ In your **preload** file add:
24
+
25
+ For javascript
26
26
 
27
27
  ```js
28
28
  const customTitlebar = require('custom-electron-titlebar');
29
29
 
30
30
  new customTitlebar.Titlebar({
31
- backgroundColor: customTitlebar.Color.fromHex('#444')
31
+ backgroundColor: customTitlebar.Color.fromHex('#ECECEC')
32
32
  });
33
33
  ```
34
34
 
35
- > if you are using _typescript_
35
+ For typescript
36
36
  ```ts
37
37
  import { Titlebar, Color } from 'custom-electron-titlebar'
38
38
 
@@ -47,10 +47,13 @@ The parameter `backgroundColor: Color` is required, this should be `Color` type.
47
47
  #### Step 2
48
48
  Update the code that launches browser window
49
49
  ```js
50
- var mainWindow = new BrowserWindow({
51
- width: 1000,
52
- height: 600,
53
- titleBarStyle: "hidden", // add this line
50
+ let mainWindow = new BrowserWindow({
51
+ width: 1000,
52
+ height: 600,
53
+ titleBarStyle: "hidden", // add this line
54
+ webPreferences: {
55
+ preload: path.join(__dirname, 'preload.js')
56
+ }
54
57
  });
55
58
  ```
56
59
 
@@ -58,25 +61,24 @@ var mainWindow = new BrowserWindow({
58
61
 
59
62
  The interface [`TitleBarOptions`] is managed, which has the following configurable options for the title bar. Some parameters are optional.
60
63
 
61
- | Parameter | Type | Description | Default |
62
- | ------------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
63
- | backgroundColor **(required)** | Color | The background color of the titlebar. | #444444 |
64
- | icon | string | The icon shown on the left side of the title bar. | null |
65
- | iconsTheme | Theme | Style of the icons. | Themebar.win |
66
- | shadow | boolean | The shadow of the titlebar. | false |
67
- | drag | boolean | Define whether or not you can drag the window by holding the click on the title bar. | true |
68
- | minimizable | boolean | Enables or disables the option to minimize the window by clicking on the corresponding button in the title bar. | true |
69
- | 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 |
70
- | closeable | boolean | Enables or disables the option of the close window by clicking on the corresponding button in the title bar. | true |
71
- | order | string | Set the order of the elements on the title bar. (`inverted`, `first-buttons`) | null |
72
- | titleHorizontalAlignment | string | Set horizontal alignment of the window title. (`left`, `center`, `right`) | center |
73
- | menu | Electron.Menu | The menu to show in the title bar. | Menu.getApplicationMenu() |
74
- | menuPosition | string | The position of menubar on titlebar. | left |
75
- | enableMnemonics | boolean | Enable the mnemonics on menubar and menu items. | true |
76
- | itemBackgroundColor | Color | The background color when the mouse is over the item. | rgba(0, 0, 0, .14) |
77
- | hideWhenClickingClose | boolean | When the close button is clicked, the window is hidden instead of closed. | false |
78
- | overflow | string | The overflow of the container (`auto`, `visible`, `hidden`) | auto |
79
- | unfocusEffect | boolean | Enables or disables the blur option in the title bar. | false |
64
+ | Parameter | Type | Description | Default |
65
+ | ------------------------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
66
+ | backgroundColor **(required)** | Color | The background color of the titlebar. | #444444 |
67
+ | icon | string | The icon shown on the left side of the title bar. | null |
68
+ | shadow | boolean | The shadow of the titlebar. | false |
69
+ | drag | boolean | Define whether or not you can drag the window by holding the click on the title bar. | true |
70
+ | onMinimize | Funtion | Enables or disables the option to minimize the window by clicking on the corresponding button in the title bar. | undefined |
71
+ | onMaximize | Funtion | Enables or disables the option to maximize and un-maximize the window by clicking on the corresponding button in the title bar. | undefined |
72
+ | onClose | Funtion | Enables or disables the option of the close window by clicking on the corresponding button in the title bar. | undefined |
73
+ | isMaximized | Funtion | Check if window is maximized. | undefined |
74
+ | onMenuItemClick | Funtion(commandId: number)| Fires when any menu option is pressed. | undefined |
75
+ | order | string | Set the order of the elements on the title bar. (`inverted`, `first-buttons`) | null |
76
+ | titleHorizontalAlignment | string | Set horizontal alignment of the window title. (`left`, `center`, `right`) | center |
77
+ | menuPosition | string | The position of menubar on titlebar. | left |
78
+ | enableMnemonics | boolean | Enable the mnemonics on menubar and menu items. | true |
79
+ | hideWhenClickingClose | boolean | When the close button is clicked, the window is hidden instead of closed. | false |
80
+ | overflow | string | The overflow of the container (`auto`, `visible`, `hidden`) | auto |
81
+ | unfocusEffect | boolean | Enables or disables the blur option in the title bar. | false |
80
82
 
81
83
  ## Methods
82
84
 
@@ -122,51 +124,6 @@ With this method you can update the icon. This method receives the url of the im
122
124
  titlebar.updateIcon('./images/my-icon.svg');
123
125
  ```
124
126
 
125
- ### Update Menu
126
-
127
- This method updates or creates the menu, to create the menu use remote.Menu and remote.MenuItem.
128
-
129
- ```js
130
- const menu = new Menu();
131
- menu.append(new MenuItem({
132
- label: 'Item 1',
133
- submenu: [
134
- {
135
- label: 'Subitem 1',
136
- click: () => console.log('Click on subitem 1')
137
- },
138
- {
139
- type: 'separator'
140
- }
141
- ]
142
- }));
143
-
144
- menu.append(new MenuItem({
145
- label: 'Item 2',
146
- submenu: [
147
- {
148
- label: 'Subitem checkbox',
149
- type: 'checkbox',
150
- checked: true
151
- },
152
- {
153
- type: 'separator'
154
- },
155
- {
156
- label: 'Subitem with submenu',
157
- submenu: [
158
- {
159
- label: 'Submenu &item 1',
160
- accelerator: 'Ctrl+T'
161
- }
162
- ]
163
- }
164
- ]
165
- }));
166
-
167
- titlebar.updateMenu(menu);
168
- ```
169
-
170
127
  ### Update Menu Position
171
128
 
172
129
  You can change the position of the menu bar. `left` and `bottom` are allowed.
@@ -177,9 +134,7 @@ titlebar.updateMenuPosition('bottom');
177
134
 
178
135
  ### Set Horizontal Alignment
179
136
 
180
- > setHorizontalAlignment method was contributed by [@MairwunNx](https://github.com/MairwunNx) :punch:
181
-
182
- `left`, `center` and `right` are allowed
137
+ You can change the position of the title of title bar. `left`, `center` and `right` are allowed
183
138
 
184
139
  ```js
185
140
  titlebar.setHorizontalAlignment('right');
@@ -193,25 +148,6 @@ This method removes the title bar completely and all recorded events.
193
148
  titlebar.dispose();
194
149
  ```
195
150
 
196
- ## CSS Classes
197
- The following CSS classes exist and can be used to customize the titlebar
198
-
199
- | Class name | Description |
200
- | --------------------------- | -----------------------------------------------------------------|
201
- | .titlebar | Styles the titlebar. |
202
- | .window-appicon | Styles the app icon on the titlebar. |
203
- | .window-title | Styles the window title. (Example: font-size) |
204
- | .window-controls-container | Styles the window controls section. |
205
- | .resizer top | Styles the resizer invisible top bar |
206
- | .resizer left | Styles the resizer invisible left bar |
207
- | .menubar | Styles the top menus |
208
- | .menubar-menu-button | Styles the main menu elements. (Example: color) |
209
- | .menubar-menu-button open | Styles the main menu elements when open menu. (Example: color) |
210
- | .menubar-menu-title | Description missing |
211
- | .action-item | Description missing |
212
- | .action-menu-item | Styles action menu elements. (Example: color) |
213
-
214
-
215
151
  ## License
216
152
 
217
153
  This project is under the [MIT](https://github.com/AlexTorresSk/custom-electron-titlebar/blob/master/LICENSE) license.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ import Titlebar from './titlebar';
2
+ import { Color } from './common/color';
3
+ declare const _default: {
4
+ Titlebar: typeof Titlebar;
5
+ Color: typeof Color;
6
+ };
7
+ export default _default;