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
e4c18d36
Commit
e4c18d36
authored
Nov 29, 2022
by
Yuri Mikhin
Committed by
Yuri Mikhin
Nov 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add number widget to the Stats page.
parent
681d8a68
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
111 additions
and
8 deletions
+111
-8
stats.ts
types/api/stats.ts
+4
-0
Stats.tsx
ui/pages/Stats.tsx
+7
-2
ChartWidget.tsx
ui/stats/ChartWidget.tsx
+2
-2
ChartsWidgetsList.tsx
ui/stats/ChartsWidgetsList.tsx
+2
-2
NumberWidget.tsx
ui/stats/NumberWidget.tsx
+34
-0
NumberWidgetSkeleton.tsx
ui/stats/NumberWidgetSkeleton.tsx
+19
-0
NumberWidgetsList.tsx
ui/stats/NumberWidgetsList.tsx
+41
-0
demo-charts-data.ts
ui/stats/constants/demo-charts-data.ts
+1
-1
index.ts
ui/stats/constants/index.ts
+1
-1
No files found.
types/api/stats.ts
View file @
e4c18d36
...
...
@@ -12,3 +12,7 @@ export type HomeStats = {
market_cap
:
string
;
network_utilization_percentage
:
number
;
}
export
type
Stats
=
{
total_blocks
:
string
;
}
ui/pages/Stats.tsx
View file @
e4c18d36
...
...
@@ -4,9 +4,10 @@ import React from 'react';
import
Page
from
'
ui/shared/Page/Page
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
ChartsWidgetsList
from
'
../stats/ChartsWidgetsList
'
;
import
NumberWidgetsList
from
'
../stats/NumberWidgetsList
'
;
import
StatsFilters
from
'
../stats/StatsFilters
'
;
import
useStats
from
'
../stats/useStats
'
;
import
WidgetsList
from
'
../stats/WidgetsList
'
;
const
Stats
=
()
=>
{
const
{
...
...
@@ -22,6 +23,10 @@ const Stats = () => {
<
Page
>
<
PageTitle
text=
"Ethereum Stats"
/>
<
Box
mb=
{
{
base
:
6
,
sm
:
8
}
}
>
<
NumberWidgetsList
/>
</
Box
>
<
Box
mb=
{
{
base
:
6
,
sm
:
8
}
}
>
<
StatsFilters
section=
{
section
}
...
...
@@ -32,7 +37,7 @@ const Stats = () => {
/>
</
Box
>
<
WidgetsList
<
Charts
WidgetsList
charts=
{
displayedCharts
}
/>
</
Page
>
...
...
ui/stats/ChartWidget.tsx
View file @
e4c18d36
...
...
@@ -2,7 +2,7 @@ import { Box, Button, Grid, Heading, Text, useColorModeValue } from '@chakra-ui/
import
React
,
{
useCallback
}
from
'
react
'
;
import
ChartWidgetGraph
from
'
./ChartWidgetGraph
'
;
import
{
demo
Data
}
from
'
./constants/demo
-data
'
;
import
{
demo
ChartsData
}
from
'
./constants/demo-charts
-data
'
;
type
Props
=
{
apiMethodURL
:
string
;
...
...
@@ -62,7 +62,7 @@ const ChartWidget = ({ title, description }: Props) => {
</
Grid
>
<
ChartWidgetGraph
items=
{
demoData
}
items=
{
demo
Charts
Data
}
onZoom=
{
handleZoom
}
isZoomResetInitial=
{
isZoomResetInitial
}
title=
{
title
}
...
...
ui/stats/WidgetsList.tsx
→
ui/stats/
Charts
WidgetsList.tsx
View file @
e4c18d36
...
...
@@ -12,7 +12,7 @@ type Props = {
charts
:
Array
<
StatsSection
>
;
}
const
WidgetsList
=
({
charts
}:
Props
)
=>
{
const
Charts
WidgetsList
=
({
charts
}:
Props
)
=>
{
const
isAnyChartDisplayed
=
charts
.
some
((
section
)
=>
section
.
charts
.
some
(
chart
=>
chart
.
visible
));
return
isAnyChartDisplayed
?
(
...
...
@@ -62,4 +62,4 @@ const WidgetsList = ({ charts }: Props) => {
);
};
export
default
WidgetsList
;
export
default
Charts
WidgetsList
;
ui/stats/NumberWidget.tsx
0 → 100644
View file @
e4c18d36
import
{
Box
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
type
Props
=
{
label
:
string
;
value
:
string
;
}
const
NumberWidget
=
({
label
,
value
}:
Props
)
=>
{
return
(
<
Box
border=
"1px"
borderColor=
{
useColorModeValue
(
'
gray.200
'
,
'
gray.600
'
)
}
p=
{
3
}
borderRadius=
{
12
}
>
<
Text
variant=
"secondary"
fontSize=
"xs"
>
{
label
}
</
Text
>
<
Text
fontWeight=
{
500
}
fontSize=
"lg"
>
{
value
}
</
Text
>
</
Box
>
);
};
export
default
NumberWidget
;
ui/stats/NumberWidgetSkeleton.tsx
0 → 100644
View file @
e4c18d36
import
{
Box
,
Skeleton
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
const
NumberWidgetSkeleton
=
()
=>
{
return
(
<
Box
border=
"1px"
borderColor=
{
useColorModeValue
(
'
gray.200
'
,
'
gray.600
'
)
}
p=
{
3
}
borderRadius=
{
12
}
>
<
Skeleton
w=
"70px"
h=
"10px"
mb=
{
2
}
/>
<
Skeleton
w=
"100px"
h=
"27px"
/>
</
Box
>
);
};
export
default
NumberWidgetSkeleton
;
ui/stats/NumberWidgetsList.tsx
0 → 100644
View file @
e4c18d36
import
{
Grid
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
Stats
}
from
'
types/api/stats
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
NumberWidget
from
'
./NumberWidget
'
;
import
NumberWidgetSkeleton
from
'
./NumberWidgetSkeleton
'
;
const
skeletonsCount
=
4
;
const
NumberWidgetsList
=
()
=>
{
const
fetch
=
useFetch
();
const
{
data
,
isLoading
}
=
useQuery
<
unknown
,
unknown
,
Stats
>
(
[
QueryKeys
.
stats
],
// TODO: Just temporary. Remove this when the API is ready.
async
()
=>
await
fetch
(
`/node-api/stats`
),
);
return
(
<
Grid
gridTemplateColumns=
{
{
base
:
'
repeat(2, 1fr)
'
,
lg
:
'
repeat(4, 1fr)
'
}
}
gridGap=
{
4
}
>
{
isLoading
?
[
...
Array
(
skeletonsCount
)
]
.
map
((
e
,
i
)
=>
<
NumberWidgetSkeleton
key=
{
i
}
/>)
:
(
<
NumberWidget
label=
"Total blocks"
value=
{
Number
(
data
?.
total_blocks
).
toLocaleString
()
}
/>
)
}
</
Grid
>
);
};
export
default
NumberWidgetsList
;
ui/stats/constants/demo-data.ts
→
ui/stats/constants/demo-
charts-
data.ts
View file @
e4c18d36
import
type
{
TimeChartItem
}
from
'
ui/shared/chart/types
'
;
export
const
demoData
:
Array
<
TimeChartItem
>
=
[
{
date
:
new
Date
(
'
2022-10-17T00:00:00.000Z
'
),
value
:
432670
},
{
export
const
demo
Charts
Data
:
Array
<
TimeChartItem
>
=
[
{
date
:
new
Date
(
'
2022-10-17T00:00:00.000Z
'
),
value
:
432670
},
{
date
:
new
Date
(
'
2022-10-18T00:00:00.000Z
'
),
value
:
370100
,
},
{
date
:
new
Date
(
'
2022-10-19T00:00:00.000Z
'
),
value
:
283234
},
{
date
:
new
Date
(
'
2022-10-20T00:00:00.000Z
'
),
value
:
420910
},
{
...
...
ui/stats/constants/index.ts
View file @
e4c18d36
import
type
{
StatsSectionIds
,
StatsIntervalIds
}
from
'
types/client/stats
'
;
export
const
STATS_SECTIONS
:
{
[
key
in
StatsSectionIds
]:
string
}
=
{
export
const
STATS_SECTIONS
:
{
[
key
in
StatsSectionIds
]
?
:
string
}
=
{
all
:
'
All stats
'
,
accounts
:
'
Accounts
'
,
blocks
:
'
Blocks
'
,
...
...
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