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

Commit 1cdf684

Browse files
Merge pull request #196 from AlexTorresSk/develop
Fix preload file error
2 parents 285cd7a + 05b3b6f commit 1cdf684

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3340
-3219
lines changed

.github/ISSUE_TEMPLATE/issue-report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
2727
- OS: [e.g. Windows]
28-
- Electron version [e.g. 4.0.0]
29-
- Node Version [e.g. 2.2]
28+
- Electron version [e.g. 16.0.0]
29+
- Node Version [e.g. 14.0]

.github/stale.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 60
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- pinned
8+
- security
9+
# Label to use when marking an issue as stale
10+
staleLabel: wontfix
11+
# Comment to post when marking an issue as stale. Set to `false` to disable
12+
markComment: false
13+
# Comment to post when closing a stale issue. Set to `false` to disable
14+
closeComment: >
15+
📢 This issue has been closed automatically because it has not had recent activity.
16+
Thank you for your contributions.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ typings/
189189
dist
190190
build/
191191
*.map
192+
index.js
193+
main.js
192194

193195
# Gatsby files
194196
.cache/

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ tsconfig.json
3535

3636
npm-debug.log
3737
webpack.config.js
38-
._config.yml
38+
_config.yml

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Alex Torres
3+
Copyright (c) 2018 - now Alex Torres
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project is a typescript library for electron that allows you to configure a
44

55
[![LICENSE](https://img.shields.io/github/license/AlexTorresSk/custom-electron-titlebar.svg)](https://github.com/AlexTorresSk/custom-electron-titlebar/blob/master/LICENSE)
66
[![NPM Version](https://img.shields.io/npm/v/custom-electron-titlebar.svg)](https://npmjs.org/package/custom-electron-titlebar)
7+
[![install size](https://packagephobia.com/badge?p=custom-electron-titlebar)](https://packagephobia.com/result?p=custom-electron-titlebar)
78

89
![Screenshot 1](screenshots/cet-001.jpg)
910

@@ -30,6 +31,17 @@ import { setupTitlebar, attachTitlebarToWindow } from "custom-electron-titlebar/
3031
setupTitlebar();
3132

3233
function createWindow() {
34+
// Create the browser window.
35+
const mainWindow = new BrowserWindow({
36+
width: 800,
37+
height: 600,
38+
titleBarStyle: 'hidden',
39+
//frame: false, // needed if process.versions.electron < 14
40+
webPreferences: {
41+
preload: path.join(__dirname, 'preload.js')
42+
}
43+
});
44+
3345
...
3446

3547
// attach fullscreen(f11 and not 'maximized') && focus listeners

example/assets/icons.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"check": "<svg viewBox='0 0 11 11'><path d='M3.8,9.3c-0.1,0-0.2,0-0.3-0.1L0.2,5.8C0,5.6,0,5.4,0.2,5.2C0.4,5,0.7,5,0.9,5.2l3,3l6.3-6.3c0.2-0.2,0.5-0.2,0.7,0C11,2,11,2.3,10.8,2.5L4.2,9.1C4.1,9.2,4,9.3,3.8,9.3z'/></svg>",
33
"arrow": "<svg viewBox='0 0 11 11'><path d='M3.1,10.7c-0.1,0-0.2,0-0.3-0.1c-0.2-0.2-0.2-0.5,0-0.7l4.4-4.4L2.8,1.1c-0.2-0.2-0.2-0.5,0-0.7c0.2-0.2,0.5-0.2,0.7,0l4.8,4.8c0.2,0.2,0.2,0.5,0,0.7l-4.8,4.8C3.4,10.7,3.2,10.7,3.1,10.7z'/></svg>",
4-
"win": {
4+
"windows": {
55
"minimize": "<svg viewBox='0 0 11 11'><path d='M11,4.9v1.1H0V4.399h11z'/></svg>",
66
"maximize": "<svg viewBox='0 0 11 11'><path d='M0,1.7v7.6C0,10.2,0.8,11,1.7,11h7.6c0.9,0,1.7-0.8,1.7-1.7V1.7C11,0.8,10.2,0,9.3,0H1.7C0.8,0,0,0.8,0,1.7z M8.8,9.9H2.2c-0.6,0-1.1-0.5-1.1-1.1V2.2c0-0.6,0.5-1.1,1.1-1.1h6.7c0.6,0,1.1,0.5,1.1,1.1v6.7C9.9,9.4,9.4,9.9,8.8,9.9z'/></svg>",
77
"restore": "<svg viewBox='0 0 11 11'><path d='M7.9,2.2h-7C0.4,2.2,0,2.6,0,3.1v7C0,10.6,0.4,11,0.9,11h7c0.5,0,0.9-0.4,0.9-0.9v-7C8.8,2.6,8.4,2.2,7.9,2.2z M7.7,9.6 c0,0.2-0.1,0.3-0.3,0.3h-6c-0.2,0-0.3-0.1-0.3-0.3v-6c0-0.2,0.1-0.3,0.3-0.3h6c0.2,0,0.3,0.1,0.3,0.3V9.6z'/><path d='M10,0H3.5v1.1h6.1c0.2,0,0.3,0.1,0.3,0.3v6.1H11V1C11,0.4,10.6,0,10,0z'/></svg>",

example/index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@
3030
font-family: Arial, Helvetica, sans-serif;
3131
}
3232

33-
.cet-titlebar,
34-
.cet-titlebar>* {
35-
font-family: 'Kalam', cursive;
36-
}
33+
3734
</style>
3835
</head>
3936

example/main.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
const { app, BrowserWindow, Menu } = require('electron');
33
const path = require('path');
44
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
5+
56
// setup the titlebar main process
67
setupTitlebar();
78

8-
createWindow = () => {
9+
const createWindow = () => {
910
// Create the browser window.
1011
const mainWindow = new BrowserWindow({
1112
width: 800,
1213
height: 600,
1314
titleBarStyle: 'hidden',
1415
//frame: false, // needed if process.versions.electron < 14
1516
webPreferences: {
17+
sandbox: false,
1618
preload: path.join(__dirname, 'preload.js')
1719
}
1820
});
1921

2022
const menu = Menu.buildFromTemplate(exampleMenuTemplate());
2123
Menu.setApplicationMenu(menu);
2224

23-
24-
2525
// and load the index.html of the app.
2626
mainWindow.loadFile('index.html');
2727

2828
// Open the DevTools.
29-
// mainWindow.webContents.openDevTools()
29+
mainWindow.webContents.openDevTools()
3030

3131
//attach fullscreen(f11 and not 'maximized') && focus listeners
3232
attachTitlebarToWindow(mainWindow);
@@ -54,7 +54,7 @@ app.on('window-all-closed', function () {
5454

5555
const exampleMenuTemplate = () => [
5656
{
57-
label: "Simple Options",
57+
label: "Simple O&ptions",
5858
submenu: [
5959
{
6060
label: "Quit",
@@ -70,7 +70,7 @@ const exampleMenuTemplate = () => [
7070
type: "radio",
7171
},
7272
{
73-
label: "Checkbox1",
73+
label: "Check&box1",
7474
type: "checkbox",
7575
checked: true,
7676
click: (item) => {
@@ -79,7 +79,7 @@ const exampleMenuTemplate = () => [
7979
},
8080
{ type: "separator" },
8181
{
82-
label: "Checkbox2",
82+
label: "Che&ckbox2",
8383
type: "checkbox",
8484
checked: false,
8585
click: (item) => {
@@ -89,7 +89,7 @@ const exampleMenuTemplate = () => [
8989
]
9090
},
9191
{
92-
label: "Advanced Options",
92+
label: "A&dvanced Options",
9393
submenu: [
9494
{
9595
label: "Quit",
@@ -125,7 +125,7 @@ const exampleMenuTemplate = () => [
125125
label: "Radio Test",
126126
submenu: [
127127
{
128-
label: "Sample Checkbox",
128+
label: "S&ample Checkbox",
129129
type: "checkbox",
130130
checked: true
131131
},
@@ -178,7 +178,7 @@ const exampleMenuTemplate = () => [
178178
]
179179
},
180180
{
181-
label: "View",
181+
label: "&View",
182182
submenu: [
183183
{ role: "reload" },
184184
{ role: "forceReload" },

example/preload.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ let titlebar;
77

88
window.addEventListener('DOMContentLoaded', () => {
99
titlebar = new Titlebar({
10-
backgroundColor: Color.fromHex("#388e3c"),
11-
itemBackgroundColor: Color.fromHex("#121212"),
10+
backgroundColor: Color.fromHex("#262626"),
11+
//itemBackgroundColor: Color.fromHex("#ffffff"),
1212
svgColor: Color.WHITE,
1313
icon: path.join(__dirname, '/assets/images', '/icon.svg'),
14+
//menuPosition: 'bottom',
1415
//menu: null // = do not automatically use Menu.applicationMenu
16+
menuTransparent: 80,
1517
})
1618

1719
const replaceText = (selector, text) => {

0 commit comments

Comments
 (0)