fix styles
This commit is contained in:
parent
e693462f0f
commit
7d3f76d230
@ -24,7 +24,7 @@
|
||||
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>
|
||||
<title>Crypto Converter</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
52
src/App.scss
52
src/App.scss
@ -1,25 +1,22 @@
|
||||
body{
|
||||
body {
|
||||
background: #e5e5e5;
|
||||
}
|
||||
|
||||
|
||||
.converter{
|
||||
|
||||
max-width: 610px;
|
||||
.converter {
|
||||
max-width: 630px;
|
||||
margin: 50px auto;
|
||||
background: #fff;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
|
||||
|
||||
&__head{
|
||||
&__head {
|
||||
font-weight: 700;
|
||||
font-size: 25px;
|
||||
text-align: center;
|
||||
margin: 0 0 50px 0;
|
||||
}
|
||||
|
||||
&__body{
|
||||
&__body {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
@ -27,13 +24,13 @@ body{
|
||||
gap: 10px;
|
||||
margin: 0 0 25px 0;
|
||||
justify-content: center;
|
||||
@media (max-width:768px) {
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&__row{
|
||||
&__row {
|
||||
border-radius: 10px;
|
||||
height: 100%;
|
||||
font-size: 24px;
|
||||
@ -41,19 +38,15 @@ body{
|
||||
align-items: center;
|
||||
position: relative;
|
||||
justify-content: center;
|
||||
@media (max-width:908px) {
|
||||
@media (max-width: 908px) {
|
||||
font-size: 20px;
|
||||
}
|
||||
@media (max-width:768px) {
|
||||
@media (max-width: 768px) {
|
||||
font-size: inherit;
|
||||
}
|
||||
&_border{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&__crypto-name{
|
||||
&__crypto-name {
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
position: relative;
|
||||
@ -69,35 +62,37 @@ body{
|
||||
border: 2px solid rgba(7, 28, 71, 0.12);
|
||||
border-left: none;
|
||||
border-radius: 0 10px 10px 0;
|
||||
&-title{
|
||||
&-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
img{
|
||||
img {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&__arrow{
|
||||
&__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;
|
||||
-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{
|
||||
&__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-family: HelveticaNeue-Light, 'Helvetica Neue Light', Helvetica, Arial,
|
||||
sans-serif;
|
||||
font-size: inherit;
|
||||
text-align: right;
|
||||
width: 201px;
|
||||
@ -106,12 +101,11 @@ body{
|
||||
top: 0;
|
||||
padding: 0 10px 0 0;
|
||||
outline: none;
|
||||
@media (max-width:768px) {
|
||||
@media (max-width: 768px) {
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
}
|
||||
&__footer{
|
||||
&__footer {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
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();
|
||||
});
|
||||
render(<App />)
|
||||
const linkElement = screen.getByText(/learn react/i)
|
||||
expect(linkElement).toBeInTheDocument()
|
||||
})
|
||||
|
388
src/App.tsx
388
src/App.tsx
@ -1,195 +1,237 @@
|
||||
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||
import './App.scss';
|
||||
import { ChangeEvent, useEffect, useRef, useState } from 'react'
|
||||
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 { PopupConverter } from './Components/popup-converter/Popup-converter';
|
||||
import { convert } from '.';
|
||||
import { IValutions } from './models/IValutions';
|
||||
import useOnClickOutside from './hooks/useOnClickOutside'
|
||||
import { PopupConverter } from './Components/popup-converter/Popup-converter'
|
||||
import { convert } from '.'
|
||||
import { IValutions } from './models/IValutions'
|
||||
|
||||
import './App.scss'
|
||||
|
||||
function App() {
|
||||
const valuations: IValutions[] = [
|
||||
{
|
||||
title: 'BTC',
|
||||
img: btc,
|
||||
alt: 'Bitcoin'
|
||||
},
|
||||
{
|
||||
title: 'USDT',
|
||||
img: usdt,
|
||||
alt: 'Tether'
|
||||
},
|
||||
{
|
||||
title: 'ETH',
|
||||
img: eth,
|
||||
alt: 'Ethereum'
|
||||
}
|
||||
]
|
||||
|
||||
const valuations: IValutions[] = [
|
||||
{
|
||||
title: 'BTC',
|
||||
img: btc,
|
||||
alt: 'Bitcoin'
|
||||
},
|
||||
{
|
||||
title: 'USDT',
|
||||
img: usdt,
|
||||
alt: 'Tether'
|
||||
},
|
||||
{
|
||||
title: 'ETH',
|
||||
img: eth,
|
||||
alt: 'Ethereum'
|
||||
},
|
||||
]
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
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 [showFirstValuation, setShowFirstValuation] = useState<boolean>()
|
||||
const [showSecondValuation, setShowSecondValuation] = useState<boolean>()
|
||||
const [isSwap, setSwap] = useState(true)
|
||||
|
||||
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 [showFirstValuation, setShowFirstValuation] = useState<boolean>()
|
||||
const [showSecondValuation, setShowSecondValuation] = useState<boolean>()
|
||||
const [isSwap, setSwap] = useState(true)
|
||||
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
|
||||
|
||||
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);
|
||||
}
|
||||
if (integer || decimals) {
|
||||
integer = +integer
|
||||
}
|
||||
|
||||
const handlerInputOne = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
regexInput(e)
|
||||
setFirstValue(e.target.value)
|
||||
getSecondValuation(+e.target.value || 0)
|
||||
const formatted = sign + integer + decimals
|
||||
|
||||
if (formatted !== e.target.value) {
|
||||
e.target.value = formatted
|
||||
e.target.setSelectionRange(pos, pos)
|
||||
}
|
||||
}
|
||||
|
||||
const handlerInputTwo = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
regexInput(e)
|
||||
setSecondValue(e.target.value)
|
||||
getFirstValuation(+e.target.value || 0)
|
||||
const handlerInputOne = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
regexInput(e)
|
||||
setFirstValue(e.target.value)
|
||||
getSecondValuation(+e.target.value || 0)
|
||||
}
|
||||
|
||||
const handlerInputTwo = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
regexInput(e)
|
||||
setSecondValue(e.target.value)
|
||||
getFirstValuation(+e.target.value || 0)
|
||||
}
|
||||
|
||||
const openFirstListValuation = () => setShowFirstValuation(true)
|
||||
|
||||
const openSecondListValuation = () => setShowSecondValuation(true)
|
||||
|
||||
const getSecondValuation = async (value: number) => {
|
||||
await convert.ready()
|
||||
setSecondValue(
|
||||
convert[firstValuation.title][secondValuation.title](value) || 0
|
||||
)
|
||||
}
|
||||
const getFirstValuation = async (value: number) => {
|
||||
await convert.ready()
|
||||
setFirstValue(
|
||||
convert[secondValuation.title][firstValuation.title](value) || 0
|
||||
)
|
||||
}
|
||||
|
||||
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])
|
||||
|
||||
const openFirstListValuation = () => setShowFirstValuation(true)
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
getSecondValuation(+firstValue)
|
||||
}, 25000)
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
|
||||
const openSecondListValuation = () => setShowSecondValuation(true)
|
||||
const getValuations = () =>
|
||||
`${firstValue || 0} ${firstValuation.title} = ${secondValue || 0} ${
|
||||
secondValuation.title
|
||||
}`
|
||||
|
||||
const getSecondValuation = async (value: number) => {
|
||||
await convert.ready()
|
||||
setSecondValue(convert[firstValuation.title][secondValuation.title](value) || 0)
|
||||
|
||||
}
|
||||
const getFirstValuation = async (value: number) => {
|
||||
await convert.ready()
|
||||
setFirstValue(convert[secondValuation.title][firstValuation.title](value) || 0)
|
||||
}
|
||||
|
||||
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])
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
getSecondValuation(+firstValue)
|
||||
}, 25000)
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<div className="converter">
|
||||
<div className="converter__body">
|
||||
<div className="converter__row converter__row_border">
|
||||
<input className='converter__input' type="text" value={firstValue}
|
||||
onChange={handlerInputOne} />
|
||||
<span className='converter__crypto-name' onClick={openFirstListValuation}>
|
||||
<div className={'converter__crypto-name-title'}>
|
||||
<img src={firstValuation.img} alt="" />
|
||||
{firstValuation.title}
|
||||
</div>
|
||||
<div>
|
||||
<svg focusable="false" xmlns="http://www.w3.org/2000/svg" width="8" height="14"><path
|
||||
d="M4 0l4 6H0l4-6zm0 14l4-6H0l4 6z" /></svg>
|
||||
</div>
|
||||
</span>
|
||||
{showFirstValuation && <div className='converter__popup popup-converter' ref={ref}>
|
||||
{valuations.map((item, index) =>
|
||||
<PopupConverter
|
||||
key={index}
|
||||
item={item}
|
||||
setValuation={setFirstValuation}
|
||||
valuation={firstValuation.title}
|
||||
|
||||
/>)}
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div className="converter__row">
|
||||
<div className={'converter__arrow'} onClick={swap} />
|
||||
</div>
|
||||
<div className="converter__row converter__row_border">
|
||||
<input className='converter__input' min={0} type="text" maxLength={20} value={secondValue}
|
||||
onChange={handlerInputTwo} />
|
||||
<span className='converter__crypto-name' onClick={openSecondListValuation}>
|
||||
<div className={'converter__crypto-name-title'}>
|
||||
<img src={secondValuation.img} alt="" />
|
||||
{secondValuation.title}
|
||||
</div>
|
||||
<div>
|
||||
<svg focusable="false" xmlns="http://www.w3.org/2000/svg" width="8" height="14"><path
|
||||
d="M4 0l4 6H0l4-6zm0 14l4-6H0l4 6z" /></svg>
|
||||
</div>
|
||||
</span>
|
||||
{showSecondValuation && <div className='converter__popup popup-converter' ref={ref}>
|
||||
{valuations.map((item, index) =>
|
||||
<PopupConverter
|
||||
key={index}
|
||||
item={item}
|
||||
valuation={secondValuation.title}
|
||||
setValuation={setSecondValuation}
|
||||
/>)}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
return (
|
||||
<div className='converter'>
|
||||
<div className='converter__body'>
|
||||
<div className='converter__row converter__row_border'>
|
||||
<input
|
||||
className='converter__input'
|
||||
type='text'
|
||||
value={firstValue}
|
||||
onChange={handlerInputOne}
|
||||
/>
|
||||
<span
|
||||
className='converter__crypto-name'
|
||||
onClick={openFirstListValuation}
|
||||
>
|
||||
<div className={'converter__crypto-name-title'}>
|
||||
<img src={firstValuation.img} alt='' />
|
||||
{firstValuation.title}
|
||||
</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>
|
||||
<svg
|
||||
focusable='false'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='8'
|
||||
height='14'
|
||||
>
|
||||
<path d='M4 0l4 6H0l4-6zm0 14l4-6H0l4 6z' />
|
||||
</svg>
|
||||
</div>
|
||||
</span>
|
||||
{showFirstValuation && (
|
||||
<div className='converter__popup popup-converter' ref={ref}>
|
||||
{valuations.map((item, index) => (
|
||||
<PopupConverter
|
||||
key={index}
|
||||
item={item}
|
||||
setValuation={setFirstValuation}
|
||||
valuation={firstValuation.title}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
<div className='converter__row'>
|
||||
<div className={'converter__arrow'} onClick={swap} />
|
||||
</div>
|
||||
<div className='converter__row converter__row_border'>
|
||||
<input
|
||||
className='converter__input'
|
||||
min={0}
|
||||
type='text'
|
||||
maxLength={20}
|
||||
value={secondValue}
|
||||
onChange={handlerInputTwo}
|
||||
/>
|
||||
<span
|
||||
className='converter__crypto-name'
|
||||
onClick={openSecondListValuation}
|
||||
>
|
||||
<div className={'converter__crypto-name-title'}>
|
||||
<img src={secondValuation.img} alt='' />
|
||||
{secondValuation.title}
|
||||
</div>
|
||||
<div>
|
||||
<svg
|
||||
focusable='false'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='8'
|
||||
height='14'
|
||||
>
|
||||
<path d='M4 0l4 6H0l4-6zm0 14l4-6H0l4 6z' />
|
||||
</svg>
|
||||
</div>
|
||||
</span>
|
||||
{showSecondValuation && (
|
||||
<div className='converter__popup popup-converter' ref={ref}>
|
||||
{valuations.map((item, index) => (
|
||||
<PopupConverter
|
||||
key={index}
|
||||
item={item}
|
||||
valuation={secondValuation.title}
|
||||
setValuation={setSecondValuation}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<footer className='converter__footer'>
|
||||
<b>{getValuations()}</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;
|
||||
|
||||
export default App
|
||||
|
@ -1,42 +1,42 @@
|
||||
.popup-converter{
|
||||
.popup-converter {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
inset: 75px auto auto 0;
|
||||
width: 100%;
|
||||
box-shadow: 0 4px 24px rgba(0,0,0,.25);
|
||||
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{
|
||||
&__container {
|
||||
padding: 4px 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
&:hover{
|
||||
&:hover {
|
||||
background: #ffeca1;
|
||||
}
|
||||
}
|
||||
&__check{
|
||||
&__check {
|
||||
display: flex;
|
||||
flex: 0 0 16px;
|
||||
}
|
||||
&__body{
|
||||
&__body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
&__img{
|
||||
&__img {
|
||||
flex: 0 0 20px;
|
||||
height: 20px;
|
||||
img{
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
&__button{
|
||||
&__button {
|
||||
background: transparent;
|
||||
transition: 0.3s all ease;
|
||||
// padding: 10px;
|
||||
@ -44,11 +44,11 @@
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
span{
|
||||
span {
|
||||
margin: 0 4px;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: rgba(84,96,122,.68);
|
||||
color: rgba(84, 96, 122, 0.68);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,43 @@
|
||||
import {Dispatch, FC, MouseEvent} from "react"
|
||||
import {IListValuationsName} from "../../models/IListValutionsName"
|
||||
import { FC, MouseEvent } from 'react'
|
||||
import { IListValuationsName } from '../../models/IListValutionsName'
|
||||
import './Popup-converter.scss'
|
||||
|
||||
export const PopupConverter: FC<IListValuationsName> = ({
|
||||
item,
|
||||
valuation,
|
||||
setValuation
|
||||
}) => {
|
||||
const setActiveValuation = (e: MouseEvent<HTMLDivElement>) => {
|
||||
setValuation({
|
||||
img: item.img,
|
||||
title: item.title
|
||||
})
|
||||
}
|
||||
|
||||
export const PopupConverter: FC<IListValuationsName> = (
|
||||
{
|
||||
item,
|
||||
valuation,
|
||||
setValuation,
|
||||
}
|
||||
) => {
|
||||
|
||||
const setActiveValuation = (e: MouseEvent<HTMLDivElement>) => {
|
||||
setValuation({
|
||||
img: item.img,
|
||||
title: item.title
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={'popup-converter__container'} onClick={setActiveValuation}>
|
||||
<div className={'popup-converter__check'}>
|
||||
{valuation === item.title &&
|
||||
<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>}
|
||||
</div>
|
||||
<div className={'popup-converter__body'}>
|
||||
<img className={'popup-converter__img'} src={item.img} alt="icon"/>
|
||||
<button type='button'
|
||||
className={'popup-converter__button'}
|
||||
value={item.title}
|
||||
>{item.title} <span>{item.alt}</span></button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
)
|
||||
return (
|
||||
<div className={'popup-converter__container'} onClick={setActiveValuation}>
|
||||
<div className={'popup-converter__check'}>
|
||||
{valuation === item.title && (
|
||||
<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>
|
||||
)}
|
||||
</div>
|
||||
<div className={'popup-converter__body'}>
|
||||
<img className={'popup-converter__img'} src={item.img} alt='icon' />
|
||||
<button
|
||||
type='button'
|
||||
className={'popup-converter__button'}
|
||||
value={item.title}
|
||||
>
|
||||
{item.title} <span>{item.alt}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,21 @@
|
||||
import { useEffect } from 'react';
|
||||
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]
|
||||
);
|
||||
}
|
||||
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])
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import axios from "axios"
|
||||
import axios from 'axios'
|
||||
|
||||
export const API_URL = 'https://testnet.binancefuture.com'
|
||||
|
||||
export const $api = axios.create({ baseURL: API_URL })
|
||||
export const $api = axios.create({ baseURL: API_URL })
|
||||
|
@ -1,34 +1,31 @@
|
||||
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";
|
||||
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;
|
||||
const CryptoConvert = require('crypto-convert').default
|
||||
|
||||
export const convert = new CryptoConvert({
|
||||
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)
|
||||
});
|
||||
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)
|
||||
})
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById('root') as HTMLElement
|
||||
);
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
|
||||
const queryClient = new QueryClient()
|
||||
root.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<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();
|
||||
reportWebVitals()
|
||||
|
@ -1 +0,0 @@
|
||||
<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>
|
Before Width: | Height: | Size: 2.6 KiB |
@ -1,8 +1,8 @@
|
||||
import { Dispatch } from "react";
|
||||
import { IValutions } from "./IValutions";
|
||||
import { Dispatch } from 'react'
|
||||
import { IValutions } from './IValutions'
|
||||
|
||||
export interface IListValuationsName {
|
||||
item: IValutions,
|
||||
setValuation: Dispatch<IValutions>,
|
||||
valuation: string
|
||||
}
|
||||
item: IValutions
|
||||
setValuation: Dispatch<IValutions>
|
||||
valuation: string
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export interface IValutions {
|
||||
title: string,
|
||||
img: string,
|
||||
alt?: string
|
||||
title: string
|
||||
img: string
|
||||
alt?: string
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { ReportHandler } from 'web-vitals';
|
||||
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);
|
||||
});
|
||||
getCLS(onPerfEntry)
|
||||
getFID(onPerfEntry)
|
||||
getFCP(onPerfEntry)
|
||||
getLCP(onPerfEntry)
|
||||
getTTFB(onPerfEntry)
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default reportWebVitals;
|
||||
export default reportWebVitals
|
||||
|
@ -2,4 +2,4 @@
|
||||
// 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';
|
||||
import '@testing-library/jest-dom'
|
||||
|
Loading…
Reference in New Issue
Block a user