first
23
.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
46
README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
16632
package-lock.json
generated
Normal file
53
package.json
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "cryptocurrency-converter",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://vbatischev1.github.io/crypto-converter",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^5.0.0-beta.9",
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^16.18.39",
|
||||
"@types/react": "^18.2.18",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"axios": "^1.4.0",
|
||||
"crypto-convert": "^2.1.5",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"sass": "^1.64.2",
|
||||
"typescript": "^4.9.5",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"predeploy": "npm run build",
|
||||
"deploy": "gh-pages -d build",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"gh-pages": "^5.0.0"
|
||||
}
|
||||
}
|
BIN
public/favicon.ico
Normal file
After Width: | Height: | Size: 3.8 KiB |
43
public/index.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Crypto Converter</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
BIN
public/logo192.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
public/logo512.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
25
public/manifest.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
3
public/robots.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
3
src/App.scss
Normal file
@ -0,0 +1,3 @@
|
||||
body {
|
||||
background: #e5e5e5;
|
||||
}
|
8
src/App.test.tsx
Normal file
@ -0,0 +1,8 @@
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import App from './App'
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />)
|
||||
const linkElement = screen.getByText(/learn react/i)
|
||||
expect(linkElement).toBeInTheDocument()
|
||||
})
|
9
src/App.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import { Converter } from './Components/Converter/Converter'
|
||||
|
||||
import './App.scss'
|
||||
|
||||
function App() {
|
||||
return <Converter />
|
||||
}
|
||||
|
||||
export default App
|
111
src/Components/Converter/Converter.scss
Normal file
@ -0,0 +1,111 @@
|
||||
.converter {
|
||||
max-width: 640px;
|
||||
margin: 50px auto;
|
||||
background: #fff;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
|
||||
&__head {
|
||||
font-weight: 700;
|
||||
font-size: 25px;
|
||||
text-align: center;
|
||||
margin: 0 0 50px 0;
|
||||
}
|
||||
|
||||
&__body {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 0 0 25px 0;
|
||||
justify-content: center;
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
border-radius: 10px;
|
||||
height: 100%;
|
||||
font-size: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
justify-content: center;
|
||||
@media (max-width: 908px) {
|
||||
font-size: 20px;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
font-size: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
&__crypto-name {
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
line-height: 15px;
|
||||
justify-content: center;
|
||||
padding: 0 15px;
|
||||
font-weight: 700;
|
||||
border: 2px solid rgba(7, 28, 71, 0.12);
|
||||
border-left: none;
|
||||
border-radius: 0 10px 10px 0;
|
||||
gap: 5px;
|
||||
&-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
&__crypto-icon {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
&__arrow {
|
||||
height: 35px;
|
||||
object-fit: contain;
|
||||
cursor: pointer;
|
||||
width: 20px;
|
||||
background: #999;
|
||||
-webkit-mask: url(//yastatic.net/s3/web4static/_/v2/static/media/Swap_16.c0236c02.svg)
|
||||
no-repeat center;
|
||||
mask: url(//yastatic.net/s3/web4static/_/v2/static/media/Swap_16.c0236c02.svg)
|
||||
no-repeat center;
|
||||
}
|
||||
|
||||
&__input {
|
||||
border: 2px solid rgba(7, 28, 71, 0.12);
|
||||
border-radius: 10px 0 0 10px;
|
||||
height: 100%;
|
||||
font-family: HelveticaNeue-Light, 'Helvetica Neue Light', Helvetica, Arial,
|
||||
sans-serif;
|
||||
font-size: inherit;
|
||||
text-align: right;
|
||||
width: 201px;
|
||||
color: #000;
|
||||
position: relative;
|
||||
top: 0;
|
||||
padding: 0 10px 0 0;
|
||||
outline: none;
|
||||
@media (max-width: 768px) {
|
||||
height: 38px;
|
||||
}
|
||||
}
|
||||
&__footer {
|
||||
font-size: 14px;
|
||||
}
|
||||
&__title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
108
src/Components/Converter/Converter.tsx
Normal file
@ -0,0 +1,108 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { IValutions } from '../../models/IValutions'
|
||||
import { valuations } from '../../utils/Constants'
|
||||
import { ConverterInput } from './ConverterInput/ConverterInput'
|
||||
import { actualDate, getRelationToCurrency } from '../../utils/HelperFunctions'
|
||||
|
||||
import './Converter.scss'
|
||||
|
||||
export const Converter = () => {
|
||||
const [isFocus, setFocus] = useState<1 | 2>(1)
|
||||
const [firstValue, setFirstValue] = useState<string>('1')
|
||||
const [secondValue, setSecondValue] = useState<string>('1')
|
||||
const [firstValuation, setFirstValuation] = useState<IValutions>(
|
||||
valuations[0]
|
||||
)
|
||||
const [secondValuation, setSecondValuation] = useState<IValutions>(
|
||||
valuations[1]
|
||||
)
|
||||
|
||||
const swap = () => {
|
||||
setSecondValuation(firstValuation)
|
||||
setFirstValuation(secondValuation)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isFocus === 1) {
|
||||
getRelationToCurrency(
|
||||
firstValuation.title,
|
||||
secondValuation.title,
|
||||
+firstValue,
|
||||
setSecondValue
|
||||
)
|
||||
} else if (isFocus === 2) {
|
||||
getRelationToCurrency(
|
||||
secondValuation.title,
|
||||
firstValuation.title,
|
||||
+secondValue,
|
||||
setFirstValue
|
||||
)
|
||||
}
|
||||
}, [isFocus, firstValue, firstValuation, secondValue, secondValuation])
|
||||
|
||||
useEffect(() => {
|
||||
if (firstValuation.title === secondValuation.title) {
|
||||
let index = valuations.findIndex(
|
||||
(item) => item.title !== firstValuation.title
|
||||
)
|
||||
setSecondValuation(valuations[index])
|
||||
}
|
||||
}, [firstValuation])
|
||||
|
||||
useEffect(() => {
|
||||
if (secondValuation.title === firstValuation.title) {
|
||||
let index = valuations.findIndex(
|
||||
(item) => item.title !== secondValuation.title
|
||||
)
|
||||
setFirstValuation(valuations[index])
|
||||
}
|
||||
}, [secondValuation])
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
getRelationToCurrency(
|
||||
firstValuation.title,
|
||||
secondValuation.title,
|
||||
+firstValue,
|
||||
setSecondValue
|
||||
)
|
||||
}, 25000)
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
|
||||
const outputResult = () =>
|
||||
`${firstValue || 0} ${firstValuation.title} = ${secondValue || 0} ${
|
||||
secondValuation.title
|
||||
}`
|
||||
|
||||
return (
|
||||
<div className='converter'>
|
||||
<div className='converter__body'>
|
||||
<ConverterInput
|
||||
valuation={firstValuation}
|
||||
value={firstValue}
|
||||
setValuation={setFirstValuation}
|
||||
setValue={setFirstValue}
|
||||
index={1}
|
||||
setFocus={setFocus}
|
||||
/>
|
||||
<div className='converter__row'>
|
||||
<div className={'converter__arrow'} onClick={swap} />
|
||||
</div>
|
||||
<ConverterInput
|
||||
valuation={secondValuation}
|
||||
value={secondValue}
|
||||
setValuation={setSecondValuation}
|
||||
setValue={setSecondValue}
|
||||
index={2}
|
||||
setFocus={setFocus}
|
||||
/>
|
||||
</div>
|
||||
<footer className='converter__footer'>
|
||||
<div className='converter__title'>{outputResult()}</div>
|
||||
Данные носят ознакомительный характер · {'\t'}
|
||||
<b>{actualDate()}</b>
|
||||
</footer>
|
||||
</div>
|
||||
)
|
||||
}
|
87
src/Components/Converter/ConverterInput/ConverterInput.tsx
Normal file
@ -0,0 +1,87 @@
|
||||
import { ChangeEvent, Dispatch, FC, useEffect, useRef, useState } from 'react'
|
||||
import { ConverterPopup } from '../ConverterPopup/ConverterPopup'
|
||||
import arrowDoubleVertical from '../../../assets/images/arrow-double-vertical.svg'
|
||||
import { IValutions } from '../../../models/IValutions'
|
||||
import { valuations } from '../../../utils/Constants'
|
||||
import useOnClickOutside from '../../../hooks/useOnClickOutside'
|
||||
import { regexInput } from '../../../utils/HelperFunctions'
|
||||
|
||||
interface IConverterInput {
|
||||
index: 1 | 2
|
||||
value: string
|
||||
setValue: Dispatch<string>
|
||||
valuation: IValutions
|
||||
setValuation: Dispatch<IValutions>
|
||||
setFocus: Dispatch<1 | 2>
|
||||
}
|
||||
|
||||
export const ConverterInput: FC<IConverterInput> = ({
|
||||
index,
|
||||
setValue,
|
||||
value,
|
||||
valuation,
|
||||
setValuation,
|
||||
setFocus
|
||||
}) => {
|
||||
const [showPopup, setShowPopup] = useState<boolean>()
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
const handlerInput = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
regexInput(e)
|
||||
setValue(e.target.value)
|
||||
}
|
||||
|
||||
useOnClickOutside(ref, () => {
|
||||
setShowPopup(false)
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
setShowPopup(false)
|
||||
}, [valuation])
|
||||
|
||||
return (
|
||||
<div className='converter__row converter__row_border'>
|
||||
<input
|
||||
className='converter__input'
|
||||
type='text'
|
||||
maxLength={20}
|
||||
value={value}
|
||||
onFocus={() => setFocus(index)}
|
||||
onChange={handlerInput}
|
||||
/>
|
||||
<span
|
||||
className='converter__crypto-name'
|
||||
onClick={() => setShowPopup((prev) => !prev)}
|
||||
>
|
||||
<div className={'converter__crypto-name-title'}>
|
||||
<img
|
||||
src={valuation.img}
|
||||
alt=''
|
||||
className={'converter__crypto-icon'}
|
||||
/>
|
||||
{valuation.title}
|
||||
</div>
|
||||
<div>
|
||||
<img
|
||||
src={arrowDoubleVertical}
|
||||
alt=''
|
||||
className={'converter__crypto-name-arrow'}
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
{showPopup && (
|
||||
<div className='converter-popup' ref={ref}>
|
||||
{valuations.map((item, index) => (
|
||||
<ConverterPopup
|
||||
key={index}
|
||||
item={item}
|
||||
valuation={valuation}
|
||||
setValuation={setValuation}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
56
src/Components/Converter/ConverterPopup/ConverterPopup.scss
Normal file
@ -0,0 +1,56 @@
|
||||
.converter-popup {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
inset: 75px auto auto 0;
|
||||
width: 100%;
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 0;
|
||||
border-radius: 5px;
|
||||
&__container {
|
||||
padding: 4px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
background: #ffeca1;
|
||||
}
|
||||
}
|
||||
&__check {
|
||||
display: flex;
|
||||
flex: 0 0 16px;
|
||||
}
|
||||
&__body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
&__img {
|
||||
flex: 0 0 20px;
|
||||
height: 20px;
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
&__button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: transparent;
|
||||
transition: 0.3s all ease;
|
||||
// padding: 10px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
span {
|
||||
margin: 0 4px;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: rgba(84, 96, 122, 0.68);
|
||||
}
|
||||
}
|
||||
}
|
36
src/Components/Converter/ConverterPopup/ConverterPopup.tsx
Normal file
@ -0,0 +1,36 @@
|
||||
import { FC, MouseEvent } from 'react'
|
||||
import { IListValuationsName } from '../../../models/IListValutionsName'
|
||||
import checkIcon from '../../../assets/images/check.svg'
|
||||
|
||||
import './ConverterPopup.scss'
|
||||
|
||||
export const ConverterPopup: FC<IListValuationsName> = ({
|
||||
item,
|
||||
valuation,
|
||||
setValuation
|
||||
}) => {
|
||||
const setActiveValuation = (e: MouseEvent<HTMLDivElement>) => {
|
||||
setValuation({
|
||||
img: item.img,
|
||||
title: item.title
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={'converter-popup__container'} onClick={setActiveValuation}>
|
||||
<div className={'converter-popup__check'}>
|
||||
{valuation.title === item.title && <img src={checkIcon} alt='check' />}
|
||||
</div>
|
||||
<div className={'converter-popup__body'}>
|
||||
<img src={item.img} alt='' className={'converter-popup__img'} />
|
||||
<button
|
||||
type='button'
|
||||
className={'converter-popup__button'}
|
||||
value={item.title}
|
||||
>
|
||||
{item.title} <span>{item.alt}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
8
src/assets/images/arrow-double-vertical.svg
Normal file
@ -0,0 +1,8 @@
|
||||
<svg
|
||||
focusable='false'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='8'
|
||||
height='14'
|
||||
>
|
||||
<path d='M4 0l4 6H0l4-6zm0 14l4-6H0l4 6z'/>
|
||||
</svg>
|
After Width: | Height: | Size: 175 B |
19
src/assets/images/arrow-right-left.svg
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 -1 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<title>arrow_right_left [#343]</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Dribbble-Light-Preview" transform="translate(-420.000000, -6640.000000)" fill="#000000">
|
||||
<g id="icons" transform="translate(56.000000, 160.000000)">
|
||||
<path d="M369.152,6496.32302 L367.74,6494.843 C367.438,6494.52378 367.664,6494.00943 368.103,6494.00943 L383,6494.00943 C383.552,6494.00943 384,6493.55012 384,6492.99774 L384,6493.00374 C384,6492.45036 383.552,6492.00806 383,6492.00806 L368.118,6492.00806 C367.677,6492.00806 367.452,6491.46669 367.758,6491.14947 L369.162,6489.68947 C369.542,6489.2902 369.525,6488.65476 369.122,6488.27851 L369.12,6488.2745 C368.722,6487.90125 368.098,6487.92026 367.723,6488.31753 L364.546,6491.65782 C363.815,6492.43135 363.819,6493.64218 364.553,6494.41271 L367.702,6497.69296 C368.076,6498.08523 368.695,6498.10424 369.092,6497.73499 L369.102,6497.72498 C369.504,6497.35172 369.526,6496.72329 369.152,6496.32302 M378.898,6480.27502 L378.908,6480.26501 C379.305,6479.89576 379.924,6479.91477 380.298,6480.30704 L383.447,6483.58729 C384.182,6484.35782 384.185,6485.56865 383.455,6486.34318 L380.277,6489.68347 C379.903,6490.07974 379.279,6490.09975 378.881,6489.7275 L378.878,6489.7245 C378.475,6489.34824 378.458,6488.7148 378.839,6488.31653 L380.242,6486.85753 C380.548,6486.53931 380.323,6486.00395 379.882,6486.00395 L365,6486.00395 C364.448,6486.00395 364,6485.56164 364,6485.00826 L364,6485.00626 C364,6484.45389 364.448,6484.00258 365,6484.00258 L379.897,6484.00258 C380.336,6484.00258 380.562,6483.48222 380.26,6483.163 L378.848,6481.67398 C378.474,6481.27371 378.496,6480.64828 378.898,6480.27502" id="arrow_right_left-[#343]">
|
||||
|
||||
</path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.1 KiB |
14
src/assets/images/btc.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
|
||||
<circle cx="16" cy="16" r="16" fill="#F7931A"/>
|
||||
|
||||
<path fill="#FFF" fill-rule="nonzero" d="M23.189 14.02c.314-2.096-1.283-3.223-3.465-3.975l.708-2.84-1.728-.43-.69 2.765c-.454-.114-.92-.22-1.385-.326l.695-2.783L15.596 6l-.708 2.839c-.376-.086-.746-.17-1.104-.26l.002-.009-2.384-.595-.46 1.846s1.283.294 1.256.312c.7.175.826.638.805 1.006l-.806 3.235c.048.012.11.03.18.057l-.183-.045-1.13 4.532c-.086.212-.303.531-.793.41.018.025-1.256-.313-1.256-.313l-.858 1.978 2.25.561c.418.105.828.215 1.231.318l-.715 2.872 1.727.43.708-2.84c.472.127.93.245 1.378.357l-.706 2.828 1.728.43.715-2.866c2.948.558 5.164.333 6.097-2.333.752-2.146-.037-3.385-1.588-4.192 1.13-.26 1.98-1.003 2.207-2.538zm-3.95 5.538c-.533 2.147-4.148.986-5.32.695l.95-3.805c1.172.293 4.929.872 4.37 3.11zm.535-5.569c-.487 1.953-3.495.96-4.47.717l.86-3.45c.975.243 4.118.696 3.61 2.733z"/>
|
||||
|
||||
</g>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
8
src/assets/images/check.svg
Normal file
@ -0,0 +1,8 @@
|
||||
<svg
|
||||
focusable='false'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='16'
|
||||
height='10'
|
||||
>
|
||||
<path d='M7.207 7.506L3.629 3.81 2.343 4.939l4.841 5.002 8.462-8.428L14.382.362z'/>
|
||||
</svg>
|
After Width: | Height: | Size: 216 B |
28
src/assets/images/eth.svg
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
|
||||
<circle cx="16" cy="16" r="16" fill="#627EEA"/>
|
||||
|
||||
<g fill="#FFF" fill-rule="nonzero">
|
||||
|
||||
<path fill-opacity=".602" d="M16.498 4v8.87l7.497 3.35z"/>
|
||||
|
||||
<path d="M16.498 4L9 16.22l7.498-3.35z"/>
|
||||
|
||||
<path fill-opacity=".602" d="M16.498 21.968v6.027L24 17.616z"/>
|
||||
|
||||
<path d="M16.498 27.995v-6.028L9 17.616z"/>
|
||||
|
||||
<path fill-opacity=".2" d="M16.498 20.573l7.497-4.353-7.497-3.348z"/>
|
||||
|
||||
<path fill-opacity=".602" d="M9 16.22l7.498 4.353v-7.701z"/>
|
||||
|
||||
</g>
|
||||
|
||||
</g>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 699 B |
14
src/assets/images/usdt.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
|
||||
<circle cx="16" cy="16" r="16" fill="#26A17B"/>
|
||||
|
||||
<path fill="#FFF" d="M17.922 17.383v-.002c-.11.008-.677.042-1.942.042-1.01 0-1.721-.03-1.971-.042v.003c-3.888-.171-6.79-.848-6.79-1.658 0-.809 2.902-1.486 6.79-1.66v2.644c.254.018.982.061 1.988.061 1.207 0 1.812-.05 1.925-.06v-2.643c3.88.173 6.775.85 6.775 1.658 0 .81-2.895 1.485-6.775 1.657m0-3.59v-2.366h5.414V7.819H8.595v3.608h5.414v2.365c-4.4.202-7.709 1.074-7.709 2.118 0 1.044 3.309 1.915 7.709 2.118v7.582h3.913v-7.584c4.393-.202 7.694-1.073 7.694-2.116 0-1.043-3.301-1.914-7.694-2.117"/>
|
||||
|
||||
</g>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 808 B |
21
src/hooks/useOnClickOutside.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { useEffect } from 'react'
|
||||
|
||||
export default function useOnClickOutside(
|
||||
ref: React.RefObject<any>,
|
||||
handler: Function
|
||||
) {
|
||||
useEffect(() => {
|
||||
const listener = (event: MouseEvent | TouchEvent) => {
|
||||
if (!ref.current || ref.current.contains(event.target)) {
|
||||
return
|
||||
}
|
||||
handler(event)
|
||||
}
|
||||
document.addEventListener('mousedown', listener)
|
||||
document.addEventListener('touchstart', listener)
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', listener)
|
||||
document.removeEventListener('touchstart', listener)
|
||||
}
|
||||
}, [ref, handler])
|
||||
}
|
5
src/http/index.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export const API_URL = 'https://testnet.binancefuture.com'
|
||||
|
||||
export const $api = axios.create({ baseURL: API_URL })
|
13
src/index.css
Normal file
@ -0,0 +1,13 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
25
src/index.tsx
Normal file
@ -0,0 +1,25 @@
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import App from './App'
|
||||
import reportWebVitals from './reportWebVitals'
|
||||
|
||||
import { convertConfig } from './utils/Constants'
|
||||
|
||||
import './index.css'
|
||||
|
||||
const CryptoConvert = require('crypto-convert').default
|
||||
|
||||
export const convert = new CryptoConvert(convertConfig)
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
|
||||
const queryClient = new QueryClient()
|
||||
root.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<App />
|
||||
</QueryClientProvider>
|
||||
)
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals()
|
8
src/models/IListValutionsName.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Dispatch } from 'react'
|
||||
import { IValutions } from './IValutions'
|
||||
|
||||
export interface IListValuationsName {
|
||||
item: IValutions
|
||||
setValuation: Dispatch<IValutions>
|
||||
valuation: IValutions
|
||||
}
|
5
src/models/IValutions.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface IValutions {
|
||||
title: string
|
||||
img: string
|
||||
alt?: string
|
||||
}
|
1
src/react-app-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
15
src/reportWebVitals.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { ReportHandler } from 'web-vitals'
|
||||
|
||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry)
|
||||
getFID(onPerfEntry)
|
||||
getFCP(onPerfEntry)
|
||||
getLCP(onPerfEntry)
|
||||
getTTFB(onPerfEntry)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default reportWebVitals
|
5
src/setupTests.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom'
|
34
src/utils/Constants.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { IValutions } from '../models/IValutions'
|
||||
|
||||
import btc from '../assets/images/btc.svg'
|
||||
import usdt from '../assets/images/usdt.svg'
|
||||
import eth from '../assets/images/eth.svg'
|
||||
|
||||
export const valuations: IValutions[] = [
|
||||
{
|
||||
title: 'BTC',
|
||||
img: btc,
|
||||
alt: 'Bitcoin'
|
||||
},
|
||||
{
|
||||
title: 'USDT',
|
||||
img: usdt,
|
||||
alt: 'Tether'
|
||||
},
|
||||
{
|
||||
title: 'ETH',
|
||||
img: eth,
|
||||
alt: 'Ethereum'
|
||||
}
|
||||
]
|
||||
|
||||
export const convertConfig = {
|
||||
cryptoInterval: 20000, // Crypto prices update interval in ms (default 5 seconds on Node.js & 15 seconds on Browsers)
|
||||
fiatInterval: 60 * 1e3 * 60, // Fiat prices update interval (default every 1 hour)
|
||||
calculateAverage: true, // Calculate the average crypto price from exchanges
|
||||
binance: true, // Use binance rates
|
||||
bitfinex: true, // Use bitfinex rates
|
||||
coinbase: true, // Use coinbase rates
|
||||
kraken: true, // Use kraken rates
|
||||
HTTPAgent: null // HTTP Agent for server-side proxies (Node.js only)
|
||||
}
|
45
src/utils/HelperFunctions.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { ChangeEvent, Dispatch } from 'react'
|
||||
import { convert } from '../index'
|
||||
|
||||
export const regexInput = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
let [_, sign, integer, decimals]: any = e.target.value
|
||||
.replace(/[^\d\.\-]/g, '')
|
||||
.replace(/(\..*?)\./g, '$1')
|
||||
.replace(/(.+)-/g, '$1')
|
||||
.match(/^(-?)(.*?)((?:\.\d*)?)$/)
|
||||
|
||||
let pos: number = Number(e.target.selectionStart) - 1
|
||||
if (!integer && decimals) pos += 2
|
||||
|
||||
if (integer || decimals) {
|
||||
integer = +integer
|
||||
}
|
||||
|
||||
const formatted = sign + integer + decimals
|
||||
|
||||
if (formatted !== e.target.value) {
|
||||
e.target.value = formatted
|
||||
e.target.setSelectionRange(pos, pos)
|
||||
}
|
||||
}
|
||||
|
||||
export const getRelationToCurrency = async (
|
||||
from: string,
|
||||
to: string,
|
||||
value: number,
|
||||
setValue: Dispatch<string>
|
||||
) => {
|
||||
await convert.ready()
|
||||
setValue(convert[from][to](value) || 0)
|
||||
}
|
||||
|
||||
export const actualDate = () => `
|
||||
${new Date(convert.lastUpdated).toLocaleDateString()}
|
||||
${new Date(convert.lastUpdated)
|
||||
.getHours()
|
||||
.toString()
|
||||
.padStart(2, '0')}:${new Date(convert.lastUpdated)
|
||||
.getMinutes()
|
||||
.toString()
|
||||
.padStart(2, '0')}
|
||||
`
|
26
tsconfig.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|