Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
a98be224
Commit
a98be224
authored
Sep 29, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GasUsedToTargetRatio component
parent
564e3586
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
BlockDetails.tsx
ui/block/BlockDetails.tsx
+3
-7
BlocksTableItem.tsx
ui/blocks/BlocksTableItem.tsx
+3
-8
GasUsedToTargetRatio.tsx
ui/shared/GasUsedToTargetRatio.tsx
+23
-0
No files found.
ui/block/BlockDetails.tsx
View file @
a98be224
import
{
Grid
,
GridItem
,
Text
,
Icon
,
Link
,
Stat
,
StatArrow
,
Box
,
Tooltip
}
from
'
@chakra-ui/react
'
;
import
{
Grid
,
GridItem
,
Text
,
Icon
,
Link
,
Box
,
Tooltip
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
{
scroller
,
Element
}
from
'
react-scroll
'
;
...
...
@@ -12,6 +12,7 @@ import useLink from 'lib/link/useLink';
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
DetailsInfoItem
from
'
ui/shared/DetailsInfoItem
'
;
import
GasUsedToTargetRatio
from
'
ui/shared/GasUsedToTargetRatio
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
import
PrevNext
from
'
ui/shared/PrevNext
'
;
import
TextSeparator
from
'
ui/shared/TextSeparator
'
;
...
...
@@ -30,8 +31,6 @@ const BlockDetails = () => {
});
},
[]);
const
gasUsedPercentage
=
Math
.
round
((
block
.
gas_used
/
block
.
gas_target
-
1
)
*
100
);
const
sectionGap
=
<
GridItem
colSpan=
{
{
base
:
undefined
,
lg
:
2
}
}
mt=
{
{
base
:
1
,
lg
:
4
}
}
/>;
return
(
...
...
@@ -104,10 +103,7 @@ const BlockDetails = () => {
>
<
Text
>
{
block
.
gas_used
.
toLocaleString
(
'
en
'
)
}
</
Text
>
<
Utilization
ml=
{
4
}
mr=
{
5
}
colorScheme=
"gray"
value=
{
block
.
gas_used
/
block
.
gas_limit
}
/>
<
Stat
>
<
StatArrow
ml=
{
1
}
type=
{
gasUsedPercentage
>=
0
?
'
increase
'
:
'
decrease
'
}
/>
<
Text
as=
"span"
color=
{
gasUsedPercentage
>=
0
?
'
green.500
'
:
'
red.500
'
}
fontWeight=
{
600
}
>
{
Math
.
abs
(
gasUsedPercentage
)
}
% Gas Target
</
Text
>
</
Stat
>
<
GasUsedToTargetRatio
used=
{
block
.
gas_used
}
target=
{
block
.
gas_target
}
/>
</
DetailsInfoItem
>
<
DetailsInfoItem
title=
"Gas limit"
...
...
ui/blocks/BlocksTableItem.tsx
View file @
a98be224
import
{
Tr
,
Td
,
Text
,
Link
,
Flex
,
Box
,
Stat
,
StatArrow
,
Icon
,
Tooltip
,
Spinner
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Tr
,
Td
,
Text
,
Link
,
Flex
,
Box
,
Icon
,
Tooltip
,
Spinner
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
ArrayElement
from
'
types/utils/ArrayElement
'
;
...
...
@@ -8,6 +8,7 @@ import flameIcon from 'icons/flame.svg';
import
dayjs
from
'
lib/date/dayjs
'
;
import
useLink
from
'
lib/link/useLink
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
GasUsedToTargetRatio
from
'
ui/shared/GasUsedToTargetRatio
'
;
import
Utilization
from
'
ui/shared/Utilization
'
;
interface
Props
{
...
...
@@ -18,7 +19,6 @@ interface Props {
const
BlocksTableItem
=
({
data
,
isPending
}:
Props
)
=>
{
const
link
=
useLink
();
const
gasUsedPercentage
=
(
data
.
gas_used
/
data
.
gas_target
-
1
)
*
100
;
const
spinnerEmptyColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
return
(
...
...
@@ -44,12 +44,7 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
<
Box
>
{
data
.
gas_used
.
toLocaleString
(
'
en
'
)
}
</
Box
>
<
Flex
mt=
{
2
}
>
<
Utilization
colorScheme=
"gray"
value=
{
data
.
gas_used
/
data
.
gas_limit
}
/>
<
Stat
ml=
{
2
}
>
<
StatArrow
type=
{
gasUsedPercentage
>=
0
?
'
increase
'
:
'
decrease
'
}
/>
<
Text
as=
"span"
color=
{
gasUsedPercentage
>=
0
?
'
green.500
'
:
'
red.500
'
}
fontWeight=
{
600
}
>
{
Math
.
abs
(
gasUsedPercentage
).
toLocaleString
(
'
en
'
,
{
maximumFractionDigits
:
2
})
}
%
</
Text
>
</
Stat
>
<
GasUsedToTargetRatio
ml=
{
2
}
used=
{
data
.
gas_used
}
target=
{
data
.
gas_target
}
/>
</
Flex
>
</
Td
>
<
Td
fontSize=
"sm"
>
{
(
data
.
reward
.
static
+
data
.
reward
.
tx_fee
-
data
.
burnt_fees
).
toLocaleString
(
'
en
'
,
{
maximumFractionDigits
:
5
})
}
</
Td
>
...
...
ui/shared/GasUsedToTargetRatio.tsx
0 → 100644
View file @
a98be224
import
{
Stat
,
StatArrow
,
Text
,
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
interface
Props
{
used
:
number
;
target
:
number
;
className
?:
string
;
}
const
GasUsedToTargetRatio
=
({
used
,
target
,
className
}:
Props
)
=>
{
const
percentage
=
(
used
/
target
-
1
)
*
100
;
return
(
<
Stat
className=
{
className
}
>
<
StatArrow
type=
{
percentage
>=
0
?
'
increase
'
:
'
decrease
'
}
/>
<
Text
as=
"span"
color=
{
percentage
>=
0
?
'
green.500
'
:
'
red.500
'
}
fontWeight=
{
600
}
>
{
Math
.
abs
(
percentage
).
toLocaleString
(
'
en
'
,
{
maximumFractionDigits
:
2
})
}
%
</
Text
>
</
Stat
>
);
};
export
default
React
.
memo
(
chakra
(
GasUsedToTargetRatio
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment