12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import styled from '@emotion/styled';
- import DropdownButton from 'sentry/components/dropdownButton';
- import {GetActorPropsFn} from 'sentry/components/dropdownMenu';
- import {t, tn} from 'sentry/locale';
- import space from 'sentry/styles/space';
- type Props = {
- checkedQuantity: number;
- getActorProps: GetActorPropsFn;
- isOpen: boolean;
- };
- function DropDownButton({isOpen, getActorProps, checkedQuantity}: Props) {
- if (checkedQuantity > 0) {
- return (
- <StyledDropdownButton
- {...getActorProps()}
- isOpen={isOpen}
- size="small"
- hideBottomBorder={false}
- priority="primary"
- >
- {tn('%s Active Filter', '%s Active Filters', checkedQuantity)}
- </StyledDropdownButton>
- );
- }
- return (
- <StyledDropdownButton
- {...getActorProps()}
- isOpen={isOpen}
- size="small"
- hideBottomBorder={false}
- >
- {t('Filter By')}
- </StyledDropdownButton>
- );
- }
- export default DropDownButton;
- const StyledDropdownButton = styled(DropdownButton)`
- z-index: ${p => p.theme.zIndex.dropdownAutocomplete.actor};
- border-radius: ${p => p.theme.borderRadius};
- max-width: 200px;
- white-space: nowrap;
- ${p =>
- p.isOpen &&
- `
- :before,
- :after {
- position: absolute;
- bottom: calc(${space(0.5)} + 1px);
- right: 32px;
- content: '';
- width: 16px;
- border: 8px solid transparent;
- transform: translateY(calc(50% + 2px));
- right: 9px;
- border-bottom-color: ${p.theme.backgroundSecondary};
- }
- :before {
- transform: translateY(calc(50% + 1px));
- border-bottom-color: ${p.theme.border};
- }
- `}
- @media (min-width: ${p => p.theme.breakpoints.small}) {
- border-right: 0;
- border-top-right-radius: 0;
- border-bottom-right-radius: 0;
- }
- `;
|