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
eafb2ab2
Commit
eafb2ab2
authored
Jun 02, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
skeletons for stats counters
parent
59c5442d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
42 deletions
+38
-42
stats.ts
stubs/stats.ts
+8
-1
stats.ts
types/api/stats.ts
+1
-1
NumberWidget.tsx
ui/stats/NumberWidget.tsx
+17
-9
NumberWidgetSkeleton.tsx
ui/stats/NumberWidgetSkeleton.tsx
+0
-20
NumberWidgetsList.tsx
ui/stats/NumberWidgetsList.tsx
+12
-11
No files found.
stubs/stats.ts
View file @
eafb2ab2
import
type
{
HomeStats
,
StatsChartsSection
}
from
'
types/api/stats
'
;
import
type
{
Counter
,
HomeStats
,
StatsChartsSection
}
from
'
types/api/stats
'
;
export
const
HOMEPAGE_STATS
:
HomeStats
=
{
export
const
HOMEPAGE_STATS
:
HomeStats
=
{
average_block_time
:
14346
,
average_block_time
:
14346
,
...
@@ -53,3 +53,10 @@ export const STATS_CHARTS_SECTION: StatsChartsSection = {
...
@@ -53,3 +53,10 @@ export const STATS_CHARTS_SECTION: StatsChartsSection = {
export
const
STATS_CHARTS
=
{
export
const
STATS_CHARTS
=
{
sections
:
[
STATS_CHARTS_SECTION
],
sections
:
[
STATS_CHARTS_SECTION
],
};
};
export
const
STATS_COUNTER
:
Counter
=
{
id
:
'
stub
'
,
value
:
'
9074405
'
,
title
:
'
Placeholder Counter
'
,
units
:
''
,
};
types/api/stats.ts
View file @
eafb2ab2
...
@@ -23,7 +23,7 @@ export type Counters = {
...
@@ -23,7 +23,7 @@ export type Counters = {
counters
:
Array
<
Counter
>
;
counters
:
Array
<
Counter
>
;
}
}
type
Counter
=
{
export
type
Counter
=
{
id
:
string
;
id
:
string
;
value
:
string
;
value
:
string
;
title
:
string
;
title
:
string
;
...
...
ui/stats/NumberWidget.tsx
View file @
eafb2ab2
import
{
Box
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Skeleton
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
type
Props
=
{
type
Props
=
{
label
:
string
;
label
:
string
;
value
:
string
;
value
:
string
;
isLoading
?:
boolean
;
}
}
const
NumberWidget
=
({
label
,
value
}:
Props
)
=>
{
const
NumberWidget
=
({
label
,
value
,
isLoading
}:
Props
)
=>
{
const
bgColor
=
useColorModeValue
(
'
blue.50
'
,
'
blue.800
'
);
const
skeletonBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
return
(
return
(
<
Box
<
Box
bg=
{
useColorModeValue
(
'
blue.50
'
,
'
blue.800
'
)
}
bg=
{
isLoading
?
skeletonBgColor
:
bgColor
}
px=
{
3
}
px=
{
3
}
py=
{
{
base
:
2
,
lg
:
3
}
}
py=
{
{
base
:
2
,
lg
:
3
}
}
borderRadius=
{
12
}
borderRadius=
{
12
}
>
>
<
Text
<
Skeleton
variant=
"secondary"
isLoaded=
{
!
isLoading
}
color=
"text_secondary"
fontSize=
"xs"
fontSize=
"xs"
w=
"fit-content"
>
>
{
label
}
<
span
>
{
label
}
</
span
>
</
Text
>
</
Skeleton
>
<
Text
<
Skeleton
isLoaded=
{
!
isLoading
}
fontWeight=
{
500
}
fontWeight=
{
500
}
fontSize=
"lg"
fontSize=
"lg"
w=
"fit-content"
>
>
{
value
}
{
value
}
</
Text
>
</
Skeleton
>
</
Box
>
</
Box
>
);
);
};
};
...
...
ui/stats/NumberWidgetSkeleton.tsx
deleted
100644 → 0
View file @
59c5442d
import
{
Box
,
Skeleton
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
const
NumberWidgetSkeleton
=
()
=>
{
const
bgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
return
(
<
Box
backgroundColor=
{
bgColor
}
p=
{
3
}
borderRadius=
{
12
}
>
<
Skeleton
w=
"70px"
h=
"10px"
mb=
{
2
}
/>
<
Skeleton
w=
"100px"
h=
"27px"
/>
</
Box
>
);
};
export
default
NumberWidgetSkeleton
;
ui/stats/NumberWidgetsList.tsx
View file @
eafb2ab2
...
@@ -2,18 +2,17 @@ import { Grid } from '@chakra-ui/react';
...
@@ -2,18 +2,17 @@ import { Grid } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
{
STATS_COUNTER
}
from
'
stubs/stats
'
;
import
DataFetchAlert
from
'
../shared/DataFetchAlert
'
;
import
DataFetchAlert
from
'
../shared/DataFetchAlert
'
;
import
NumberWidget
from
'
./NumberWidget
'
;
import
NumberWidget
from
'
./NumberWidget
'
;
import
NumberWidgetSkeleton
from
'
./NumberWidgetSkeleton
'
;
const
skeletonsCount
=
8
;
const
NumberWidgetsList
=
()
=>
{
const
NumberWidgetsList
=
()
=>
{
const
{
data
,
isLoading
,
isError
}
=
useApiQuery
(
'
stats_counters
'
);
const
{
data
,
isPlaceholderData
,
isError
}
=
useApiQuery
(
'
stats_counters
'
,
{
queryOptions
:
{
const
skeletonElement
=
[
...
Array
(
skeletonsCount
)
]
placeholderData
:
{
counters
:
Array
(
10
).
fill
(
STATS_COUNTER
)
},
.
map
((
e
,
i
)
=>
<
NumberWidgetSkeleton
key=
{
i
}
/>);
},
});
if
(
isError
)
{
if
(
isError
)
{
return
<
DataFetchAlert
/>;
return
<
DataFetchAlert
/>;
...
@@ -24,17 +23,19 @@ const NumberWidgetsList = () => {
...
@@ -24,17 +23,19 @@ const NumberWidgetsList = () => {
gridTemplateColumns=
{
{
base
:
'
repeat(2, 1fr)
'
,
lg
:
'
repeat(4, 1fr)
'
}
}
gridTemplateColumns=
{
{
base
:
'
repeat(2, 1fr)
'
,
lg
:
'
repeat(4, 1fr)
'
}
}
gridGap=
{
4
}
gridGap=
{
4
}
>
>
{
isLoading
?
skeletonElement
:
{
data
?.
counters
?.
map
(({
id
,
title
,
value
,
units
})
=>
{
data
?.
counters
?.
map
(({
id
,
title
,
value
,
units
}
,
index
)
=>
{
return
(
return
(
<
NumberWidget
<
NumberWidget
key=
{
id
}
key=
{
id
+
(
isPlaceholderData
?
index
:
''
)
}
label=
{
title
}
label=
{
title
}
value=
{
`${ Number(value).toLocaleString(undefined, { maximumFractionDigits: 3, notation: 'compact' }) } ${ units ? units : '' }`
}
value=
{
`${ Number(value).toLocaleString(undefined, { maximumFractionDigits: 3, notation: 'compact' }) } ${ units ? units : '' }`
}
isLoading=
{
isPlaceholderData
}
/>
/>
);
);
})
}
})
}
</
Grid
>
</
Grid
>
);
);
};
};
...
...
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