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