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
4384eb2f
Commit
4384eb2f
authored
Jan 17, 2019
by
Dominik Prokop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move tooltip themes to Tooltip component making Popper/PopperController theme agnostic
parent
ac378790
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
25 deletions
+24
-25
packages/grafana-ui/src/components/Tooltip/Popper.tsx
+5
-12
packages/grafana-ui/src/components/Tooltip/PopperController.tsx
+1
-6
packages/grafana-ui/src/components/Tooltip/Tooltip.tsx
+12
-1
packages/grafana-ui/src/components/Tooltip/_Tooltip.scss
+4
-4
public/app/features/dashboard/dashgrid/DataPanel.tsx
+1
-1
public/app/features/dashboard/panel_editor/PanelEditor.tsx
+1
-1
No files found.
packages/grafana-ui/src/components/Tooltip/Popper.tsx
View file @
4384eb2f
...
...
@@ -4,11 +4,6 @@ import { Manager, Popper as ReactPopper } from 'react-popper';
import
{
Portal
}
from
'@grafana/ui'
;
import
Transition
from
'react-transition-group/Transition'
;
export
enum
Themes
{
Default
=
'popper__background--default'
,
Error
=
'popper__background--error'
,
Brand
=
'popper__background--brand'
,
}
const
defaultTransitionStyles
=
{
transition
:
'opacity 200ms linear'
,
...
...
@@ -22,22 +17,20 @@ const transitionStyles: {[key: string]: object} = {
exiting
:
{
opacity
:
0
},
};
interface
Props
extends
React
.
DOM
Attributes
<
HTMLDivElement
>
{
interface
Props
extends
React
.
HTML
Attributes
<
HTMLDivElement
>
{
renderContent
:
(
content
:
any
)
=>
any
;
show
:
boolean
;
placement
?:
PopperJS
.
Placement
;
content
:
string
|
((
props
:
any
)
=>
JSX
.
Element
);
referenceElement
:
PopperJS
.
ReferenceObject
;
theme
?:
Themes
;
}
class
Popper
extends
PureComponent
<
Props
>
{
render
()
{
const
{
renderContent
,
show
,
placement
,
onMouseEnter
,
onMouseLeave
,
the
me
}
=
this
.
props
;
const
{
renderContent
,
show
,
placement
,
onMouseEnter
,
onMouseLeave
,
classNa
me
}
=
this
.
props
;
const
{
content
}
=
this
.
props
;
const
popperBackgroundClassName
=
'popper__background'
+
(
theme
?
' '
+
theme
:
''
);
return
(
<
Manager
>
<
Transition
in=
{
show
}
timeout=
{
100
}
mountOnEnter=
{
true
}
unmountOnExit=
{
true
}
>
...
...
@@ -56,9 +49,9 @@ class Popper extends PureComponent<Props> {
...
transitionStyles
[
transitionState
],
}
}
data
-
placement=
{
placement
}
className=
"popper"
className=
{
`popper`
}
>
<
div
className=
{
popperBackgroundC
lassName
}
>
<
div
className=
{
c
lassName
}
>
{
renderContent
(
content
)
}
<
div
ref=
{
arrowProps
.
ref
}
data
-
placement=
{
placement
}
className=
"popper__arrow"
/>
</
div
>
...
...
packages/grafana-ui/src/components/Tooltip/PopperController.tsx
View file @
4384eb2f
import
React
from
'react'
;
import
*
as
PopperJS
from
'popper.js'
;
import
{
Themes
}
from
'./Popper'
;
type
PopperContent
=
string
|
(()
=>
JSX
.
Element
);
...
...
@@ -10,7 +9,6 @@ export interface UsingPopperProps {
content
:
PopperContent
;
children
:
JSX
.
Element
;
renderContent
?:
(
content
:
PopperContent
)
=>
JSX
.
Element
;
theme
?:
Themes
;
}
type
PopperControllerRenderProp
=
(
...
...
@@ -21,7 +19,6 @@ type PopperControllerRenderProp = (
placement
:
PopperJS
.
Placement
;
content
:
string
|
((
props
:
any
)
=>
JSX
.
Element
);
renderContent
:
(
content
:
any
)
=>
any
;
theme
?:
Themes
;
}
)
=>
JSX
.
Element
;
...
...
@@ -30,7 +27,6 @@ interface Props {
content
:
PopperContent
;
className
?:
string
;
children
:
PopperControllerRenderProp
;
theme
?:
Themes
;
}
interface
State
{
...
...
@@ -83,7 +79,7 @@ class PopperController extends React.Component<Props, State> {
}
render
()
{
const
{
children
,
content
,
theme
}
=
this
.
props
;
const
{
children
,
content
}
=
this
.
props
;
const
{
show
,
placement
}
=
this
.
state
;
return
children
(
this
.
showPopper
,
this
.
hidePopper
,
{
...
...
@@ -91,7 +87,6 @@ class PopperController extends React.Component<Props, State> {
placement
,
content
,
renderContent
:
this
.
renderContent
,
theme
,
});
}
}
...
...
packages/grafana-ui/src/components/Tooltip/Tooltip.tsx
View file @
4384eb2f
...
...
@@ -3,8 +3,18 @@ import * as PopperJS from 'popper.js';
import
Popper
from
'./Popper'
;
import
PopperController
,
{
UsingPopperProps
}
from
'./PopperController'
;
export
const
Tooltip
=
({
children
,
renderContent
,
...
controllerProps
}:
UsingPopperProps
)
=>
{
export
enum
Themes
{
Default
=
'popper__background--default'
,
Error
=
'popper__background--error'
,
Brand
=
'popper__background--brand'
,
}
interface
TooltipProps
extends
UsingPopperProps
{
theme
?:
Themes
;
}
export
const
Tooltip
=
({
children
,
renderContent
,
theme
,
...
controllerProps
}:
TooltipProps
)
=>
{
const
tooltipTriggerRef
=
createRef
<
PopperJS
.
ReferenceObject
>
();
const
popperBackgroundClassName
=
'popper__background'
+
(
theme
?
' '
+
theme
:
''
);
return
(
<
PopperController
{
...
controllerProps
}
>
...
...
@@ -17,6 +27,7 @@ export const Tooltip = ({ children, renderContent, ...controllerProps }: UsingPo
onMouseEnter=
{
showPopper
}
onMouseLeave=
{
hidePopper
}
referenceElement=
{
tooltipTriggerRef
.
current
}
className=
{
popperBackgroundClassName
}
/>
)
}
{
React
.
cloneElement
(
children
,
{
...
...
packages/grafana-ui/src/components/Tooltip/_Tooltip.scss
View file @
4384eb2f
$popper-margin-from-ref
:
5px
;
@mixin
popper-theme
(
$backgroundColor
,
$arrowColor
)
{
background
:
$backgroundColor
;
.popper__arrow
{
...
...
@@ -22,6 +21,10 @@ $popper-margin-from-ref: 5px;
box-shadow
:
0
0
2px
rgba
(
0
,
0
,
0
,
0
.5
);
padding
:
10px
;
.popper__arrow
{
border-color
:
$tooltipBackground
;
}
// Themes
&
.popper__background--error
{
@include
popper-theme
(
$tooltipBackgroundError
,
$tooltipBackgroundError
);
...
...
@@ -41,9 +44,6 @@ $popper-margin-from-ref: 5px;
margin
:
0px
;
}
.popper__arrow
{
border-color
:
$tooltipBackground
;
}
// Top
.popper
[
data-placement
^=
'top'
]
{
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
4384eb2f
// Library
import
React
,
{
Component
}
from
'react'
;
import
{
Tooltip
}
from
'@grafana/ui'
;
import
{
Themes
}
from
'@grafana/ui/src/components/Tooltip/
Popper
'
;
import
{
Themes
}
from
'@grafana/ui/src/components/Tooltip/
Tooltip
'
;
import
ErrorBoundary
from
'app/core/components/ErrorBoundary/ErrorBoundary'
;
...
...
public/app/features/dashboard/panel_editor/PanelEditor.tsx
View file @
4384eb2f
...
...
@@ -16,7 +16,7 @@ import { DashboardModel } from '../dashboard_model';
import
{
PanelPlugin
}
from
'app/types/plugins'
;
import
{
Tooltip
}
from
'@grafana/ui'
;
import
{
Themes
}
from
'@grafana/ui/src/components/Tooltip/
Popper
'
;
import
{
Themes
}
from
'@grafana/ui/src/components/Tooltip/
Tooltip
'
;
interface
PanelEditorProps
{
panel
:
PanelModel
;
...
...
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