2018-07-09 16:43:28 +02:00
|
|
|
const styles = require('./styles')
|
2017-05-10 01:55:44 +02:00
|
|
|
|
|
|
|
exports.decorateConfig = config => Object.assign({}, config, {
|
|
|
|
css: (config.css || '') + styles
|
|
|
|
})
|
|
|
|
|
|
|
|
// Fix native fullscreen titlebar
|
|
|
|
exports.decorateBrowserOptions = defaults => Object.assign({}, defaults, {
|
|
|
|
transparent: false
|
|
|
|
})
|
|
|
|
|
|
|
|
// Tabs/no tabs body class
|
|
|
|
exports.getTabsProps = (parentProps, props) => {
|
|
|
|
const bodyClasses = document.body.classList
|
|
|
|
|
|
|
|
if (props.tabs.length <= 1) {
|
|
|
|
bodyClasses.add('no-tabs')
|
|
|
|
} else {
|
|
|
|
bodyClasses.remove('no-tabs')
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object.assign({}, parentProps, props)
|
|
|
|
}
|
|
|
|
|
2017-05-16 00:28:24 +02:00
|
|
|
// Fullscreen & blur/focus body classes
|
|
|
|
module.exports.onWindow = browserWindow => {
|
|
|
|
const enterFullscreen = () => {
|
|
|
|
document.body.classList.add('fullscreen')
|
|
|
|
}
|
2017-05-10 01:55:44 +02:00
|
|
|
|
2017-05-16 00:28:24 +02:00
|
|
|
const leaveFullscreen = () => {
|
|
|
|
document.body.classList.remove('fullscreen')
|
2017-05-10 01:55:44 +02:00
|
|
|
}
|
|
|
|
|
2017-05-16 00:28:24 +02:00
|
|
|
const onBlur = () => {
|
|
|
|
document.body.classList.add('blur')
|
|
|
|
}
|
|
|
|
|
|
|
|
const onFocus = () => {
|
|
|
|
document.body.classList.remove('blur')
|
|
|
|
}
|
|
|
|
|
|
|
|
browserWindow.on('enter-full-screen', () => {
|
|
|
|
browserWindow.webContents.executeJavaScript(`(${enterFullscreen.toString()})();`)
|
|
|
|
})
|
|
|
|
|
|
|
|
browserWindow.on('leave-full-screen', () => {
|
|
|
|
browserWindow.webContents.executeJavaScript(`(${leaveFullscreen.toString()})();`)
|
|
|
|
})
|
|
|
|
|
|
|
|
browserWindow.on('blur', () => {
|
|
|
|
browserWindow.webContents.executeJavaScript(`(${onBlur.toString()})();`)
|
|
|
|
})
|
|
|
|
|
|
|
|
browserWindow.on('focus', () => {
|
|
|
|
browserWindow.webContents.executeJavaScript(`(${onFocus.toString()})();`)
|
|
|
|
})
|
|
|
|
|
|
|
|
return browserWindow
|
2017-05-10 01:55:44 +02:00
|
|
|
}
|