Skip to content

Commit

Permalink
Fix latest version of Hyper
Browse files Browse the repository at this point in the history
  • Loading branch information
krve committed Jan 10, 2022
1 parent 27a3d2b commit 52d7801
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ module.exports = {
```

### Changelog
**1.2.0**
- Fixed issue with latest version of HyperJS

**1.1.2**
- Add flipped versions again (see config option above)

Expand Down
28 changes: 6 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const isWin = process.platform === 'win32';
const remote = require('electron').remote;
let dirname = __dirname;

if (isWin == true) {
Expand Down Expand Up @@ -93,30 +92,19 @@ exports.decorateHeader = (Hyper, { React }) => {
super(props);

this.state = {
window: null,
maximized: false
}

this.closeApp = this.closeApp.bind(this);
this.minimizeApp = this.minimizeApp.bind(this);
this.props = props;
this.maximizeApp = this.maximizeApp.bind(this);
}

closeApp() {
this.state.window.close();
}

minimizeApp() {
this.state.window.minimize();
this.state.maximized = false;
}

maximizeApp() {
if (this.state.maximized == true) {
this.state.window.unmaximize();
this.props.unmaximize()
this.state.maximized = false;
} else {
this.state.window.maximize();
this.props.maximize()
this.state.maximized = true;
}
}
Expand All @@ -126,17 +114,13 @@ exports.decorateHeader = (Hyper, { React }) => {
React.createElement(Hyper, Object.assign({}, this.props, {
customChildren: React.createElement('div', { className: 'mac_header' },
React.createElement('div', { className: 'mac_actions' },
React.createElement('span', { className: 'mac_close', onClick: this.closeApp }),
React.createElement('span', { className: 'mac_minimize', onClick: this.minimizeApp }),
React.createElement('span', { className: 'mac_close', onClick: this.props.close }),
React.createElement('span', { className: 'mac_minimize', onClick: this.props.minimize }),
React.createElement('span', { className: 'mac_maximize', onClick: this.maximizeApp })
)
)
),
}))
)
}

componentDidMount() {
this.state.window = remote.getCurrentWindow();
}
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hyper-mac-controls",
"version": "1.1.2",
"version": "1.2.0",
"description": "Hyper mac-like window controls on linux or windows",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 52d7801

Please sign in to comment.