Created
August 13, 2018 18:49
-
-
Save bloqhead/5b2988ea86b5e5c3ebd35f578a671169 to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Time -> Decimal</title> | |
<style type="text/css"> | |
*, *:before, *:after { | |
box-sizing: border-box; | |
} | |
html, body { | |
width: 100%; | |
height: 100vh; | |
margin: 0; | |
overflow: hidden; | |
} | |
body { | |
background: linear-gradient(#358495, #b2dbe4); | |
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
form { | |
display: flex; | |
flex-direction: row; | |
flex-wrap: wrap; | |
justify-content: center; | |
align-items: center; | |
padding: 20px; | |
} | |
form input { | |
display: block; | |
width: 100%; | |
border: 0; | |
padding: 10px; | |
text-align: center; | |
background: #fff; | |
border-radius: 5px; | |
transition: background 300ms ease-in-out; | |
outline: 0; | |
font-size: 18px !important; | |
} | |
form input:focus { | |
background-color: palegreen; | |
} | |
form .col:nth-of-type(1) { | |
margin-right: 15px; | |
flex: 0 0 50%; | |
} | |
form .col:nth-of-type(2) { | |
flex: 0 0 calc(50% - 15px); | |
} | |
form .col:nth-of-type(3) { | |
flex: 0 0 100%; | |
margin: 1rem 0 0 0; | |
} | |
</style> | |
</head> | |
<body> | |
<form> | |
<div class='col'> | |
<input autofocus='autofocus' class='hours' placeholder='Hours' type='number'> | |
</div> | |
<div class='col'> | |
<input class='minutes' placeholder='Minutes' type='number'> | |
</div> | |
<div class='col'> | |
<input class='output' placeholder='Result' type='number'> | |
</div> | |
</form> | |
<script> | |
require('./renderer.js') | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, BrowserWindow } = require('electron') | |
let mainWindow | |
function createWindow () { | |
mainWindow = new BrowserWindow({ | |
width: 500, | |
height: 160 | |
}) | |
mainWindow.loadFile('index.html') | |
// open DevTools on load (make sure your window size is not too small) | |
// mainWindow.webContents.openDevTools() | |
// Emitted when the window is closed. | |
mainWindow.on('closed', function () { | |
mainWindow = null | |
}) | |
} | |
app.on('ready', createWindow) | |
// Quit when all windows are closed. | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}) | |
app.on('activate', function () { | |
if (mainWindow === null) { | |
createWindow() | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TimeCalc = function() { | |
const hours = document.querySelector('.hours'); | |
const minutes = document.querySelector('.minutes'); | |
const final = document.querySelector('.output'); | |
// run the calculation on minute and hour keyup | |
[hours, minutes].forEach(input => input.addEventListener( 'keyup', () => { | |
const hval = parseFloat(hours.value) || 0; | |
const mval = parseFloat(minutes.value) || 0; | |
const result = ( hval + mval / 60 ).toFixed(2); | |
final.value = result; | |
})); | |
} | |
TimeCalc(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment