Skip to content

Commit 26f66bb

Browse files
gurinder39GurinderRawala
authored andcommitted
changed query filter designs (#59)
1 parent 7caf019 commit 26f66bb

File tree

2 files changed

+64
-13
lines changed

2 files changed

+64
-13
lines changed

public/app/features/dashboard/components/SubMenu/SubMenu.tsx

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { css } from '@emotion/css';
2-
import { PureComponent } from 'react';
3-
import * as React from 'react';
2+
import FilterListIcon from '@mui/icons-material/FilterList';
3+
import { Box, styled } from '@mui/material';
4+
import React, { FC, PureComponent } from 'react';
45
import { connect, MapStateToProps } from 'react-redux';
56

67
import { AnnotationQuery, DataQuery, TypedVariableModel, GrafanaTheme2 } from '@grafana/data';
@@ -13,7 +14,7 @@ import { DashboardModel } from '../../state';
1314
import { Annotations } from './Annotations';
1415
import { DashboardLinks } from './DashboardLinks';
1516
import { SubMenuItems } from './SubMenuItems';
16-
import { VariableModel } from 'app/features/variables/types';
17+
// import { VariableModel } from 'app/features/variables/types';
1718
import { Themeable2, stylesFactory, withTheme2 } from '@grafana-ui';
1819
import { DashboardLink } from '@grafana/schema/dist/esm/index';
1920

@@ -60,6 +61,7 @@ class SubMenuUnConnected extends PureComponent<Props> {
6061
return (
6162
<div className="submenu-controls">
6263
<form aria-label="Template variables" className={styles}>
64+
<FilterWithIcon />
6365
<SubMenuItems
6466
variables={variables}
6567
readOnly={readOnlyVariables}
@@ -112,3 +114,20 @@ const getStyles = stylesFactory((theme: GrafanaTheme2) => {
112114
export const SubMenu = withTheme2(connect(mapStateToProps)(SubMenuUnConnected));
113115

114116
SubMenu.displayName = 'SubMenu';
117+
118+
const FilterWithIcon: FC = () => (
119+
<FilterWithIconStyled>
120+
<FilterListIcon sx={{ color: '#3A785E' }} />
121+
FILTERS
122+
</FilterWithIconStyled>
123+
);
124+
125+
const FilterWithIconStyled = styled(Box)({
126+
display: 'flex',
127+
gap: 1,
128+
alignItems: 'center',
129+
color: '#3A785E',
130+
fontWeight: 600,
131+
lineHeight: '160%',
132+
fontSize: 12,
133+
});

public/app/features/variables/pickers/PickerRenderer.tsx

+42-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import { css } from '@emotion/css';
12
import React, { CSSProperties, FunctionComponent, PropsWithChildren, ReactElement, useMemo } from 'react';
3+
import { Stack } from '@mui/material';
4+
// eslint-disable-next-line no-restricted-imports
25
import { useSelector } from 'react-redux';
36

47
import { TypedVariableModel, VariableHide } from '@grafana/data';
58
import { selectors } from '@grafana/e2e-selectors';
6-
import { Tooltip, useTheme2 } from '@grafana/ui';
9+
import { Tooltip } from '@grafana/ui';
710
import { FnGlobalState } from 'app/core/reducers/fn-slice';
811
import type { StoreState } from 'app/types';
912

@@ -15,7 +18,19 @@ interface Props {
1518
readOnly?: boolean;
1619
}
1720

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) => {
1934
const PickerToRender = useMemo(() => variableAdapters.get(props.variable.type).picker, [props.variable]);
2035

2136
if (!props.variable) {
@@ -26,36 +41,53 @@ export const PickerRenderer = (props: Props) => {
2641
<Stack gap={0}>
2742
<PickerLabel variable={props.variable} />
2843
{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>
3047
)}
3148
</Stack>
3249
);
3350
};
3451

3552
const COMMON_PICKER_LABEL_STYLE: CSSProperties = {
36-
borderRadius: '4px',
53+
borderRadius: '2px',
3754
border: 'none',
38-
fontWeight: 600,
55+
fontWeight: 400,
3956
fontSize: '12px',
57+
padding: '3px 6px',
58+
letterSpacing: '0.15px',
59+
height: '24px',
4060
};
4161

4262
function PickerLabel({ variable }: PropsWithChildren<Props>): ReactElement | null {
4363
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+
);
4678

4779
if (variable.hide !== VariableHide.dontHide) {
4880
return null;
4981
}
50-
const fnLabelOrName = FNDashboard ? labelOrName.replace('druid', '') : labelOrName;
82+
const fnLabelOrName = FNDashboard ? labelOrName.replace('druid_adhoc_filters', 'ad-hoc') : labelOrName;
5183

5284
const elementId = VARIABLE_PREFIX + variable.id;
5385
if (variable.description) {
5486
return (
5587
<Tooltip content={variable.description} placement={'bottom'}>
5688
<label
5789
className="gf-form-label gf-form-label--variable"
58-
style={FNDashboard ? { ...COMMON_PICKER_LABEL_STYLE, color: theme.colors.text.secondary } : {}}
90+
style={fnLabelStyle}
5991
data-testid={selectors.pages.Dashboard.SubMenu.submenuItemLabels(labelOrName)}
6092
htmlFor={elementId}
6193
>
@@ -67,7 +99,7 @@ function PickerLabel({ variable }: PropsWithChildren<Props>): ReactElement | nul
6799
return (
68100
<label
69101
className="gf-form-label gf-form-label--variable"
70-
style={FNDashboard ? { ...COMMON_PICKER_LABEL_STYLE, color: theme.colors.text.secondary } : {}}
102+
style={fnLabelStyle}
71103
data-testid={selectors.pages.Dashboard.SubMenu.submenuItemLabels(labelOrName)}
72104
htmlFor={elementId}
73105
>

0 commit comments

Comments
 (0)