diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx index 55689e34d97..b80e61ffb30 100644 --- a/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx @@ -15,7 +15,8 @@ import NoOptionsMessage from './NoOptionsMessage'; import resetSelectStyles from '../../../Select/resetSelectStyles'; import { CustomScrollbar } from '../../../CustomScrollbar/CustomScrollbar'; import { PopoverContent, Tooltip } from '../../../Tooltip/Tooltip'; -import { SelectableValue } from '@grafana/data'; +import { GrafanaTheme2, SelectableValue } from '@grafana/data'; +import { ThemeContext } from '../../../../themes'; /** * Changes in new selects: @@ -49,6 +50,8 @@ export const MenuList = (props: any) => { ); }; export class Select extends PureComponent> { + static contextType = ThemeContext; + static defaultProps: Partial> = { className: '', isDisabled: false, @@ -137,7 +140,7 @@ export class Select extends PureComponent> { onChange={onChange} options={options} placeholder={placeholder || 'Choose'} - styles={resetSelectStyles()} + styles={resetSelectStyles(this.context as GrafanaTheme2)} isDisabled={isDisabled} isLoading={isLoading} isClearable={isClearable} diff --git a/packages/grafana-ui/src/components/Select/SelectBase.tsx b/packages/grafana-ui/src/components/Select/SelectBase.tsx index f1c4b0df0a6..3f71f5416b3 100644 --- a/packages/grafana-ui/src/components/Select/SelectBase.tsx +++ b/packages/grafana-ui/src/components/Select/SelectBase.tsx @@ -6,7 +6,6 @@ import { default as AsyncCreatable } from 'react-select/async-creatable'; import { Icon } from '../Icon/Icon'; import { Spinner } from '../Spinner/Spinner'; -import { css, cx } from '@emotion/css'; import resetSelectStyles from './resetSelectStyles'; import { SelectMenu, SelectMenuOptions } from './SelectMenu'; import { IndicatorsContainer } from './IndicatorsContainer'; @@ -251,33 +250,6 @@ export function SelectBase({ MenuList: SelectMenu, Group: SelectOptionGroup, ValueContainer, - Placeholder(props: any) { - return ( -
- {props.children} -
- ); - }, IndicatorsContainer(props: any) { const { selectProps } = props; const { value, showAllSelectedWhenOpen, maxVisibleValues, menuIsOpen } = selectProps; @@ -346,7 +318,7 @@ export function SelectBase({ ...components, }} styles={{ - ...resetSelectStyles(), + ...resetSelectStyles(theme), menuPortal: (base: any) => ({ ...base, zIndex: theme.zIndex.portal, diff --git a/packages/grafana-ui/src/components/Select/resetSelectStyles.ts b/packages/grafana-ui/src/components/Select/resetSelectStyles.ts index 4b31dacd8cc..edcc3b52b97 100644 --- a/packages/grafana-ui/src/components/Select/resetSelectStyles.ts +++ b/packages/grafana-ui/src/components/Select/resetSelectStyles.ts @@ -1,6 +1,7 @@ +import { GrafanaTheme2 } from '@grafana/data'; import { CSSObjectWithLabel } from 'react-select'; -export default function resetSelectStyles() { +export default function resetSelectStyles(theme: GrafanaTheme2) { return { clearIndicator: () => ({}), container: () => ({}), @@ -31,7 +32,10 @@ export default function resetSelectStyles() { multiValueRemove: () => ({}), noOptionsMessage: () => ({}), option: () => ({}), - placeholder: () => ({}), + placeholder: (originalStyles: CSSObjectWithLabel) => ({ + ...originalStyles, + color: theme.colors.text.disabled, + }), singleValue: () => ({}), valueContainer: () => ({}), }; diff --git a/public/app/core/components/FolderFilter/FolderFilter.tsx b/public/app/core/components/FolderFilter/FolderFilter.tsx index 44af8e06d65..37cc3e04774 100644 --- a/public/app/core/components/FolderFilter/FolderFilter.tsx +++ b/public/app/core/components/FolderFilter/FolderFilter.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useMemo, useState } from 'react'; import { css } from '@emotion/css'; import debounce from 'debounce-promise'; -import { AsyncMultiSelect, Icon, resetSelectStyles, useStyles2 } from '@grafana/ui'; +import { AsyncMultiSelect, Icon, useStyles2 } from '@grafana/ui'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { FolderInfo, PermissionLevelString } from 'app/types'; @@ -36,7 +36,6 @@ export function FolderFilter({ onChange: propsOnChange, maxMenuHeight }: FolderF isMulti: true, noOptionsMessage: 'No folders found', placeholder: 'Filter by folder', - styles: resetSelectStyles(), maxMenuHeight, value, onChange, diff --git a/public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx b/public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx index aa3fddb0778..a03362e9da7 100644 --- a/public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx +++ b/public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useMemo, useState } from 'react'; import { GrafanaTheme2, PanelPluginMeta, SelectableValue } from '@grafana/data'; import { getAllPanelPluginMeta } from 'app/features/panel/state/util'; -import { Icon, resetSelectStyles, MultiSelect, useStyles2 } from '@grafana/ui'; +import { Icon, MultiSelect, useStyles2 } from '@grafana/ui'; import { css } from '@emotion/css'; export interface Props { @@ -42,7 +42,6 @@ export const PanelTypeFilter = ({ onChange: propsOnChange, maxMenuHeight }: Prop getOptionValue: (i: any) => i.value, noOptionsMessage: 'No Panel types found', placeholder: 'Filter by type', - styles: resetSelectStyles(), maxMenuHeight, options, value, diff --git a/public/app/core/components/TagFilter/TagFilter.tsx b/public/app/core/components/TagFilter/TagFilter.tsx index e0761c722ff..c69fd5ac889 100644 --- a/public/app/core/components/TagFilter/TagFilter.tsx +++ b/public/app/core/components/TagFilter/TagFilter.tsx @@ -3,7 +3,7 @@ import React, { FC } from 'react'; import { css } from '@emotion/css'; import { components } from 'react-select'; import debounce from 'debounce-promise'; -import { stylesFactory, useTheme, resetSelectStyles, Icon, AsyncMultiSelect } from '@grafana/ui'; +import { stylesFactory, useTheme, Icon, AsyncMultiSelect } from '@grafana/ui'; import { escapeStringForRegex, GrafanaTheme } from '@grafana/data'; // Components import { TagOption } from './TagOption'; @@ -82,7 +82,6 @@ export const TagFilter: FC = ({ noOptionsMessage: 'No tags found', onChange: onTagChange, placeholder, - styles: resetSelectStyles(), value, width, components: {