Commit d2d0995b authored by Illia Baida's avatar Illia Baida

Prepare app

parent 47d4c0f5
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
} }
.App-logo { .App-logo {
height: 40vmin; height: 10vmin;
pointer-events: none; pointer-events: none;
} }
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
color: white; color: white;
} }
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin { @keyframes App-logo-spin {
from { from {
transform: rotate(0deg); transform: rotate(0deg);
......
import React from 'react'; import React, { useEffect, useCallback, useState, useMemo } from "react";
import logo from './logo.svg'; import logo from "./logo.svg";
import './App.css'; import "./App.css";
const Inputs = { toDecimal: "toDecimal", toRoman: "toRoman" };
function App() { function App() {
// form
const [toDecimalValue, setToDecimalValue] = useState("");
const [toRomanValue, setToRomanValue] = useState("");
const handleChange = useCallback(e => {
e.preventDefault();
const value = e.target.value.trim().toUpperCase();
if (value) {
if (e.target.name === Inputs.toDecimal) {
setToDecimalValue(value);
} else {
setToRomanValue(value);
}
}
}, []);
useEffect(() => {
console.log(toDecimalValue, toRomanValue);
}, [toDecimalValue, toRomanValue]);
// convert values
const converted = useMemo(() => {
const romanToBeConverted = toDecimalValue;
const decimalToBeConverted = toRomanValue;
return {
toDecimal: 499,
toRoman: 'CDXCIX'
};
}, [toDecimalValue, toRomanValue]);
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <header className="App-header">
<img src={logo} className="App-logo" alt="logo" /> <img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload. <h2>Converter: Roman to Decimal</h2>
</p> <input name={Inputs.toDecimal} onChange={handleChange} />
<a <span>Value is: {converted.toDecimal}</span>
className="App-link"
href="https://reactjs.org" <h2>Converter: Decimal to Roman</h2>
target="_blank" <input name={Inputs.toRoman} onChange={handleChange} />
rel="noopener noreferrer" <span>Value is: {converted.toRoman}</span>
>
Learn React
</a>
</header> </header>
</div> </div>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment