diff --git a/.betterer.results b/.betterer.results index 9abae8a3a30..48f308f57b5 100644 --- a/.betterer.results +++ b/.betterer.results @@ -3668,17 +3668,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "2"] ], - "public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.tsx:5381": [ - [0, 0, 0, "Styles should be written using objects.", "0"], - [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"], - [0, 0, 0, "Styles should be written using objects.", "5"], - [0, 0, 0, "Styles should be written using objects.", "6"], - [0, 0, 0, "Styles should be written using objects.", "7"], - [0, 0, 0, "Styles should be written using objects.", "8"] - ], "public/app/features/library-panels/components/LibraryPanelsView/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], diff --git a/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.tsx b/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.tsx index 104e5feda14..7c015f60b6a 100644 --- a/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.tsx +++ b/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.tsx @@ -1,4 +1,4 @@ -import { css } from '@emotion/css'; +import { css, cx } from '@emotion/css'; import React, { useCallback, useState } from 'react'; import { useDebounce } from 'react-use'; @@ -57,7 +57,11 @@ export const LibraryPanelsSearch = ({ return (
-
+
{ - const styles = useStyles2(getRowStyles, variant); + const styles = useStyles2(getRowStyles); const panelFilterChanged = useCallback( (plugins: PanelPluginMeta[]) => onPanelFilterChange(plugins.map((p) => p.id)), [onPanelFilterChange] @@ -160,10 +163,18 @@ const SearchControls = React.memo( ); return ( -
+
{showSort && } {(showFolderFilter || showPanelFilter) && ( -
+
{showFolderFilter && } {showPanelFilter && }
@@ -174,42 +185,29 @@ const SearchControls = React.memo( ); SearchControls.displayName = 'SearchControls'; -function getRowStyles(theme: GrafanaTheme2, variant = LibraryPanelsSearchVariant.Spacious) { - const searchRowContainer = css` - display: flex; - gap: ${theme.spacing(1)}; - flex-grow: 1; - flex-direction: row; - justify-content: end; - `; - const searchRowContainerTight = css` - ${searchRowContainer}; - flex-grow: initial; - flex-direction: column; - justify-content: normal; - `; - const filterContainer = css` - display: flex; - flex-direction: row; - margin-left: auto; - gap: 4px; - `; - const filterContainerTight = css` - ${filterContainer}; - flex-direction: column; - margin-left: initial; - `; - - switch (variant) { - case LibraryPanelsSearchVariant.Spacious: - return { - container: searchRowContainer, - filterContainer: filterContainer, - }; - case LibraryPanelsSearchVariant.Tight: - return { - container: searchRowContainerTight, - filterContainer: filterContainerTight, - }; - } +function getRowStyles(theme: GrafanaTheme2) { + return { + container: css({ + display: 'flex', + gap: theme.spacing(1), + flexGrow: 1, + flexDirection: 'row', + justifyContent: 'space-between', + flexWrap: 'wrap', + }), + containerTight: css({ + flexGrow: 'initial', + flexDirection: 'column', + justifyContent: 'normal', + }), + filterContainer: css({ + display: 'flex', + flexDirection: 'row', + gap: theme.spacing(1), + }), + filterContainerTight: css({ + flexDirection: 'column', + marginLeft: 'initial', + }), + }; }