@@ -11,18 +11,6 @@ import {getAnchoredPosition} from '@primer/behaviors'
1111import type { AnchorSide , AnchorAlignment } from '@primer/behaviors'
1212import { isSupported , apply } from '@oddbird/popover-polyfill/fn'
1313
14- // Reusable styles to use for :popover-open (Chrome, Edge) and \:popover-open (Safari, Firefox) classes
15- const popoverStyles = `
16- padding: 0.5em 0.75em;
17- width: max-content;
18- height: fit-content;
19- margin: auto;
20- clip: auto;
21- white-space: normal;
22- /* for scrollbar */
23- overflow: visible;
24- `
25-
2614const animationStyles = `
2715 animation-name: tooltip-appear;
2816 animation-duration: 0.1s;
@@ -32,43 +20,39 @@ const animationStyles = `
3220`
3321
3422const StyledTooltip = styled . div `
35- /* tooltip element should be rendered visually hidden when it is not opened. */
36- width: 1px;
37- height: 1px;
38- padding: 0;
39- margin: -1px;
40- overflow: hidden;
41- clip: rect(0, 0, 0, 0);
42- white-space: nowrap;
43- position: fixed;
44- font: normal normal 11px/1.5 ${ get ( 'fonts.normal' ) } ;
45- -webkit-font-smoothing: subpixel-antialiased;
46- color: ${ get ( 'colors.fg.onEmphasis' ) } ;
47- text-align: center;
48-
49- word-wrap: break-word;
50- background: ${ get ( 'colors.neutral.emphasisPlus' ) } ; //bg--emphasis-color
51- border-radius: ${ get ( 'radii.2' ) } ;
52- border: 0;
53- opacity: 0;
54- max-width: 250px;
55- inset: auto;
56-
57- @media (forced-colors: active) {
58- outline: 1px solid transparent;
23+ /* Overriding the default popover styles */
24+ display: none;
25+ &[popover] {
26+ padding: 0.5em 0.75em;
27+ width: max-content;
28+ margin: auto;
29+ clip: auto;
30+ white-space: normal;
31+ font: normal normal 11px/1.5 ${ get ( 'fonts.normal' ) } ;
32+ -webkit-font-smoothing: subpixel-antialiased;
33+ color: ${ get ( 'colors.fg.onEmphasis' ) } ;
34+ text-align: center;
35+ word-wrap: break-word;
36+ background: ${ get ( 'colors.neutral.emphasisPlus' ) } ;
37+ border-radius: ${ get ( 'radii.2' ) } ;
38+ border: 0;
39+ opacity: 0;
40+ max-width: 250px;
41+ inset: auto;
42+ /* for scrollbar */
43+ overflow: visible;
5944 }
60- /* pollyfil */
61- z-index: 2147483647;
62- display: block;
63-
6445 /* class name in chrome is :popover-open */
65- &:popover-open {
66- ${ popoverStyles }
46+ &[popover] :popover-open {
47+ display: block;
6748 }
68-
6949 /* class name in firefox and safari is \:popover-open */
70- &.\\:popover-open {
71- ${ popoverStyles }
50+ &[popover].\\:popover-open {
51+ display: block;
52+ }
53+
54+ @media (forced-colors: active) {
55+ outline: 1px solid transparent;
7256 }
7357
7458 // This is needed to keep the tooltip open when the user leaves the trigger element to hover tooltip
@@ -284,7 +268,7 @@ export const Tooltip = React.forwardRef(
284268
285269 return (
286270 < TooltipContext . Provider value = { { tooltipId} } >
287- < Box sx = { { display : 'inline-block' } } onMouseLeave = { ( ) => closeTooltip ( ) } >
271+ < Box onMouseLeave = { ( ) => closeTooltip ( ) } >
288272 { React . isValidElement ( child ) &&
289273 React . cloneElement ( child as React . ReactElement < TriggerPropsType > , {
290274 ref : triggerRef ,
0 commit comments