From 81c422d4e0a073b5633e5d8c974e07d807c7d946 Mon Sep 17 00:00:00 2001 From: Umair Ahmed <30743917+ahmedu007@users.noreply.github.com> Date: Thu, 22 Aug 2019 20:25:58 +0100 Subject: [PATCH] Support setting background color (fixes #795) (PR #819) Adds a `--background-color` flag for the background of the window when the app isn't loaded. --- app/src/components/mainWindow/mainWindow.js | 1 + docs/api.md | 9 +++++++++ src/build/buildApp.js | 2 ++ src/cli.js | 4 ++++ src/options/optionsMain.js | 1 + 5 files changed, 17 insertions(+) diff --git a/app/src/components/mainWindow/mainWindow.js b/app/src/components/mainWindow/mainWindow.js index 3473242..d0fe1ca 100644 --- a/app/src/components/mainWindow/mainWindow.js +++ b/app/src/components/mainWindow/mainWindow.js @@ -125,6 +125,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) { alwaysOnTop: options.alwaysOnTop, titleBarStyle: options.titleBarStyle, show: options.tray !== 'start-in-tray', + backgroundColor: options.backgroundColor, }, DEFAULT_WINDOW_OPTIONS, ), diff --git a/docs/api.md b/docs/api.md index ea1cecc..aa964fe 100644 --- a/docs/api.md +++ b/docs/api.md @@ -65,6 +65,7 @@ - [[always-on-top]](#always-on-top) - [[global-shortcuts]](#global-shortcuts) - [[darwin-dark-mode-support]](#darwin-dark-mode-support) + - [[background-color]](#background-color) - [Programmatic API](#programmatic-api) - [Addition packaging options for Windows](#addition-packaging-options-for-windows) - [[version-string]](#version-string) @@ -703,6 +704,14 @@ Example `shortcuts.json` for `https://deezer.com` & `https://soundcloud.com` to Enables Dark Mode support on macOS 10.4+. +#### [background-color] + +``` +--background-color +``` + +See https://electronjs.org/docs/api/browser-window#setting-backgroundcolor + ## Programmatic API You can use the Nativefier programmatic API as well. diff --git a/src/build/buildApp.js b/src/build/buildApp.js index 42db474..078846e 100644 --- a/src/build/buildApp.js +++ b/src/build/buildApp.js @@ -58,6 +58,7 @@ function selectAppArgs(options) { alwaysOnTop: options.alwaysOnTop, titleBarStyle: options.titleBarStyle, globalShortcuts: options.globalShortcuts, + backgroundColor: options.backgroundColor, darwinDarkModeSupport: options.darwinDarkModeSupport, }; } @@ -134,6 +135,7 @@ function changeAppPackageJsonName(appPath, name, url) { */ function buildApp(src, dest, options, callback) { const appArgs = selectAppArgs(options); + copy(src, dest, (error) => { if (error) { callback(`Error Copying temporary directory: ${error}`); diff --git a/src/cli.js b/src/cli.js index 80ccbf4..2a6f29d 100755 --- a/src/cli.js +++ b/src/cli.js @@ -238,6 +238,10 @@ if (require.main === module) { '--global-shortcuts ', 'JSON file with global shortcut configuration. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#global-shortcuts', ) + .option( + '--background-color ', + "Sets the background color (for seamless experience while the app is loading). Example value: '#2e2c29'", + ) .option( '--darwin-dark-mode-support', '(macOS only) enable Dark Mode support on macOS 10.14+', diff --git a/src/options/optionsMain.js b/src/options/optionsMain.js index 7b5730e..429b297 100644 --- a/src/options/optionsMain.js +++ b/src/options/optionsMain.js @@ -77,6 +77,7 @@ export default function(inpOptions) { alwaysOnTop: inpOptions.alwaysOnTop || false, titleBarStyle: inpOptions.titleBarStyle || null, globalShortcuts: inpOptions.globalShortcuts || null, + backgroundColor: inpOptions.backgroundColor || null, darwinDarkModeSupport: inpOptions.darwinDarkModeSupport || false, };