2

I'm working on an app for Mac OSX and Windows using Electron and React. Our team of designers would like the app to have rounded borders. They want something that looks more or less like this:

The design I have to implement

I am using the following code that works fine on Mac

On my main.dev.js:

mainWindow = new BrowserWindow({
    show: false,
    width: 1024,
    height: 728,
    hasShadow: false,
    frame: false, // Important!
    transparent: true // Important!
  });

On my app.global.css:

body {
  position: relative;
  height: 100vh;
  font-family: Arial, Helvetica, Helvetica Neue, serif;
  overflow-y: hidden;
  background-color:rgba(0,0,0,0); /* Important! */
  -webkit-app-region: drag;
}

On my DisplayBar React component:

class DisplayBar extends React.Component {
  render() {
    return (
      <div style={styles.container}>
        {this.props.children}
      </div>);
  }
}

const styles = {
  container: {
    backgroundColor: '#333333',
    borderRadius: 40, // Important!
    display: 'flex',
    height: '100%',
    border: '2px solid white',
    alignItems: 'center',
    justifyContent: 'flex-end'
  }
};

As I said it works fine on Mac however, on Windows it doesn't show anything, just a transparent screen. Do you know any solution for this problem? What my code does on windows

PS: Greetings form Spain!

EDIT

I found out I have some missing dependencies problem and I have run the following command:

npm install --global --production windows-build-tools

I found it on this question.

Still I get the following error on my dev tools console:

Error on dev tools console

jpuriol
  • 332
  • 2
  • 11

1 Answers1

0

Iv looked over your code and everything looks fine apart from your CSS where you set the background to black (0, 0, 0) but you set the opacity to 0 so when you show the window it is there but the background is "invisible" because there is nothing to show.

Also I once made a window with rounded corners and ran into a problem where some corners were not rounded, I fixed this by making the window its self have a margin. This happens because when you add the border radius the border goes on the outside which in the window is out the display region so adding a margin pushes it back in.

Hope this helps you and if you run in to any problems just drop a comment.

hammy2899
  • 1,304
  • 1
  • 10
  • 19
  • I removed the `background-color:rgba(0,0,0,0);` line from the CSS and I still have the same problem. I think it has something to do with the `transparent: true` from the electron code, but I'm not sure. – jpuriol Sep 11 '17 at 09:10
  • Try adding a width to your window, the `transparent: true` isn't a problem if you have some sort of colour/element in your window which you do – hammy2899 Sep 11 '17 at 09:17
  • I'm just found out I have some problems with my packages. Maybe that's the problem. Thank you for your help! – jpuriol Sep 11 '17 at 11:39
  • I added an edit with more info on my problem. If you know anything your help will be very much appreciated @y0hami – jpuriol Sep 15 '17 at 10:40