Skip to content

Instantly share code, notes, and snippets.

@erickzhao
Last active February 11, 2021 19:37
Show Gist options
  • Select an option

  • Save erickzhao/79ace85d406ffde26382e15e9b76f7fd to your computer and use it in GitHub Desktop.

Select an option

Save erickzhao/79ace85d406ffde26382e15e9b76f7fd to your computer and use it in GitHub Desktop.
Click me demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To-Do App</title>
</head>
<body>
<header id="titlebar">
<div id="drag-region">
<img src="images/check_icon.svg" alt="icon" id="icon">
<p id="title">to-do app</p>
<input type="image" src="images/dash.svg" alt="minimise" id="minimise_button">
<a href="#" id="exit_link">
<img src="images/cross.svg" alt="exit" id="exit_button">
</a>
</div>
</header>
<div id="main_body">
<h1 id="Title">To-do list</h1>
<button id="add_todo">+</button>
<h3 id="list_title">List</h3>
<div id="title_seperator"></div>
<h3 id="done_title">Done</h3>
</div>
<script src="renderer.js"></script>
</body>
</html>
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
function createWindow () {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
// Open the DevTools.
mainWindow.webContents.openDevTools()
}
// 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.whenReady().then(createWindow)
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
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 (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
document.getElementById('exit_link').addEventListener('click', () => {
console.log('It worked!');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment