Skip to content

Commit 44160ac

Browse files
committed
Inject platform specific style using js
1 parent 1b29479 commit 44160ac

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Diff for: index.html

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
width: 100%;
2929
display: flex;
3030
-webkit-app-region: drag;
31-
padding-left: 75px;
3231
background-color: #f8f8f8;
3332
color: #484848;
3433

Diff for: renderer.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ const path = require('electron').remote.require('path');
44
const {ipcRenderer} = require('electron');
55
const {BrowserWindow} = require('electron').remote;
66
const {clipboard} = require('electron');
7+
const { createWindow } = require('./window');
78

89
const SERVER_URL = 'https://hackmd.io';
910

10-
const isDarwin = os.platform() === 'darwin';
11+
const isMac = os.platform() === 'darwin';
1112

1213
const winOption = {
1314
width: 1024,
1415
height: 768
1516
}
1617

1718
onload = () => {
19+
/* inject mac specific styles */
20+
if (isMac) {
21+
document.querySelector('navbar').style.paddingLeft = '75px';
22+
}
23+
1824
if (window.location.search !== '') {
1925
targetURL = window.location.search.match(/\?target=([^?]+)/)[1];
2026
} else {
@@ -73,10 +79,6 @@ onload = () => {
7379

7480
/* handle _target=blank pages */
7581
webview.addEventListener('new-window', (event) => {
76-
new BrowserWindow(
77-
(isDarwin
78-
? Object.assign({}, winOption, {titleBarStyle: 'hidden'})
79-
: winOption)
80-
).loadURL(`file://${path.join(__dirname, `index.html?target=${event.url}`)}`);
82+
createWindow({url: `file://${path.join(__dirname, `index.html?target=${event.url}`)}`});
8183
});
8284
}

0 commit comments

Comments
 (0)