Skip to content

Commit 91e9ec8

Browse files
authored
changed query filter designs (#59)
1 parent d90ade2 commit 91e9ec8

File tree

4 files changed

+88
-10
lines changed

4 files changed

+88
-10
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
"@lezer/lr": "1.2.3",
276276
"@lingui/core": "3.14.0",
277277
"@lingui/react": "3.14.0",
278+
"@mui/icons-material": "^5.11.11",
278279
"@mui/material": "^5.10.9",
279280
"@mui/styled-engine": "^5.10.8",
280281
"@opentelemetry/api": "1.2.0",

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

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { css } from '@emotion/css';
2-
import React, { PureComponent } from 'react';
2+
import FilterListIcon from '@mui/icons-material/FilterList';
3+
import { Box, styled } from '@mui/material';
4+
import React, { FC, PureComponent } from 'react';
35
import { connect, MapStateToProps } from 'react-redux';
46

57
import { AnnotationQuery, DataQuery } from '@grafana/data';
@@ -56,6 +58,7 @@ class SubMenuUnConnected extends PureComponent<Props> {
5658
return (
5759
<div className="submenu-controls">
5860
<form aria-label="Template variables" className={styles}>
61+
<FilterWithIcon />
5962
<SubMenuItems
6063
variables={variables}
6164
readOnly={readOnlyVariables}
@@ -93,3 +96,20 @@ const styles = css`
9396
export const SubMenu = connect(mapStateToProps)(SubMenuUnConnected);
9497

9598
SubMenu.displayName = 'SubMenu';
99+
100+
const FilterWithIcon: FC = () => (
101+
<FilterWithIconStyled>
102+
<FilterListIcon sx={{ color: '#3A785E' }} />
103+
FILTERS
104+
</FilterWithIconStyled>
105+
);
106+
107+
const FilterWithIconStyled = styled(Box)({
108+
display: 'flex',
109+
gap: 1,
110+
alignItems: 'center',
111+
color: '#3A785E',
112+
fontWeight: 600,
113+
lineHeight: '160%',
114+
fontSize: 12,
115+
});

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

+40-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { css } from '@emotion/css';
12
import React, { CSSProperties, FunctionComponent, PropsWithChildren, ReactElement, useMemo } from 'react';
3+
// eslint-disable-next-line no-restricted-imports
24
import { useSelector } from 'react-redux';
35

46
import { selectors } from '@grafana/e2e-selectors';
5-
import { Tooltip, useTheme2 } from '@grafana/ui';
7+
import { Tooltip } from '@grafana/ui';
68
import { FnGlobalState } from 'app/core/reducers/fn-slice';
79
import type { StoreState } from 'app/types';
810

@@ -14,6 +16,18 @@ interface Props {
1416
readOnly?: boolean;
1517
}
1618

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+
1731
export const PickerRenderer: FunctionComponent<Props> = (props) => {
1832
const PickerToRender = useMemo(() => variableAdapters.get(props.variable.type).picker, [props.variable]);
1933

@@ -25,36 +39,53 @@ export const PickerRenderer: FunctionComponent<Props> = (props) => {
2539
<div className="gf-form">
2640
<PickerLabel variable={props.variable} />
2741
{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>
2945
)}
3046
</div>
3147
);
3248
};
3349

3450
const COMMON_PICKER_LABEL_STYLE: CSSProperties = {
35-
borderRadius: '4px',
51+
borderRadius: '2px',
3652
border: 'none',
37-
fontWeight: 600,
53+
fontWeight: 400,
3854
fontSize: '12px',
55+
padding: '3px 6px',
56+
letterSpacing: '0.15px',
57+
height: '24px',
3958
};
4059

4160
function PickerLabel({ variable }: PropsWithChildren<Props>): ReactElement | null {
4261
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+
);
4576

4677
if (variable.hide !== VariableHide.dontHide) {
4778
return null;
4879
}
49-
const fnLabelOrName = FNDashboard ? labelOrName.replace('druid', '') : labelOrName;
80+
const fnLabelOrName = FNDashboard ? labelOrName.replace('druid_adhoc_filters', 'ad-hoc') : labelOrName;
5081

5182
const elementId = `var-${variable.id}`;
5283
if (variable.description) {
5384
return (
5485
<Tooltip content={variable.description} placement={'bottom'}>
5586
<label
5687
className="gf-form-label gf-form-label--variable"
57-
style={FNDashboard ? { ...COMMON_PICKER_LABEL_STYLE, color: theme.colors.text.secondary } : {}}
88+
style={fnLabelStyle}
5889
data-testid={selectors.pages.Dashboard.SubMenu.submenuItemLabels(labelOrName)}
5990
htmlFor={elementId}
6091
>
@@ -66,7 +97,7 @@ function PickerLabel({ variable }: PropsWithChildren<Props>): ReactElement | nul
6697
return (
6798
<label
6899
className="gf-form-label gf-form-label--variable"
69-
style={FNDashboard ? { ...COMMON_PICKER_LABEL_STYLE, color: theme.colors.text.secondary } : {}}
100+
style={fnLabelStyle}
70101
data-testid={selectors.pages.Dashboard.SubMenu.submenuItemLabels(labelOrName)}
71102
htmlFor={elementId}
72103
>

yarn.lock

+26
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,15 @@ __metadata:
18971897
languageName: node
18981898
linkType: hard
18991899

1900+
"@babel/runtime@npm:^7.21.0":
1901+
version: 7.21.0
1902+
resolution: "@babel/runtime@npm:7.21.0"
1903+
dependencies:
1904+
regenerator-runtime: ^0.13.11
1905+
checksum: 7b33e25bfa9e0e1b9e8828bb61b2d32bdd46b41b07ba7cb43319ad08efc6fda8eb89445193e67d6541814627df0ca59122c0ea795e412b99c5183a0540d338ab
1906+
languageName: node
1907+
linkType: hard
1908+
19001909
"@babel/template@npm:^7.12.7, @babel/template@npm:^7.18.10, @babel/template@npm:^7.18.6, @babel/template@npm:^7.20.7, @babel/template@npm:^7.3.3":
19011910
version: 7.20.7
19021911
resolution: "@babel/template@npm:7.20.7"
@@ -5408,6 +5417,22 @@ __metadata:
54085417
languageName: node
54095418
linkType: hard
54105419

5420+
"@mui/icons-material@npm:^5.11.11":
5421+
version: 5.11.11
5422+
resolution: "@mui/icons-material@npm:5.11.11"
5423+
dependencies:
5424+
"@babel/runtime": ^7.21.0
5425+
peerDependencies:
5426+
"@mui/material": ^5.0.0
5427+
"@types/react": ^17.0.0 || ^18.0.0
5428+
react: ^17.0.0 || ^18.0.0
5429+
peerDependenciesMeta:
5430+
"@types/react":
5431+
optional: true
5432+
checksum: 6ec89f3c68aaedd521f6a5106964394c410b08cec6875166d3ee97dcbaf2983c67d3b19cd58113d767d9f934cc0e9439fb5856e45471f5094656c0f87bbefecd
5433+
languageName: node
5434+
linkType: hard
5435+
54115436
"@mui/material@npm:^5.10.9":
54125437
version: 5.11.3
54135438
resolution: "@mui/material@npm:5.11.3"
@@ -20080,6 +20105,7 @@ __metadata:
2008020105
"@lingui/macro": 3.14.0
2008120106
"@lingui/react": 3.14.0
2008220107
"@microsoft/api-extractor": 7.28.6
20108+
"@mui/icons-material": ^5.11.11
2008320109
"@mui/material": ^5.10.9
2008420110
"@mui/styled-engine": ^5.10.8
2008520111
"@opentelemetry/api": 1.2.0

0 commit comments

Comments
 (0)