1
- import { type Interpolation , type Theme , useTheme } from "@emotion/react" ;
1
+ import { useTheme , type Interpolation , type Theme } from "@emotion/react" ;
2
2
import type { AlertProps } from "components/Alert/Alert" ;
3
3
import { Button , type ButtonProps } from "components/Button/Button" ;
4
- import {
5
- Popover ,
6
- PopoverContent ,
7
- PopoverTrigger ,
8
- usePopover ,
9
- } from "components/deprecated/Popover/Popover" ;
10
4
import { Pill } from "components/Pill/Pill" ;
11
- import type { FC , ReactNode } from "react" ;
5
+ import {
6
+ Tooltip ,
7
+ TooltipContent ,
8
+ TooltipProvider ,
9
+ TooltipTrigger ,
10
+ } from "components/Tooltip/Tooltip" ;
11
+ import { useState , type FC , type ReactNode } from "react" ;
12
12
import type { ThemeRole } from "theme/roles" ;
13
13
14
14
export type NotificationItem = {
@@ -22,55 +22,62 @@ type NotificationsProps = {
22
22
items : NotificationItem [ ] ;
23
23
severity : ThemeRole ;
24
24
icon : ReactNode ;
25
+ isTooltipOpen : boolean ;
25
26
} ;
26
27
27
28
export const Notifications : FC < NotificationsProps > = ( {
28
29
items,
29
30
severity,
30
31
icon,
31
32
} ) => {
33
+ const [ isOpen , setIsOpen ] = useState ( false ) ;
32
34
const theme = useTheme ( ) ;
33
35
34
36
return (
35
- < Popover mode = "hover" >
36
- < PopoverTrigger >
37
- < div
38
- css = { styles . pillContainer }
39
- data-testid = { `${ severity } -notifications` }
40
- >
41
- < NotificationPill items = { items } severity = { severity } icon = { icon } />
42
- </ div >
43
- </ PopoverTrigger >
44
- < PopoverContent
45
- horizontal = "right"
46
- css = { {
47
- "& .MuiPaper-root" : {
37
+ < TooltipProvider >
38
+ < Tooltip open = { isOpen } onOpenChange = { setIsOpen } delayDuration = { 0 } >
39
+ < TooltipTrigger asChild >
40
+ < div
41
+ css = { styles . pillContainer }
42
+ data-testid = { `${ severity } -notifications` }
43
+ >
44
+ < NotificationPill
45
+ items = { items }
46
+ severity = { severity }
47
+ icon = { icon }
48
+ isTooltipOpen = { isOpen }
49
+ />
50
+ </ div >
51
+ </ TooltipTrigger >
52
+ < TooltipContent
53
+ align = "end"
54
+ collisionPadding = { 16 }
55
+ className = "max-w-[400px] p-0 bg-surface-secondary border-surface-quaternary text-sm text-white"
56
+ style = { {
48
57
borderColor : theme . roles [ severity ] . outline ,
49
- maxWidth : 400 ,
50
- } ,
51
- } }
52
- >
53
- { items . map ( ( n ) => (
54
- < NotificationItem notification = { n } key = { n . title } />
55
- ) ) }
56
- </ PopoverContent >
57
- </ Popover >
58
+ } }
59
+ >
60
+ { items . map ( ( n ) => (
61
+ < NotificationItem notification = { n } key = { n . title } />
62
+ ) ) }
63
+ </ TooltipContent >
64
+ </ Tooltip >
65
+ </ TooltipProvider >
58
66
) ;
59
67
} ;
60
68
61
69
const NotificationPill : FC < NotificationsProps > = ( {
62
70
items,
63
71
severity,
64
72
icon,
73
+ isTooltipOpen,
65
74
} ) => {
66
- const popover = usePopover ( ) ;
67
-
68
75
return (
69
76
< Pill
70
77
icon = { icon }
71
78
css = { ( theme ) => ( {
72
79
"& svg" : { color : theme . roles [ severity ] . outline } ,
73
- borderColor : popover . open ? theme . roles [ severity ] . outline : undefined ,
80
+ borderColor : isTooltipOpen ? theme . roles [ severity ] . outline : undefined ,
74
81
} ) }
75
82
>
76
83
{ items . length }
@@ -99,7 +106,7 @@ export const NotificationActionButton: FC<ButtonProps> = (props) => {
99
106
} ;
100
107
101
108
const styles = {
102
- // Adds some spacing from the popover content
109
+ // Adds some spacing from the Tooltip content
103
110
pillContainer : {
104
111
padding : "8px 0" ,
105
112
} ,
0 commit comments