From c91dfd7cc27b560fd26b9fcc9ccbf4fb36ce67f0 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Tue, 27 Sep 2016 17:52:09 -0700 Subject: [PATCH] Adds rounded borders to the top corners for Windows 7. - Introduces a platformUtil helper - Top level element uses this helper to add classes for platform and release (Windows only) - removed OS detection logic in WindowCaptionButtons component - reworked styles in navigationBar.less Fixes https://github.com/brave/browser-laptop/issues/4216 Auditors: @bbondy @bridiver --- app/common/lib/platformUtil.js | 35 + .../components/windowCaptionButtons.js | 16 +- js/components/window.js | 11 +- less/navigationBar.less | 603 +++++++++--------- test/unit/lib/platformUtilTest.js | 95 +++ 5 files changed, 446 insertions(+), 314 deletions(-) create mode 100644 app/common/lib/platformUtil.js create mode 100644 test/unit/lib/platformUtilTest.js diff --git a/app/common/lib/platformUtil.js b/app/common/lib/platformUtil.js new file mode 100644 index 00000000000..0014dadc006 --- /dev/null +++ b/app/common/lib/platformUtil.js @@ -0,0 +1,35 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +'use strict' + +const os = require('os') + +/** + * Get list of styles which should be applied to root window div + * return array of strings (each being a class name) + */ +module.exports.getPlatformStyles = () => { + const platform = os.platform() + const styleList = ['platform--' + platform] + + switch (platform) { + case 'win32': + if (/6.1./.test(os.release())) { + styleList.push('win7') + } else { + styleList.push('win10') + } + } + + return styleList +} + +module.exports.isDarwin = () => { + return os.platform() === 'darwin' +} + +module.exports.isWindows = () => { + return os.platform() === 'win32' +} diff --git a/app/renderer/components/windowCaptionButtons.js b/app/renderer/components/windowCaptionButtons.js index 257ac6564ff..9d96c82bfb3 100644 --- a/app/renderer/components/windowCaptionButtons.js +++ b/app/renderer/components/windowCaptionButtons.js @@ -16,7 +16,6 @@ class WindowCaptionButtons extends ImmutableComponent { this.onMinimizeClick = this.onMinimizeClick.bind(this) this.onMaximizeClick = this.onMaximizeClick.bind(this) this.onCloseClick = this.onCloseClick.bind(this) - this.osClass = this.getPlatformCssClass() } get maximizeTitle () { @@ -25,19 +24,6 @@ class WindowCaptionButtons extends ImmutableComponent { : 'windowCaptionButtonMaximize' } - getPlatformCssClass () { - switch (os.platform()) { - case 'win32': - if (/6.1./.test(os.release())) { - return 'win7' - } else { - return 'win10' - } - default: - return 'hidden' - } - } - onMinimizeClick (e) { currentWindow.minimize() } @@ -62,7 +48,7 @@ class WindowCaptionButtons extends ImmutableComponent { fullscreen: this.props.windowMaximized, windowCaptionButtons: true })}> -
+