File tree 3 files changed +23
-10
lines changed
3 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ const config = allBuildFormats.map(
98
98
replaceBeforeSaveFile ( {
99
99
// this only works for the react-tooltip.css because it's the first file
100
100
// writen in our build process before the javascript files.
101
- "'temp-content-for-styles '" : 'file:react-tooltip.css' ,
102
- '"temp-content-for-styles "' : 'file:react-tooltip.css' ,
101
+ "'react-tooltip-css-placeholder '" : 'file:react-tooltip.css' ,
102
+ '"react-tooltip-css-placeholder "' : 'file:react-tooltip.css' ,
103
103
} ) ,
104
104
]
105
105
Original file line number Diff line number Diff line change 1
1
import './tokens.css'
2
2
3
- import styleInject from 'utils/style-inject '
3
+ import { injectStyle } from 'utils/handle-style '
4
4
5
5
import type {
6
6
ChildrenType ,
@@ -17,10 +17,9 @@ import type { ITooltipController } from './components/TooltipController/TooltipC
17
17
import type { ITooltipWrapper } from './components/TooltipProvider/TooltipProviderTypes'
18
18
19
19
// this content will be replaced in build time with the `react-tooltip.css` builded content
20
- const TooltipStyles = 'temp-content-for-styles '
20
+ const TooltipStyles = 'react-tooltip-css-placeholder '
21
21
22
- // @ts -ignore
23
- styleInject ( TooltipStyles )
22
+ injectStyle ( TooltipStyles )
24
23
25
24
export { TooltipController as Tooltip } from './components/TooltipController'
26
25
export { TooltipProvider , TooltipWrapper } from './components/TooltipProvider'
@@ -37,3 +36,5 @@ export type {
37
36
IPosition ,
38
37
Middleware ,
39
38
}
39
+
40
+ export { removeStyle } from './utils/handle-style'
Original file line number Diff line number Diff line change 1
- function styleInject ( css : string , ref ?: any ) {
1
+ const REACT_TOOLTIP_STYLES_ID = 'react-tooltip-styles'
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ function injectStyle ( css : string , ref ?: any ) {
2
5
if ( ! ref ) {
3
6
// eslint-disable-next-line no-param-reassign
4
7
ref = { }
5
8
}
6
9
const { insertAt } = ref
7
10
8
- if ( ! css || typeof document === 'undefined' || document . getElementById ( 'react-tooltip-styles' ) ) {
11
+ if ( ! css || typeof document === 'undefined' || document . getElementById ( REACT_TOOLTIP_STYLES_ID ) ) {
9
12
return
10
13
}
11
14
12
15
const head = document . head || document . getElementsByTagName ( 'head' ) [ 0 ]
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
17
const style : any = document . createElement ( 'style' )
14
- style . id = 'react-tooltip-styles'
18
+ style . id = REACT_TOOLTIP_STYLES_ID
15
19
style . type = 'text/css'
16
20
17
21
if ( insertAt === 'top' ) {
@@ -31,4 +35,12 @@ function styleInject(css: string, ref?: any) {
31
35
}
32
36
}
33
37
34
- export default styleInject
38
+ function removeStyle ( ) {
39
+ const style = document . getElementById ( REACT_TOOLTIP_STYLES_ID )
40
+ if ( ! style ) {
41
+ return
42
+ }
43
+ style . remove ( )
44
+ }
45
+
46
+ export { injectStyle , removeStyle }
You can’t perform that action at this time.
0 commit comments