mirror of
https://github.com/kremalicious/hyper-mac-pro.git
synced 2024-11-22 01:37:13 +01:00
Matthias Kretschmann
346cd18db8
* css variables dont work for whatever reason so move to css in js only
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
const styles = require('./styles')
|
|
|
|
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)
|
|
}
|
|
|
|
// Fullscreen & blur/focus body classes
|
|
module.exports.onWindow = browserWindow => {
|
|
const enterFullscreen = () => {
|
|
document.body.classList.add('fullscreen')
|
|
}
|
|
|
|
const leaveFullscreen = () => {
|
|
document.body.classList.remove('fullscreen')
|
|
}
|
|
|
|
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
|
|
}
|