import styled from '@emotion/styled'; import { CompactSelect, SelectOption, SelectOptionOrSection, } from 'sentry/components/compactSelect'; import DropdownButton from 'sentry/components/dropdownButton'; import SearchBar from 'sentry/components/searchBar'; import {t, tn} from 'sentry/locale'; type Props = { onChange: (value: string) => void; placeholder: string; query: string; className?: string; filterOptions?: SelectOptionOrSection[]; filterSelections?: SelectOption[]; onFilterChange?: (options: SelectOption[]) => void; }; function SearchBarAction({ onChange, query, placeholder, filterOptions, filterSelections, onFilterChange, className, }: Props) { const trigger: React.ComponentProps['trigger'] = ( props, isOpen ) => ( 0 ? 'primary' : 'default'} {...props} > {filterSelections?.length ? tn('%s Active Filter', '%s Active Filters', filterSelections.length) : t('Filter By')} ); return ( {filterOptions && ( f.value)} onChange={onFilterChange} trigger={trigger} /> )} ); } export default SearchBarAction; const Wrapper = styled('div')` display: flex; width: 100%; justify-content: flex-end; @media (min-width: ${p => p.theme.breakpoints.medium}) { width: 350px; } @media (min-width: ${p => p.theme.breakpoints.xlarge}) { width: 500px; } `; const StyledSearchBar = styled(SearchBar)<{blendWithFilter?: boolean}>` width: 100%; ${p => p.blendWithFilter && ` input { border-radius: ${p.theme.borderRadiusRight}; border-left-width: 0; } `} `; const StyledTrigger = styled(DropdownButton)` border-radius: ${p => p.theme.borderRadiusLeft}; `;