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
57a9e422
Unverified
Commit
57a9e422
authored
May 29, 2020
by
Ryan McKinley
Committed by
GitHub
May 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FieldConfig: implement color picker (#24833)
parent
b703f216
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
4 deletions
+75
-4
packages/grafana-data/src/field/overrides/processors.ts
+3
-1
packages/grafana-ui/src/components/OptionsUI/color.tsx
+72
-3
No files found.
packages/grafana-data/src/field/overrides/processors.ts
View file @
57a9e422
...
...
@@ -109,5 +109,7 @@ export const booleanOverrideProcessor = (
};
export
interface
ColorFieldConfigSettings
{
enableNamedColors
?:
boolean
;
allowUndefined
?:
boolean
;
textWhenUndefined
?:
string
;
// Pick Color
disableNamedColors
?:
boolean
;
}
packages/grafana-ui/src/components/OptionsUI/color.tsx
View file @
57a9e422
import
React
from
'react'
;
import
{
FieldConfigEditorProps
,
ColorFieldConfigSettings
}
from
'@grafana/data'
;
/* import { ColorPicker } from '../ColorPicker/ColorPicker'; */
import
{
FieldConfigEditorProps
,
ColorFieldConfigSettings
,
GrafanaTheme
,
getColorFromHexRgbOrName
,
}
from
'@grafana/data'
;
import
{
ColorPicker
}
from
'../ColorPicker/ColorPicker'
;
import
{
getTheme
,
stylesFactory
}
from
'../../themes'
;
import
{
Icon
}
from
'../Icon/Icon'
;
import
{
css
}
from
'emotion'
;
import
{
ColorPickerTrigger
}
from
'../ColorPicker/ColorPickerTrigger'
;
export
const
ColorValueEditor
:
React
.
FC
<
FieldConfigEditorProps
<
string
,
ColorFieldConfigSettings
>>
=
({
value
,
onChange
,
item
,
})
=>
{
return
<
div
>
todo
</
div
>;
const
{
settings
}
=
item
;
const
theme
=
getTheme
();
const
styles
=
getStyles
(
theme
);
const
color
=
value
||
(
item
.
defaultValue
as
string
)
||
theme
.
colors
.
panelBg
;
return
(
<
ColorPicker
color=
{
color
}
onChange=
{
onChange
}
enableNamedColors=
{
!
settings
.
disableNamedColors
}
>
{
({
ref
,
showColorPicker
,
hideColorPicker
})
=>
{
return
(
<
div
className=
{
styles
.
spot
}
onBlur=
{
hideColorPicker
}
>
<
div
className=
{
styles
.
colorPicker
}
>
<
ColorPickerTrigger
ref=
{
ref
}
onClick=
{
showColorPicker
}
onMouseLeave=
{
hideColorPicker
}
color=
{
getColorFromHexRgbOrName
(
color
,
theme
.
type
)
}
/>
</
div
>
<
div
className=
{
styles
.
colorText
}
onClick=
{
showColorPicker
}
>
{
value
??
settings
.
textWhenUndefined
??
'Pick Color'
}
</
div
>
{
value
&&
settings
.
allowUndefined
&&
(
<
Icon
className=
{
styles
.
trashIcon
}
name=
"trash-alt"
onClick=
{
()
=>
onChange
(
undefined
)
}
/>
)
}
</
div
>
);
}
}
</
ColorPicker
>
);
};
const
getStyles
=
stylesFactory
((
theme
:
GrafanaTheme
)
=>
{
return
{
spot
:
css
`
color:
${
theme
.
colors
.
text
}
;
background:
${
theme
.
colors
.
formInputBg
}
;
padding: 3px;
border: 1px solid
${
theme
.
colors
.
formInputBorder
}
;
display: flex;
flex-direction: row;
align-items: center;
&:hover {
border: 1px solid
${
theme
.
colors
.
formInputBorderHover
}
;
}
`
,
colorPicker
:
css
`
padding: 0
${
theme
.
spacing
.
sm
}
;
`
,
colorText
:
css
`
cursor: pointer;
flex-grow: 1;
`
,
trashIcon
:
css
`
cursor: pointer;
color:
${
theme
.
colors
.
textWeak
}
;
&:hover {
color:
${
theme
.
colors
.
text
}
;
}
`
,
};
});
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