Skip to content

Commit

Permalink
Basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Oct 26, 2018
1 parent 419ca29 commit 0358aa0
Show file tree
Hide file tree
Showing 6 changed files with 376 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
11 changes: 1 addition & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
"name": "pennywise",
"version": "0.1.0",
"private": true,
"main": "src/electron/index.js",
"homepage": "./",
"dependencies": {
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-scripts": "2.0.5"
},
"scripts": {
"start": "react-scripts start",
"react": "cross-env BROWSER=none react-scripts start",
"electron": "cross-env APP_URL=http://localhost:3000 electron .",
"start": "concurrently \"yarn react\" \"wait-on http://localhost:3000 && yarn electron\" ",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand All @@ -21,5 +25,11 @@
"not dead",
"not ie <= 11",
"not op_mini all"
]
],
"devDependencies": {
"concurrently": "^4.0.1",
"cross-env": "^5.2.0",
"electron": "^3.0.6",
"wait-on": "^3.1.0"
}
}
File renamed without changes.
51 changes: 51 additions & 0 deletions src/electron/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { app, BrowserWindow } = require('electron');
const url = require('url');
const path = require('path');


// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

function createWindow() {
mainWindow = new BrowserWindow({ width: 800, height: 600 });

console.log(process.env.APP_URL);
const appUrl = process.env.APP_URL || url.format({
protocol: 'file',
slashes: true,
pathname: path.join(__dirname, 'index.html')
});

mainWindow.loadURL('http://localhost:3000');

// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
Loading

0 comments on commit 0358aa0

Please sign in to comment.