Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
09380399
Unverified
Commit
09380399
authored
Dec 05, 2018
by
Torkel Ödegaard
Committed by
GitHub
Dec 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14331 from grafana/develop-tooltip-css
Portal component
parents
e4e40867
7d6db12f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
20 deletions
+58
-20
public/app/core/components/Portal/Portal.tsx
+35
-0
public/app/core/components/Tooltip/Popper.tsx
+23
-20
No files found.
public/app/core/components/Portal/Portal.tsx
0 → 100644
View file @
09380399
import
{
PureComponent
}
from
'react'
;
import
ReactDOM
from
'react-dom'
;
interface
Props
{
className
?:
string
;
root
?:
HTMLElement
;
}
export
default
class
BodyPortal
extends
PureComponent
<
Props
>
{
node
:
HTMLElement
=
document
.
createElement
(
'div'
);
portalRoot
:
HTMLElement
;
constructor
(
props
)
{
super
(
props
);
const
{
className
,
root
=
document
.
body
}
=
this
.
props
;
if
(
className
)
{
this
.
node
.
classList
.
add
(
className
);
}
this
.
portalRoot
=
root
;
this
.
portalRoot
.
appendChild
(
this
.
node
);
}
componentWillUnmount
()
{
this
.
portalRoot
.
removeChild
(
this
.
node
);
}
render
()
{
return
ReactDOM
.
createPortal
(
this
.
props
.
children
,
this
.
node
);
}
}
public/app/core/components/Tooltip/Popper.tsx
View file @
09380399
import
React
,
{
PureComponent
}
from
'react'
;
import
Portal
from
'app/core/components/Portal/Portal'
;
import
{
Manager
,
Popper
as
ReactPopper
,
Reference
}
from
'react-popper'
;
import
Transition
from
'react-transition-group/Transition'
;
...
...
@@ -38,27 +39,29 @@ class Popper extends PureComponent<Props> {
</
Reference
>
<
Transition
in=
{
show
}
timeout=
{
100
}
mountOnEnter=
{
true
}
unmountOnExit=
{
true
}
>
{
transitionState
=>
(
<
ReactPopper
placement=
{
placement
}
>
{
({
ref
,
style
,
placement
,
arrowProps
})
=>
{
return
(
<
div
ref=
{
ref
}
style=
{
{
...
style
,
...
defaultTransitionStyles
,
...
transitionStyles
[
transitionState
],
}
}
data
-
placement=
{
placement
}
className=
"popper"
>
<
div
className=
"popper__background"
>
{
renderContent
(
content
)
}
<
div
ref=
{
arrowProps
.
ref
}
data
-
placement=
{
placement
}
className=
"popper__arrow"
/>
<
Portal
>
<
ReactPopper
placement=
{
placement
}
>
{
({
ref
,
style
,
placement
,
arrowProps
})
=>
{
return
(
<
div
ref=
{
ref
}
style=
{
{
...
style
,
...
defaultTransitionStyles
,
...
transitionStyles
[
transitionState
],
}
}
data
-
placement=
{
placement
}
className=
"popper"
>
<
div
className=
"popper__background"
>
{
renderContent
(
content
)
}
<
div
ref=
{
arrowProps
.
ref
}
data
-
placement=
{
placement
}
className=
"popper__arrow"
/>
</
div
>
</
div
>
</
div
>
);
}
}
</
ReactPopper
>
);
}
}
</
ReactPopper
>
</
Portal
>
)
}
</
Transition
>
</
Manager
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment