1
+ import { css } from '@emotion/css' ;
1
2
import React , { CSSProperties , FunctionComponent , PropsWithChildren , ReactElement , useMemo } from 'react' ;
3
+ // eslint-disable-next-line no-restricted-imports
2
4
import { useSelector } from 'react-redux' ;
3
5
4
6
import { selectors } from '@grafana/e2e-selectors' ;
5
- import { Tooltip , useTheme2 } from '@grafana/ui' ;
7
+ import { Tooltip } from '@grafana/ui' ;
6
8
import { FnGlobalState } from 'app/core/reducers/fn-slice' ;
7
9
import type { StoreState } from 'app/types' ;
8
10
@@ -14,6 +16,18 @@ interface Props {
14
16
readOnly ?: boolean ;
15
17
}
16
18
19
+ const renderWrapperStyle = css `
20
+ & button ,
21
+ & span ,
22
+ & label ,
23
+ & input {
24
+ height : 24px ;
25
+ font-size : 12px ;
26
+ line-height : 24px ;
27
+ align-self : center;
28
+ }
29
+ ` ;
30
+
17
31
export const PickerRenderer : FunctionComponent < Props > = ( props ) => {
18
32
const PickerToRender = useMemo ( ( ) => variableAdapters . get ( props . variable . type ) . picker , [ props . variable ] ) ;
19
33
@@ -25,36 +39,53 @@ export const PickerRenderer: FunctionComponent<Props> = (props) => {
25
39
< div className = "gf-form" >
26
40
< PickerLabel variable = { props . variable } />
27
41
{ props . variable . hide !== VariableHide . hideVariable && PickerToRender && (
28
- < PickerToRender variable = { props . variable } readOnly = { props . readOnly ?? false } />
42
+ < div className = { renderWrapperStyle } >
43
+ < PickerToRender variable = { props . variable } readOnly = { props . readOnly ?? false } />
44
+ </ div >
29
45
) }
30
46
</ div >
31
47
) ;
32
48
} ;
33
49
34
50
const COMMON_PICKER_LABEL_STYLE : CSSProperties = {
35
- borderRadius : '4px ' ,
51
+ borderRadius : '2px ' ,
36
52
border : 'none' ,
37
- fontWeight : 600 ,
53
+ fontWeight : 400 ,
38
54
fontSize : '12px' ,
55
+ padding : '3px 6px' ,
56
+ letterSpacing : '0.15px' ,
57
+ height : '24px' ,
39
58
} ;
40
59
41
60
function PickerLabel ( { variable } : PropsWithChildren < Props > ) : ReactElement | null {
42
61
const labelOrName = useMemo ( ( ) => variable . label || variable . name , [ variable ] ) ;
43
- const { FNDashboard } = useSelector < StoreState , FnGlobalState > ( ( { fnGlobalState } ) => fnGlobalState ) ;
44
- const theme = useTheme2 ( ) ;
62
+ const { FNDashboard, mode } = useSelector < StoreState , FnGlobalState > ( ( { fnGlobalState } ) => fnGlobalState ) ;
63
+
64
+ const fnLabelStyle = useMemo (
65
+ ( ) => ( {
66
+ ...COMMON_PICKER_LABEL_STYLE ,
67
+ ...( FNDashboard
68
+ ? {
69
+ color : mode === 'light' ? '#2D333E' : '#DBD9D7' ,
70
+ backgroundColor : mode === 'light' ? '#E0E0E0' : '#56524D' ,
71
+ }
72
+ : { } ) ,
73
+ } ) ,
74
+ [ mode , FNDashboard ]
75
+ ) ;
45
76
46
77
if ( variable . hide !== VariableHide . dontHide ) {
47
78
return null ;
48
79
}
49
- const fnLabelOrName = FNDashboard ? labelOrName . replace ( 'druid ' , '' ) : labelOrName ;
80
+ const fnLabelOrName = FNDashboard ? labelOrName . replace ( 'druid_adhoc_filters ' , 'ad-hoc ' ) : labelOrName ;
50
81
51
82
const elementId = `var-${ variable . id } ` ;
52
83
if ( variable . description ) {
53
84
return (
54
85
< Tooltip content = { variable . description } placement = { 'bottom' } >
55
86
< label
56
87
className = "gf-form-label gf-form-label--variable"
57
- style = { FNDashboard ? { ... COMMON_PICKER_LABEL_STYLE , color : theme . colors . text . secondary } : { } }
88
+ style = { fnLabelStyle }
58
89
data-testid = { selectors . pages . Dashboard . SubMenu . submenuItemLabels ( labelOrName ) }
59
90
htmlFor = { elementId }
60
91
>
@@ -66,7 +97,7 @@ function PickerLabel({ variable }: PropsWithChildren<Props>): ReactElement | nul
66
97
return (
67
98
< label
68
99
className = "gf-form-label gf-form-label--variable"
69
- style = { FNDashboard ? { ... COMMON_PICKER_LABEL_STYLE , color : theme . colors . text . secondary } : { } }
100
+ style = { fnLabelStyle }
70
101
data-testid = { selectors . pages . Dashboard . SubMenu . submenuItemLabels ( labelOrName ) }
71
102
htmlFor = { elementId }
72
103
>
0 commit comments