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
75a9889a
Unverified
Commit
75a9889a
authored
Sep 19, 2023
by
tom goriunov
Committed by
GitHub
Sep 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Charts&Stats: add tooltips to number charts (#1192)
Fixes #1151
parent
c389dc76
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
19 deletions
+40
-19
stats.ts
stubs/stats.ts
+1
-0
stats.ts
types/api/stats.ts
+1
-0
NumberWidget.tsx
ui/stats/NumberWidget.tsx
+36
-18
NumberWidgetsList.tsx
ui/stats/NumberWidgetsList.tsx
+2
-1
No files found.
stubs/stats.ts
View file @
75a9889a
...
@@ -58,5 +58,6 @@ export const STATS_COUNTER: Counter = {
...
@@ -58,5 +58,6 @@ export const STATS_COUNTER: Counter = {
id
:
'
stub
'
,
id
:
'
stub
'
,
value
:
'
9074405
'
,
value
:
'
9074405
'
,
title
:
'
Placeholder Counter
'
,
title
:
'
Placeholder Counter
'
,
description
:
'
Placeholder description
'
,
units
:
''
,
units
:
''
,
};
};
types/api/stats.ts
View file @
75a9889a
...
@@ -27,6 +27,7 @@ export type Counter = {
...
@@ -27,6 +27,7 @@ export type Counter = {
id
:
string
;
id
:
string
;
value
:
string
;
value
:
string
;
title
:
string
;
title
:
string
;
description
?:
string
;
units
:
string
;
units
:
string
;
}
}
...
...
ui/stats/NumberWidget.tsx
View file @
75a9889a
import
{
Box
,
Skeleton
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Flex
,
Skeleton
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
Hint
from
'
ui/shared/Hint
'
;
type
Props
=
{
type
Props
=
{
label
:
string
;
label
:
string
;
description
?:
string
;
value
:
string
;
value
:
string
;
isLoading
?:
boolean
;
isLoading
?:
boolean
;
}
}
const
NumberWidget
=
({
label
,
value
,
isLoading
}:
Props
)
=>
{
const
NumberWidget
=
({
label
,
value
,
isLoading
,
description
}:
Props
)
=>
{
const
bgColor
=
useColorModeValue
(
'
blue.50
'
,
'
blue.800
'
);
const
bgColor
=
useColorModeValue
(
'
blue.50
'
,
'
blue.800
'
);
const
skeletonBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
const
skeletonBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
const
hintColor
=
useColorModeValue
(
'
gray.600
'
,
'
gray.400
'
);
return
(
return
(
<
Box
<
Flex
alignItems=
"flex-start"
bg=
{
isLoading
?
skeletonBgColor
:
bgColor
}
bg=
{
isLoading
?
skeletonBgColor
:
bgColor
}
px=
{
3
}
px=
{
3
}
py=
{
{
base
:
2
,
lg
:
3
}
}
py=
{
{
base
:
2
,
lg
:
3
}
}
borderRadius=
{
12
}
borderRadius=
{
12
}
justifyContent=
"space-between"
columnGap=
{
3
}
>
<
Box
>
>
<
Skeleton
<
Skeleton
isLoaded=
{
!
isLoading
}
isLoaded=
{
!
isLoading
}
...
@@ -35,7 +44,16 @@ const NumberWidget = ({ label, value, isLoading }: Props) => {
...
@@ -35,7 +44,16 @@ const NumberWidget = ({ label, value, isLoading }: Props) => {
>
>
{
value
}
{
value
}
</
Skeleton
>
</
Skeleton
>
</
Box
>
</
Box
>
<
Skeleton
isLoaded=
{
!
isLoading
}
alignSelf=
"center"
borderRadius=
"base"
>
<
Hint
label=
{
description
}
boxSize=
{
6
}
color=
{
hintColor
}
/>
</
Skeleton
>
</
Flex
>
);
);
};
};
...
...
ui/stats/NumberWidgetsList.tsx
View file @
75a9889a
...
@@ -24,7 +24,7 @@ const NumberWidgetsList = () => {
...
@@ -24,7 +24,7 @@ const NumberWidgetsList = () => {
gridGap=
{
4
}
gridGap=
{
4
}
>
>
{
{
data
?.
counters
?.
map
(({
id
,
title
,
value
,
units
},
index
)
=>
{
data
?.
counters
?.
map
(({
id
,
title
,
value
,
units
,
description
},
index
)
=>
{
return
(
return
(
<
NumberWidget
<
NumberWidget
...
@@ -32,6 +32,7 @@ const NumberWidgetsList = () => {
...
@@ -32,6 +32,7 @@ const NumberWidgetsList = () => {
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
}
isLoading=
{
isPlaceholderData
}
description=
{
description
}
/>
/>
);
);
})
})
...
...
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