This commit is contained in:
Nicola Zambello 2020-01-10 09:44:48 +01:00
parent d52300c681
commit 635c210c73
3 changed files with 36 additions and 40 deletions

1
.env Normal file
View file

@ -0,0 +1 @@
INLINE_RUNTIME_CHUNK=false

View file

@ -1,25 +1,14 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
"manifest_version": 2,
"version": "1.0",
"name": "Convert time to h",
"icons": {
"192": "logo192.png",
"512": "logo512.png"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
"browser_action": {
"default_icon": "logo192.png",
"default_title": "Converttime",
"default_popup": "index.html"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View file

@ -1,24 +1,30 @@
import React from 'react';
import logo from './logo.svg';
import React, {useState} from 'react';
import './App.css';
function App() {
const parseTime = time => {
const parsed = parseInt(time, 10);
if (isNaN(parsed)) return 0;
return parsed;
};
const App = () => {
const [hours, setHours] = useState(0)
const [minutes, setMinutes] = useState(0)
const [seconds, setSeconds] = useState(0)
const result = hours + minutes / 60 + seconds / (60 * 60)
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<div>
<input id="hours" type="text" value={hours} onChange={e => setHours(parseTime(e.target.value, 10))} />
<input id="minutes" type="text" value={minutes} onChange={e => setMinutes(parseTime(e.target.value, 10))} />
<input id="seconds" type="text" value={seconds} onChange={e => setSeconds(parseTime(e.target.value, 10))} />
</div>
<br />
<div>
<pre>{result} h</pre>
</div>
</div>
);
}