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
Show 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 @@
...
@@ -3,7 +3,7 @@
}
}
.App-logo
{
.App-logo
{
height
:
4
0vmin
;
height
:
1
0vmin
;
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
);
...
...
src/App.js
View file @
d2d0995b
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
>
);
);
...
...
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