Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
roman-numerals-converter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Illia Baida
roman-numerals-converter
Commits
d2d0995b
Commit
d2d0995b
authored
Mar 30, 2020
by
Illia Baida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare app
parent
47d4c0f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
19 deletions
+44
-19
package-lock.json
package-lock.json
+0
-0
App.css
src/App.css
+1
-5
App.js
src/App.js
+43
-14
No files found.
package-lock.json
0 → 100644
View file @
d2d0995b
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/App.css
View file @
d2d0995b
...
...
@@ -3,7 +3,7 @@
}
.App-logo
{
height
:
4
0vmin
;
height
:
1
0vmin
;
pointer-events
:
none
;
}
...
...
@@ -24,10 +24,6 @@
color
:
white
;
}
.App-link
{
color
:
#61dafb
;
}
@keyframes
App-logo-spin
{
from
{
transform
:
rotate
(
0deg
);
...
...
src/App.js
View file @
d2d0995b
import
React
from
'react'
;
import
logo
from
'./logo.svg'
;
import
'./App.css'
;
import
React
,
{
useEffect
,
useCallback
,
useState
,
useMemo
}
from
"react"
;
import
logo
from
"./logo.svg"
;
import
"./App.css"
;
const
Inputs
=
{
toDecimal
:
"toDecimal"
,
toRoman
:
"toRoman"
};
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
(
<
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
>
<
h2
>
Converter
:
Roman
to
Decimal
<
/h2
>
<
input
name
=
{
Inputs
.
toDecimal
}
onChange
=
{
handleChange
}
/
>
<
span
>
Value
is
:
{
converted
.
toDecimal
}
<
/span
>
<
h2
>
Converter
:
Decimal
to
Roman
<
/h2
>
<
input
name
=
{
Inputs
.
toRoman
}
onChange
=
{
handleChange
}
/
>
<
span
>
Value
is
:
{
converted
.
toRoman
}
<
/span
>
<
/header
>
<
/div
>
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment