Skip to content

Commit d023963

Browse files
authored
Merge pull request #520 from onkofonko/master
feat: Introduce custom title bar
2 parents 95e0274 + adeb19c commit d023963

File tree

3 files changed

+40
-26
lines changed

3 files changed

+40
-26
lines changed

common/components/Menubar.svelte

+33-19
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@
2525
<img src='./logo_filled.png' class='position-absolute w-50 h-50 m-10 pointer d-md-block d-none p-5' alt='ico' use:click={close} />
2626
{/if}
2727
</div>
28-
<div class='h-full bg-dark flex-grow-1'>
29-
{#if window.version?.platform === 'linux'}
30-
<div class='d-flex align-items-center close h-full' use:click={() => IPC.emit('close')}>
31-
<svg viewBox='0 0 24 24'>
32-
<path d='M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z' />
33-
</svg>
34-
</div>
35-
{/if}
28+
<div class='window-controls d-flex position-absolute top-0 right-0 height-full'>
29+
<button class='button max-button d-flex border-0 color-white align-items-center justify-content-center' on:click={() => IPC.emit('minimize')}><svg class='svg-controls' height='12' role='img' viewBox='0 0 12 12'width='12'><rect fill='currentColor' height='1' width='10' x='1' y='6' /></svg></button>
30+
<button class='button restore-button d-flex border-0 color-white align-items-center justify-content-center' on:click={() => IPC.emit('maximize')}><svg class='svg-controls' height='12' role='img' viewBox='0 0 12 12'width='12'><rect fill='none' height='9' stroke='currentColor' width='9' x='1.5' y='1.5' /></svg></button>
31+
<button class='button close-button d-flex border-0 color-white align-items-center justify-content-center' on:click={() => IPC.emit('close')}><svg class='svg-controls' height='12' role='img' viewBox='0 0 12 12'width='12'><polygon fill='currentColor' fill-rule='evenodd' points='11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1' /></svg></button>
3632
</div>
3733
</div>
3834
{#if $debug}
@@ -51,7 +47,7 @@
5147
transform: translate(-29.3%) rotate(-45deg);
5248
}
5349
.navbar {
54-
--navbar-height: 28px !important;
50+
--navbar-height: 32px !important;
5551
}
5652
.z-101 {
5753
z-index: 101 !important
@@ -66,27 +62,45 @@
6662
top: 0;
6763
-webkit-app-region: no-drag
6864
}
69-
.close {
70-
width: 40px;
71-
}
72-
.close:hover {
73-
background-color: #e81123 !important;
74-
}
7565
svg {
7666
width: 18px;
7767
height: 18px;
7868
width: 100%;
7969
}
80-
path {
81-
fill: currentColor;
82-
}
8370
.navbar {
84-
left: unset !important
71+
left: unset !important;
8572
}
8673
@media (pointer: none), (pointer: coarse) {
8774
.navbar {
8875
display: none !important;
8976
height: 0;
9077
}
9178
}
79+
.window-controls {
80+
-webkit-app-region: no-drag;
81+
backdrop-filter: blur(8px);
82+
background: rgba(24, 24, 24, 0.1);
83+
}
84+
.window-controls .button {
85+
background: transparent;
86+
width: 46px;
87+
height: 32px;
88+
user-select: none;
89+
}
90+
.window-controls .button:hover {
91+
background: rgba(128, 128, 128, 0.2);
92+
}
93+
.window-controls .button:active {
94+
background: rgba(128, 128, 128, 0.4);
95+
}
96+
.close-button:hover {
97+
background: #e81123 !important;
98+
}
99+
.close-button:active {
100+
background: #f1707a !important;
101+
}
102+
.svg-controls {
103+
width: 12px;
104+
height: 12px;
105+
}
92106
</style>

electron/src/main/app.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ export default class App {
2929
height: 900,
3030
frame: process.platform === 'darwin', // Only keep the native frame on Mac
3131
titleBarStyle: 'hidden',
32-
titleBarOverlay: {
33-
color: '#17191c',
34-
symbolColor: '#eee',
35-
height: 28
36-
},
3732
backgroundColor: '#17191c',
3833
autoHideMenuBar: true,
3934
webPreferences: {
@@ -65,6 +60,11 @@ export default class App {
6560
this.mainWindow.on('closed', () => this.destroy())
6661
this.webtorrentWindow.on('closed', () => this.destroy())
6762
ipcMain.on('close', () => this.destroy())
63+
ipcMain.on('minimize', () => this.mainWindow?.minimize())
64+
ipcMain.on('maximize', () => {
65+
const focusedWindow = this.mainWindow
66+
focusedWindow?.isMaximized() ? focusedWindow.unmaximize() : focusedWindow.maximize()
67+
});
6868
app.on('before-quit', e => {
6969
if (this.destroyed) return
7070
e.preventDefault()
@@ -158,4 +158,4 @@ export default class App {
158158
this.destroyed = true
159159
if (!this.updater.install(forceRunAfter)) app.quit()
160160
}
161-
}
161+
}

electron/src/preload/preload.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ ipcRenderer.once('port', ({ ports }) => {
2929
ports[0].postMessage(a, b)
3030
}
3131
})
32-
})
32+
})

0 commit comments

Comments
 (0)