initial version
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://dmitry220.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>React App</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:
|
127
src/App.scss
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
.converter{
|
||||||
|
|
||||||
|
max-width: 812px;
|
||||||
|
margin: 50px auto;
|
||||||
|
padding: 0 15px;
|
||||||
|
|
||||||
|
&__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{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
&_border{
|
||||||
|
border: 3px solid gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__crypto-name{
|
||||||
|
height: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0 15px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
img{
|
||||||
|
width: 50px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
&__arrow{
|
||||||
|
width: 50px;
|
||||||
|
height: 35px;
|
||||||
|
object-fit: contain;
|
||||||
|
cursor: pointer;
|
||||||
|
@media (max-width:768px) {
|
||||||
|
height: 50px;
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
@media (max-width:576px) {
|
||||||
|
height: 25px;
|
||||||
|
width: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__input{
|
||||||
|
height: 100%;
|
||||||
|
font-family: HelveticaNeue-Light,"Helvetica Neue Light",Helvetica,Arial,sans-serif;
|
||||||
|
font-size: inherit;
|
||||||
|
text-align: right;
|
||||||
|
color: #000;
|
||||||
|
border-width: 0 5px 0px 0px;
|
||||||
|
border-color: rgb(107 107 107);
|
||||||
|
@media (max-width:768px) {
|
||||||
|
border-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
&__footer{
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-converter{
|
||||||
|
position: absolute;
|
||||||
|
z-index: 2;
|
||||||
|
inset: 75px auto auto 0;
|
||||||
|
width: 95%;
|
||||||
|
box-shadow: 0 4px 24px rgba(0,0,0,.25);
|
||||||
|
background: #fff;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 10px;
|
||||||
|
gap: 12px;
|
||||||
|
border-radius: 5px;
|
||||||
|
&__button{
|
||||||
|
background: transparent;
|
||||||
|
transition: 0.3s all ease;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
&_active{
|
||||||
|
background: green;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
&:hover{
|
||||||
|
background: green;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/App.test.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react';
|
||||||
|
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();
|
||||||
|
});
|
156
src/App.tsx
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
import React, {ChangeEvent, useEffect, useRef, useState} from 'react';
|
||||||
|
import './App.scss';
|
||||||
|
import arrowSwap from '../src/assets/images/arrow-right-left.svg'
|
||||||
|
import btc from '../src/assets/images/btc.svg'
|
||||||
|
import usdt from '../src/assets/images/usdt.svg'
|
||||||
|
import eth from '../src/assets/images/eth.svg'
|
||||||
|
import useOnClickOutside from './hooks/useOnClickOutside';
|
||||||
|
import {SecondValuationItem} from './Components/SecondValutionItem/SecondValutionItem';
|
||||||
|
import {FirstValuationItem} from './Components/FirstValutionItem/FirstValutionItem';
|
||||||
|
import {convert} from '.';
|
||||||
|
import {IValutions} from './models/IValutions';
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
|
||||||
|
const valuations: IValutions[] = [
|
||||||
|
{
|
||||||
|
title: 'BTC',
|
||||||
|
img: btc
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'USDT',
|
||||||
|
img: usdt
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ETH',
|
||||||
|
img: eth
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const [firstValue, setFirstValue] = useState<number>(0)
|
||||||
|
const [secondValue, setSecondValue] = useState<number>(0)
|
||||||
|
const [firstValuation, setFirstValuation] = useState<IValutions>(valuations[0])
|
||||||
|
const [secondValuation, setSecondValuation] = useState<IValutions>(valuations[1])
|
||||||
|
const [showFirstValuation, setShowFirstValuation] = useState<boolean>()
|
||||||
|
const [showSecondValuation, setShowSecondValuation] = useState<boolean>()
|
||||||
|
const [isSwap, setSwap] = useState(false)
|
||||||
|
|
||||||
|
|
||||||
|
const handlerInputOne = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setFirstValue(+e.target.value)
|
||||||
|
getSecondValuation(+e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlerInputTwo = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setSecondValue(+e.target.value)
|
||||||
|
getFirstValuation(+e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const openFirstListValuation = () => setShowFirstValuation(true)
|
||||||
|
|
||||||
|
const openSecondListValuation = () => setShowSecondValuation(true)
|
||||||
|
|
||||||
|
const getSecondValuation = async (value: number) => {
|
||||||
|
await convert.ready()
|
||||||
|
setSecondValue(convert[firstValuation.title][secondValuation.title](value))
|
||||||
|
|
||||||
|
}
|
||||||
|
const getFirstValuation = async (value: number) => {
|
||||||
|
await convert.ready()
|
||||||
|
setFirstValue(convert[secondValuation.title][firstValuation.title](value))
|
||||||
|
}
|
||||||
|
|
||||||
|
const swap = () => {
|
||||||
|
setSwap(true)
|
||||||
|
setSecondValuation(firstValuation)
|
||||||
|
setFirstValuation(secondValuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
useOnClickOutside(ref, () => {
|
||||||
|
setShowSecondValuation(false)
|
||||||
|
setShowFirstValuation(false)
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getSecondValuation(firstValue)
|
||||||
|
}, [firstValuation])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(isSwap){
|
||||||
|
setSwap(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
getFirstValuation(secondValue)
|
||||||
|
}, [secondValuation])
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="converter">
|
||||||
|
<div className="converter__head">
|
||||||
|
Тестовое задание. React. Typescript
|
||||||
|
</div>
|
||||||
|
<div className="converter__body">
|
||||||
|
{ }
|
||||||
|
<div className="converter__row converter__row_border">
|
||||||
|
<input className='converter__input' min={0} type="number" value={firstValue} onChange={handlerInputOne} />
|
||||||
|
<span className='converter__crypto-name' onClick={openFirstListValuation}>
|
||||||
|
<img src={firstValuation.img} alt="" />
|
||||||
|
{firstValuation.title}
|
||||||
|
|
||||||
|
</span>
|
||||||
|
{showFirstValuation && <div className='converter__popup popup-converter' ref={ref}>
|
||||||
|
{valuations.map((item, index) =>
|
||||||
|
<FirstValuationItem
|
||||||
|
key={index}
|
||||||
|
item={item}
|
||||||
|
firstValuation={firstValuation.title}
|
||||||
|
setSecondValuation={setSecondValuation}
|
||||||
|
secondValuation={secondValuation.title}
|
||||||
|
setFirstValuation={setFirstValuation}
|
||||||
|
/>)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div className="converter__row">
|
||||||
|
<img className='converter__arrow' src={arrowSwap} alt="" onClick={swap} />
|
||||||
|
</div>
|
||||||
|
<div className="converter__row converter__row_border">
|
||||||
|
<input className='converter__input' min={0} type="number" value={secondValue} onChange={handlerInputTwo} />
|
||||||
|
<span className='converter__crypto-name' onClick={openSecondListValuation}>
|
||||||
|
<img src={secondValuation.img} alt="" />
|
||||||
|
{secondValuation.title}
|
||||||
|
</span>
|
||||||
|
{showSecondValuation && <div className='converter__popup popup-converter' ref={ref}>
|
||||||
|
{valuations.map((item, index) =>
|
||||||
|
<SecondValuationItem
|
||||||
|
key={index}
|
||||||
|
item={item}
|
||||||
|
firstValuation={firstValuation.title}
|
||||||
|
setSecondValuation={setSecondValuation}
|
||||||
|
secondValuation={secondValuation.title}
|
||||||
|
setFirstValuation={setFirstValuation}
|
||||||
|
/>)}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer className="converter__footer">
|
||||||
|
<b>{(firstValue || 0) + ' ' + firstValuation.title + ' = ' + (secondValue || 0) + ' ' + secondValuation.title}</b> <br />
|
||||||
|
Данные носят ознакомительный характер {'\t'}
|
||||||
|
<b>
|
||||||
|
{
|
||||||
|
new Date(convert.lastUpdated).toLocaleDateString() + ' ' +
|
||||||
|
new Date(convert.lastUpdated).getHours() + ':' +
|
||||||
|
new Date(convert.lastUpdated).getMinutes().toString().padStart(2,'0')
|
||||||
|
}
|
||||||
|
</b>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
|
|
28
src/Components/FirstValutionItem/FirstValutionItem.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { Dispatch, FC, MouseEvent } from "react"
|
||||||
|
import { IListValuationsName } from "../../models/IListValutionsName"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const FirstValuationItem: FC<IListValuationsName> = (
|
||||||
|
{
|
||||||
|
item,
|
||||||
|
firstValuation,
|
||||||
|
secondValuation,
|
||||||
|
setFirstValuation,
|
||||||
|
setSecondValuation
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button type='button'
|
||||||
|
className={firstValuation != item.title ? 'popup-converter__button' : 'popup-converter__button popup-converter__button_active'}
|
||||||
|
value={item.title}
|
||||||
|
onClick={(e: MouseEvent<HTMLButtonElement>) => {
|
||||||
|
setFirstValuation({
|
||||||
|
img: item.img,
|
||||||
|
title: e.currentTarget.value
|
||||||
|
})
|
||||||
|
}}>{item.title}</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
25
src/Components/SecondValutionItem/SecondValutionItem.tsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { Dispatch, FC, MouseEvent } from "react"
|
||||||
|
import { IListValuationsName } from "../../models/IListValutionsName"
|
||||||
|
|
||||||
|
|
||||||
|
export const SecondValuationItem: FC<IListValuationsName> = ({
|
||||||
|
item,
|
||||||
|
firstValuation,
|
||||||
|
secondValuation,
|
||||||
|
setFirstValuation,
|
||||||
|
setSecondValuation
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button type='button'
|
||||||
|
className={secondValuation != item.title ? 'popup-converter__button' : 'popup-converter__button popup-converter__button_active'}
|
||||||
|
value={item.title} onClick={(e: MouseEvent<HTMLButtonElement>) => {
|
||||||
|
setSecondValuation({
|
||||||
|
img: item.img,
|
||||||
|
title: e.currentTarget.value
|
||||||
|
})
|
||||||
|
|
||||||
|
}}>{item.title}</button>
|
||||||
|
)
|
||||||
|
}
|
5
src/assets/images/arrow-double-vertical.svg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?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 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M16.2427 5.6568C16.6332 5.26627 16.6332 4.63311 16.2427 4.24258L13.4142 1.41416C12.6332 0.633107 11.3669 0.633107 10.5858 1.41416L7.75737 4.24268C7.36685 4.6332 7.36685 5.26637 7.75737 5.65689C8.1479 6.04741 8.78106 6.04741 9.17158 5.65689L11 3.82847V8.99998C11 9.55227 11.4477 9.99998 12 9.99998C12.5523 9.99998 13 9.55227 13 8.99998V3.82835L14.8284 5.6568C15.219 6.04732 15.8521 6.04732 16.2427 5.6568Z" fill="#0F0F0F"/>
|
||||||
|
<path d="M7.7574 18.3429C7.36688 18.7334 7.36688 19.3666 7.7574 19.7571L10.5858 22.5856C11.3669 23.3666 12.6332 23.3668 13.4143 22.5857L16.2427 19.7573C16.6332 19.3668 16.6332 18.7336 16.2427 18.3431C15.8522 17.9526 15.219 17.9526 14.8285 18.3431L13 20.1716L13 15C13 14.4477 12.5523 14 12 14C11.4477 14 11 14.4477 11 15L11 20.1713L9.17161 18.3429C8.78109 17.9524 8.14792 17.9524 7.7574 18.3429Z" fill="#0F0F0F"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
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 |
8
src/assets/images/btc.svg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?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 |
15
src/assets/images/eth.svg
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?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 |
8
src/assets/images/usdt.svg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?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 |
22
src/hooks/useOnClickOutside.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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;
|
||||||
|
}
|
34
src/index.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import './index.css';
|
||||||
|
import App from './App';
|
||||||
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
import {QueryClient, QueryClientProvider} from "@tanstack/react-query";
|
||||||
|
|
||||||
|
const CryptoConvert = require("crypto-convert").default;
|
||||||
|
|
||||||
|
export const convert = new CryptoConvert({
|
||||||
|
cryptoInterval: 600000, //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)
|
||||||
|
});
|
||||||
|
|
||||||
|
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();
|
1
src/logo.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
After Width: | Height: | Size: 2.6 KiB |
10
src/models/IListValutionsName.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Dispatch } from "react";
|
||||||
|
import { IValutions } from "./IValutions";
|
||||||
|
|
||||||
|
export interface IListValuationsName {
|
||||||
|
item: IValutions,
|
||||||
|
setFirstValuation: Dispatch<IValutions>,
|
||||||
|
setSecondValuation: Dispatch<IValutions>,
|
||||||
|
secondValuation: string,
|
||||||
|
firstValuation: string
|
||||||
|
}
|
4
src/models/IValutions.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface IValutions {
|
||||||
|
title: string,
|
||||||
|
img: 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';
|
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"
|
||||||
|
]
|
||||||
|
}
|