custom-electron-titlebar 4.4.0 → 4.4.1
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.
- package/README.md +1 -5
- package/index.js +17 -35
- package/index.js.map +1 -1
- package/index.mjs +17 -25
- package/index.mjs.map +1 -1
- package/package.json +6 -21
- package/theme/base.css +0 -425
- package/theme/mac.css +0 -0
- package/theme/win.css +0 -0
package/README.md
CHANGED
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
This project is a typescript library for electron that allows you to configure a fully customizable title bar.
|
|
4
4
|
|
|
5
|
-
[](https://github.com/AlexTorresDev/custom-electron-titlebar/actions/workflows/build
|
|
5
|
+
[](https://github.com/AlexTorresDev/custom-electron-titlebar/actions/workflows/build.yml)
|
|
6
6
|
[](https://github.com/AlexTorresDev/custom-electron-titlebar/blob/master/LICENSE)
|
|
7
7
|
[](https://npmjs.org/package/custom-electron-titlebar)
|
|
8
8
|
[](https://packagephobia.com/result?p=custom-electron-titlebar)
|
|
9
9
|
|
|
10
|
-
> [!IMPORTANT]
|
|
11
|
-
> This project will no longer be maintained, because I am the only one working on it and I have no free time left to review the issues and incorporate new features or update the dependencies to the latest versions.
|
|
12
|
-
>
|
|
13
|
-
> **Thanks to all the contributors and dependents of this library.**
|
|
14
10
|
|
|
15
11
|
[📄 Documentation](https://github.com/AlexTorresDev/custom-electron-titlebar/wiki)
|
|
16
12
|
|
package/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -4434,29 +4424,20 @@ var _MenuBar = class _MenuBar extends Disposable {
|
|
|
4434
4424
|
_MenuBar.OVERFLOW_INDEX = -1;
|
|
4435
4425
|
var MenuBar = _MenuBar;
|
|
4436
4426
|
|
|
4427
|
+
// raw-loader:/home/runner/work/custom-electron-titlebar/custom-electron-titlebar/static/theme/base.css?raw
|
|
4428
|
+
var base_default = "body {\n margin: 0 !important;\n overflow: hidden !important;\n}\n\n/* Titlebar */\n.cet-titlebar {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n flex-wrap: wrap;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n font-size: var(--cet-font-size, 13px);\n font-family: var(--cet-font-family, Arial, Helvetica, sans-serif);\n box-sizing: border-box;\n padding: 0 16px;\n overflow: hidden;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n zoom: 1;\n width: 100%;\n height: 31px;\n line-height: 31px;\n z-index: 99999;\n}\n\n.cet-titlebar *,\n.cet-titlebar *:before,\n.cet-titlebar *:after {\n box-sizing: border-box;\n}\n\n.cet-titlebar.cet-windows,\n.cet-titlebar.cet-linux,\n.cet-titlebar.cet-freebsd {\n padding: 0;\n height: 30px;\n line-height: 30px;\n justify-content: left;\n overflow: visible;\n}\n\n/* Inverted */\n.cet-titlebar.cet-inverted {\n flex-direction: row-reverse;\n}\n\n.cet-titlebar.cet-inverted .cet-menubar,\n.cet-titlebar.cet-inverted .cet-window-controls {\n flex-direction: row-reverse;\n margin-left: 20px;\n margin-right: 0;\n}\n\n/* First buttons */\n.cet-titlebar.cet-first-buttons .cet-window-controls {\n order: -1;\n margin: 0 5px 0 0;\n}\n\n.cet-titlebar.cet-inverted .cet-window-controls {\n margin: 0 5px 0 0;\n}\n\n/* Shadow */\n.cet-titlebar.cet-shadow {\n box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12);\n}\n\n/* Drag region */\n.cet-drag-region {\n top: 0;\n left: 0;\n display: block;\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: -1;\n -webkit-app-region: drag;\n}\n\n/* Icon */\n.cet-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 34px;\n height: 30px;\n z-index: 99;\n overflow: hidden;\n}\n\n/* Title */\n.cet-title {\n flex: 0 1 auto;\n font-size: var(--cet-title-font-size, 12px);\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n zoom: 1;\n}\n\n/* Title alignment */\n.cet-title.cet-title-left {\n margin-left: 8px;\n margin-right: auto;\n}\n\n.cet-title.cet-title-right {\n margin-left: auto;\n margin-right: 8px;\n}\n\n.cet-title.cet-title-center {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n}\n\n.cet-title.cet-bigsur {\n font-size: 13px;\n font-weight: 600;\n}\n\n/* Window controls */\n.cet-window-controls {\n display: flex;\n flex-grow: 0;\n flex-shrink: 0;\n text-align: center;\n position: relative;\n z-index: 99;\n -webkit-app-region: no-drag;\n height: 30px;\n font-family: initial !important;\n margin-left: auto;\n}\n\n.cet-control-icon {\n width: 2.85rem;\n}\n\n.cet-control-icon:not(.inactive):hover {\n background-color: rgb(255 255 255 / 12%);\n}\n\n.light .cet-control-icon:not(.inactive):hover {\n background-color: rgb(0 0 0 / 12%);\n}\n\n.cet-control-icon.inactive svg {\n opacity: 0.4;\n}\n\n.cet-control-icon svg {\n width: 10px;\n height: -webkit-fill-available;\n fill: #fff;\n display: initial !important;\n vertical-align: unset !important;\n}\n\n.cet-titlebar.light .cet-control-icon svg {\n fill: #222222 !important;\n}\n\n.cet-control-close:not(.inactive):hover {\n background-color: rgb(232 17 35 / 90%) !important;\n}\n\n.cet-control-close:not(.inactive):hover svg {\n fill: #fff !important;\n}\n\n/* Resizer */\n.cet-resizer {\n -webkit-app-region: no-drag;\n position: absolute;\n}\n\n.cet-resizer.left {\n top: 0;\n left: 0;\n width: 6px;\n height: 100%;\n}\n\n.cet-resizer.top {\n top: 0;\n width: 100%;\n height: 6px;\n}\n\n/* Container */\n.cet-container {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: auto;\n z-index: 1;\n}\n\n/* MenuBar */\n.cet-menubar {\n min-width: 0;\n display: flex;\n flex-shrink: 1;\n flex-grow: 0;\n box-sizing: border-box;\n overflow: hidden;\n flex-wrap: nowrap;\n margin-right: 20px;\n}\n\n.cet-menubar.bottom {\n order: 1;\n width: 100%;\n padding: 0 5px 5px;\n margin-right: 0;\n}\n\n.cet-menubar.bottom .cet-menubar-menu-button {\n border-radius: 4px;\n}\n\n.cet-menubar.bottom .cet-menubar-menu-button .cet-menubar-menu-title {\n line-height: 26px;\n}\n\n.cet-menubar .cet-menubar-menu-button {\n box-sizing: border-box;\n padding: 0px 8px;\n height: 100%;\n cursor: default;\n zoom: 1;\n white-space: nowrap;\n -webkit-app-region: no-drag;\n outline: 0;\n}\n\n.cet-menubar .cet-menubar-menu-button .cet-menubar-menu-title {\n font-size: var(--cet-menu-font-size, 12px);\n}\n\n.cet-menubar .cet-menubar-menu-title.cet-toggle-more {\n font-weight: 700;\n letter-spacing: 1px;\n}\n\n.cet-menubar .cet-menubar-menu-button.disabled {\n opacity: 0.4;\n}\n\n.cet-menubar .cet-menubar-menu-button:not(.disabled):hover,\n.cet-menubar .cet-menubar-menu-button:not(.disabled).open {\n background-color: rgb(255 255 255 / 12%);\n}\n\n.cet-titlebar.light .cet-menubar .cet-menubar-menu-button:not(.disabled):hover,\n.cet-titlebar.light .cet-menubar .cet-menubar-menu-button:not(.disabled).open {\n background-color: rgb(0 0 0 / 12%);\n}\n\n.cet-menubar-menu-container {\n position: absolute;\n display: block;\n left: 0px;\n opacity: 1;\n outline: 0;\n border: none;\n text-align: left;\n margin: 0 auto;\n margin-left: 0;\n font-size: inherit;\n overflow-x: visible;\n overflow-y: visible;\n -webkit-overflow-scrolling: touch;\n justify-content: flex-end;\n white-space: nowrap;\n border-radius: 7px;\n backdrop-filter: blur(10px);\n box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);\n z-index: 99999;\n}\n\n.cet-menubar-menu-container::-webkit-scrollbar {\n width: 8px;\n height: 4px;\n cursor: pointer;\n background-color: rgba(0, 0, 0, 0);\n}\n\n.cet-menubar-menu-container::-webkit-scrollbar-track {\n border: none;\n background-color: rgba(0, 0, 0, 0);\n}\n\n.cet-menubar-menu-container::-webkit-scrollbar-thumb {\n border-radius: 10px;\n background-color: rgba(110, 110, 110, 0.2);\n}\n\n.cet-menubar-menu-container:focus {\n outline: 0;\n}\n\n.cet-menubar-menu-container .cet-action-item {\n padding: 0;\n margin: 0;\n transform: none;\n display: -ms-flexbox;\n display: flex;\n outline: none;\n}\n\n.cet-menubar-menu-container .cet-action-item.active {\n transform: none;\n}\n\n.cet-menubar-menu-container .cet-action-item.disabled .cet-action-menu-item {\n opacity: 0.4;\n}\n\n.cet-menubar-menu-container .cet-action-item .cet-submenu {\n position: absolute;\n}\n\n.cet-menubar-menu-container .cet-action-menu-item {\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n display: -ms-flexbox;\n display: flex;\n height: 2.231em;\n margin: 4px 3px;\n align-items: center;\n position: relative;\n border-radius: 4px;\n text-decoration: none;\n}\n\n.cet-menubar-menu-container .cet-action-label {\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n text-decoration: none;\n padding: 0 1em;\n background: none;\n font-size: 12px;\n line-height: 1;\n}\n\n.cet-menubar-menu-container .cet-action-label:not(.separator) {\n display: inline-block;\n -webkit-box-sizing: border-box;\n -o-box-sizing: border-box;\n -moz-box-sizing: border-box;\n -ms-box-sizing: border-box;\n box-sizing: border-box;\n margin: 0;\n padding: 0 2em 0 0.8em;\n}\n\n.cet-menubar-menu-container .cet-action-label.separator {\n opacity: 0.1;\n font-size: inherit;\n width: 100%;\n border-bottom: 1px solid transparent;\n}\n\n.cet-menubar-menu-container .cet-action-label.separator.text {\n padding: 0.7em 1em 0.1em 1em;\n font-weight: bold;\n opacity: 1;\n}\n\n.cet-menubar-menu-container .cet-action-label:hover {\n color: inherit;\n}\n\n.cet-menubar-menu-container .keybinding,\n.cet-menubar-menu-container .cet-submenu-indicator {\n display: inline-block;\n -ms-flex: 2 1 auto;\n flex: 2 1 auto;\n padding: 0 2em 0 1em;\n text-align: right;\n font-size: 11px;\n line-height: 1;\n}\n\n.cet-menubar-menu-container .cet-submenu-indicator {\n position: absolute;\n right: 4px;\n height: 12px;\n width: 12px;\n padding: 0;\n}\n\n.cet-menubar-menu-container .cet-submenu-indicator img,\n.cet-menubar-menu-container .cet-menu-item-icon .icon,\n.cet-menubar-menu-container .cet-submenu-indicator svg,\n.cet-menubar-menu-container .cet-menu-item-icon svg {\n display: inherit;\n width: 100%;\n height: 100%;\n}\n\n.cet-menubar-menu-container .cet-action-menu-item.checked>.cet-menu-item-icon.checkbox {\n visibility: visible;\n}\n\n.cet-menubar-menu-container .cet-menu-item-icon {\n width: 14px;\n height: 14px;\n margin: 0 0 0 12px;\n}\n\n.cet-menubar-menu-container .cet-menu-item-icon.checkbox {\n visibility: hidden;\n}";
|
|
4429
|
+
|
|
4430
|
+
// raw-loader:/home/runner/work/custom-electron-titlebar/custom-electron-titlebar/static/theme/mac.css?raw
|
|
4431
|
+
var mac_default = "";
|
|
4432
|
+
|
|
4433
|
+
// raw-loader:/home/runner/work/custom-electron-titlebar/custom-electron-titlebar/static/theme/win.css?raw
|
|
4434
|
+
var win_default = "";
|
|
4435
|
+
|
|
4437
4436
|
// src/titlebar/themebar.ts
|
|
4438
|
-
var path = __toESM(require("path"));
|
|
4439
|
-
var fs = __toESM(require("fs"));
|
|
4440
|
-
function loadThemeCss(filename) {
|
|
4441
|
-
let cssPath = path.resolve(process.cwd(), "dist/theme", filename);
|
|
4442
|
-
if (!fs.existsSync(cssPath)) {
|
|
4443
|
-
cssPath = path.resolve(process.cwd(), "static/theme", filename);
|
|
4444
|
-
}
|
|
4445
|
-
try {
|
|
4446
|
-
return fs.readFileSync(cssPath, "utf8");
|
|
4447
|
-
} catch (e) {
|
|
4448
|
-
console.warn("Could not load theme CSS:", cssPath, e);
|
|
4449
|
-
return "";
|
|
4450
|
-
}
|
|
4451
|
-
}
|
|
4452
|
-
var baseTheme = loadThemeCss("base.css");
|
|
4453
|
-
var macTheme = loadThemeCss("mac.css");
|
|
4454
|
-
var winTheme = loadThemeCss("win.css");
|
|
4455
4437
|
var ThemingRegistry = class extends Disposable {
|
|
4456
4438
|
constructor() {
|
|
4457
4439
|
super();
|
|
4458
4440
|
this.theming = [];
|
|
4459
|
-
this.theming = [];
|
|
4460
4441
|
}
|
|
4461
4442
|
onThemeChange(theme) {
|
|
4462
4443
|
this.theming.push(theme);
|
|
@@ -4473,7 +4454,7 @@ var ThemeBar = class extends ThemingRegistry {
|
|
|
4473
4454
|
constructor() {
|
|
4474
4455
|
super();
|
|
4475
4456
|
this.registerTheme((collector) => {
|
|
4476
|
-
collector.addRule(
|
|
4457
|
+
collector.addRule(base_default);
|
|
4477
4458
|
});
|
|
4478
4459
|
}
|
|
4479
4460
|
registerTheme(theme) {
|
|
@@ -4493,12 +4474,12 @@ var ThemeBar = class extends ThemingRegistry {
|
|
|
4493
4474
|
}
|
|
4494
4475
|
static get win() {
|
|
4495
4476
|
return (collector) => {
|
|
4496
|
-
collector.addRule(
|
|
4477
|
+
collector.addRule(win_default);
|
|
4497
4478
|
};
|
|
4498
4479
|
}
|
|
4499
4480
|
static get mac() {
|
|
4500
4481
|
return (collector) => {
|
|
4501
|
-
collector.addRule(
|
|
4482
|
+
collector.addRule(mac_default);
|
|
4502
4483
|
};
|
|
4503
4484
|
}
|
|
4504
4485
|
};
|
|
@@ -4510,6 +4491,7 @@ function _applyRules(styleSheetContent, rulesClassName) {
|
|
|
4510
4491
|
styleElement.innerHTML = styleSheetContent;
|
|
4511
4492
|
document.head.appendChild(styleElement);
|
|
4512
4493
|
} else {
|
|
4494
|
+
;
|
|
4513
4495
|
themeStyles[0].innerHTML = styleSheetContent;
|
|
4514
4496
|
}
|
|
4515
4497
|
}
|
|
@@ -5093,9 +5075,9 @@ var CustomTitlebar = class extends ThemeBar {
|
|
|
5093
5075
|
* It method set new icon to title-bar-icon of title-bar.
|
|
5094
5076
|
* @param path path to icon
|
|
5095
5077
|
*/
|
|
5096
|
-
updateIcon(
|
|
5078
|
+
updateIcon(path) {
|
|
5097
5079
|
if (this.icon && this.icon.firstElementChild) {
|
|
5098
|
-
this.icon.firstElementChild.setAttribute("src",
|
|
5080
|
+
this.icon.firstElementChild.setAttribute("src", path);
|
|
5099
5081
|
}
|
|
5100
5082
|
return this;
|
|
5101
5083
|
}
|
|
@@ -5244,8 +5226,8 @@ var CustomTitlebar = class extends ThemeBar {
|
|
|
5244
5226
|
var createTitlebar = (options = {}) => new CustomTitlebar(options);
|
|
5245
5227
|
var createTitlebarOnDOMContentLoaded = (options = {}) => {
|
|
5246
5228
|
if (document.readyState === "loading") {
|
|
5247
|
-
return new Promise((
|
|
5248
|
-
window.addEventListener("DOMContentLoaded", () =>
|
|
5229
|
+
return new Promise((resolve) => {
|
|
5230
|
+
window.addEventListener("DOMContentLoaded", () => resolve(new CustomTitlebar(options)), { once: true });
|
|
5249
5231
|
});
|
|
5250
5232
|
}
|
|
5251
5233
|
return Promise.resolve(new CustomTitlebar(options));
|