File tree Expand file tree Collapse file tree 3 files changed +44
-12
lines changed
packages/design-system/src/components/circlePieChart Expand file tree Collapse file tree 3 files changed +44
-12
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,15 @@ import { VictoryPie } from 'victory-pie';
22
22
* Internal dependencies
23
23
*/
24
24
import { COLOR_MAP } from '../../theme/colors' ;
25
+ import Tooltip from './tooltip' ;
25
26
26
- const EmptyCirclePieChart = ( ) => {
27
+ const EmptyCirclePieChart = ( {
28
+ tooltipText = '' ,
29
+ showTooltip = false ,
30
+ } : {
31
+ tooltipText ?: string ;
32
+ showTooltip ?: boolean ;
33
+ } ) => {
27
34
return (
28
35
< div className = "w-full h-full relative" >
29
36
< VictoryPie
@@ -35,6 +42,7 @@ const EmptyCirclePieChart = () => {
35
42
< p className = "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-center opacity-40 text-2xl leading-4 dark:text-bright-gray" >
36
43
0
37
44
</ p >
45
+ { tooltipText && showTooltip && < Tooltip tooltipText = { tooltipText } /> }
38
46
</ div >
39
47
) ;
40
48
} ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import classNames from 'classnames';
24
24
* Internal dependencies.
25
25
*/
26
26
import EmptyCirclePieChart from './emptyCirclePieChart' ;
27
+ import Tooltip from './tooltip' ;
27
28
28
29
interface CirclePieChartProps {
29
30
centerCount : number ;
@@ -59,7 +60,10 @@ const CirclePieChart = ({
59
60
>
60
61
< div className = "inline-block align-bottom w-16 relative" >
61
62
{ centerCount <= 0 ? (
62
- < EmptyCirclePieChart />
63
+ < EmptyCirclePieChart
64
+ tooltipText = { tooltipText }
65
+ showTooltip = { showTooltip }
66
+ />
63
67
) : (
64
68
< div className = { `w-full h-full relative ${ pieChartExtraClasses } ` } >
65
69
< VictoryPie
@@ -79,16 +83,7 @@ const CirclePieChart = ({
79
83
{ centerCount <= MAX_COUNT ? centerCount : MAX_COUNT + '+' }
80
84
</ p >
81
85
{ tooltipText && showTooltip && (
82
- < div
83
- className = "
84
- absolute left-1/2 bottom-0 translate-x-[-50%] translate-y-[110%]
85
- bg-black/80 text-white text-xs rounded px-2 py-1 shadow-lg
86
- animate-fadeIn z-10 pointer-events-none text-center
87
- max-w-xs min-w-[80px] w-max whitespace-pre-line transition-opacity duration-300
88
- "
89
- >
90
- { tooltipText }
91
- </ div >
86
+ < Tooltip tooltipText = { tooltipText } />
92
87
) }
93
88
</ div >
94
89
) }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * External dependencies.
18
+ */
19
+ import React from 'react' ;
20
+
21
+ const Tooltip = ( { tooltipText } : { tooltipText ?: string } ) => {
22
+ return (
23
+ < div className = "absolute left-1/2 bottom-0 translate-x-[-50%] translate-y-[110%] bg-black/80 text-white text-xs rounded px-2 py-1 shadow-lg animate-fadeIn z-10 pointer-events-none text-center max-w-xs min-w-[80px] w-max whitespace-pre-line transition-opacity duration-300" >
24
+ { tooltipText }
25
+ </ div >
26
+ ) ;
27
+ } ;
28
+
29
+ export default Tooltip ;
You can’t perform that action at this time.
0 commit comments