Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4342 from bsclifton/fix-rounded-borders-win7
Browse files Browse the repository at this point in the history
Adds rounded borders to the top corners for Windows 7
  • Loading branch information
bbondy authored Oct 4, 2016
2 parents e1569c5 + c91dfd7 commit a9a3f5e
Show file tree
Hide file tree
Showing 5 changed files with 446 additions and 314 deletions.
35 changes: 35 additions & 0 deletions app/common/lib/platformUtil.js
Original file line number Diff line number Diff line change
@@ -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'
}
16 changes: 1 addition & 15 deletions app/renderer/components/windowCaptionButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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()
}
Expand All @@ -62,7 +48,7 @@ class WindowCaptionButtons extends ImmutableComponent {
fullscreen: this.props.windowMaximized,
windowCaptionButtons: true
})}>
<div className={'container ' + this.osClass}>
<div className='container'>
<button
className={cx({
fullscreen: this.props.windowMaximized,
Expand Down
11 changes: 6 additions & 5 deletions js/components/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const windowActions = require('../actions/windowActions')
const Main = require('./main')
const SiteTags = require('../constants/siteTags')
const config = require('../constants/config')
const cx = require('../lib/classSet.js')
const cx = require('../lib/classSet')
const { getPlatformStyles } = require('../../app/common/lib/platformUtil')

class Window extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -55,10 +56,10 @@ class Window extends React.Component {
let classes = {}
classes['windowContainer'] = true

// Possible values for process.platform are:
// darwin, freebsd, linux, sunos, win32
// https://nodejs.org/api/process.html#process_process_platform
classes['platform--' + process.platform] = true
const platformClasses = getPlatformStyles()
platformClasses.forEach((className) => {
classes[className] = true
})

return <div id='windowContainer' className={cx(classes)} >
<Main windowState={this.state.immutableData.windowState}
Expand Down
Loading

0 comments on commit a9a3f5e

Please sign in to comment.