Skip to content

Commit dac78e3

Browse files
committed
Add tooltip to signals
1 parent 18d9cb0 commit dac78e3

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

packages/design-system/src/components/circlePieChart/emptyCirclePieChart.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ import { VictoryPie } from 'victory-pie';
2222
* Internal dependencies
2323
*/
2424
import { COLOR_MAP } from '../../theme/colors';
25+
import Tooltip from './tooltip';
2526

26-
const EmptyCirclePieChart = () => {
27+
const EmptyCirclePieChart = ({
28+
tooltipText = '',
29+
showTooltip = false,
30+
}: {
31+
tooltipText?: string;
32+
showTooltip?: boolean;
33+
}) => {
2734
return (
2835
<div className="w-full h-full relative">
2936
<VictoryPie
@@ -35,6 +42,7 @@ const EmptyCirclePieChart = () => {
3542
<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">
3643
0
3744
</p>
45+
{tooltipText && showTooltip && <Tooltip tooltipText={tooltipText} />}
3846
</div>
3947
);
4048
};

packages/design-system/src/components/circlePieChart/index.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import classNames from 'classnames';
2424
* Internal dependencies.
2525
*/
2626
import EmptyCirclePieChart from './emptyCirclePieChart';
27+
import Tooltip from './tooltip';
2728

2829
interface CirclePieChartProps {
2930
centerCount: number;
@@ -59,7 +60,10 @@ const CirclePieChart = ({
5960
>
6061
<div className="inline-block align-bottom w-16 relative">
6162
{centerCount <= 0 ? (
62-
<EmptyCirclePieChart />
63+
<EmptyCirclePieChart
64+
tooltipText={tooltipText}
65+
showTooltip={showTooltip}
66+
/>
6367
) : (
6468
<div className={`w-full h-full relative ${pieChartExtraClasses}`}>
6569
<VictoryPie
@@ -79,16 +83,7 @@ const CirclePieChart = ({
7983
{centerCount <= MAX_COUNT ? centerCount : MAX_COUNT + '+'}
8084
</p>
8185
{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} />
9287
)}
9388
</div>
9489
)}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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;

0 commit comments

Comments
 (0)