-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1482 from blockscout/tom2drum/issue-1405
Gas tooltip: periodical updates of data
- Loading branch information
Showing
29 changed files
with
309 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-243 Bytes
(99%)
...e/__screenshots__/Stats.pw.tsx_dark-color-mode_all-items-mobile-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-261 Bytes
(98%)
ui/home/__screenshots__/Stats.pw.tsx_default_all-items-mobile-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-347 Bytes
(98%)
ui/home/__screenshots__/Stats.pw.tsx_default_all-items-screen-xl-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-515 Bytes
(96%)
...__screenshots__/Stats.pw.tsx_mobile_4-items-default-view-mobile---default-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-647 Bytes
(97%)
ui/home/__screenshots__/Stats.pw.tsx_mobile_all-items-mobile-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-514 Bytes
(100%)
...creenshots__/Home.pw.tsx_dark-color-mode_default-view---default-dark-mode-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-462 Bytes
(100%)
ui/pages/__screenshots__/Home.pw.tsx_default_default-view-screen-xl-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-677 Bytes
(100%)
ui/pages/__screenshots__/Home.pw.tsx_default_mobile-base-view-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { GridItem, chakra } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
import type { GasPriceInfo } from 'types/api/stats'; | ||
|
||
import { asymp, space } from 'lib/html-entities'; | ||
|
||
interface Props { | ||
name: string; | ||
info: GasPriceInfo | null; | ||
} | ||
|
||
const GasInfoRow = ({ name, info }: Props) => { | ||
const content = (() => { | ||
if (!info || info.price === null) { | ||
return 'N/A'; | ||
} | ||
|
||
return ( | ||
<> | ||
<span>{ info.fiat_price ? `$${ info.fiat_price }` : `${ info.price } Gwei` }</span> | ||
{ info.time && ( | ||
<chakra.span color="text_secondary"> | ||
{ space }per tx { asymp } { (info.time / 1000).toLocaleString(undefined, { maximumFractionDigits: 1 }) }s | ||
</chakra.span> | ||
) } | ||
</> | ||
); | ||
})(); | ||
|
||
return ( | ||
<> | ||
<GridItem color="blue.100">{ name }</GridItem> | ||
<GridItem color="text" textAlign="right">{ content }</GridItem> | ||
</> | ||
); | ||
}; | ||
|
||
export default React.memo(GasInfoRow); |
48 changes: 34 additions & 14 deletions
48
ui/shared/GasInfoTooltipContent/GasInfoTooltipContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { CircularProgress } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
import dayjs from 'lib/date/dayjs'; | ||
|
||
interface Props { | ||
startTime: number; | ||
duration: number; | ||
} | ||
|
||
const getValue = (startDate: dayjs.Dayjs, duration: number) => { | ||
const now = dayjs(); | ||
const diff = now.diff(startDate, 'ms'); | ||
const value = diff / duration * 100; | ||
|
||
if (value >= 99) { | ||
return 99; | ||
} | ||
|
||
return value; | ||
}; | ||
|
||
const GasInfoUpdateTimer = ({ startTime, duration }: Props) => { | ||
const [ value, setValue ] = React.useState(getValue(dayjs(startTime), duration)); | ||
|
||
React.useEffect(() => { | ||
const startDate = dayjs(startTime); | ||
|
||
const intervalId = window.setInterval(() => { | ||
const nextValue = getValue(startDate, duration); | ||
setValue(nextValue); | ||
if (nextValue === 99) { | ||
window.clearInterval(intervalId); | ||
} | ||
}, 100); | ||
|
||
return () => { | ||
window.clearInterval(intervalId); | ||
}; | ||
}, [ startTime, duration ]); | ||
|
||
return <CircularProgress value={ value } trackColor="whiteAlpha.100" size={ 4 }/>; | ||
}; | ||
|
||
export default React.memo(GasInfoUpdateTimer); |
Oops, something went wrong.