dropDownButton.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import styled from '@emotion/styled';
  2. import DropdownButton from 'sentry/components/dropdownButton';
  3. import {GetActorPropsFn} from 'sentry/components/dropdownMenu';
  4. import {t, tn} from 'sentry/locale';
  5. import space from 'sentry/styles/space';
  6. type Props = {
  7. checkedQuantity: number;
  8. getActorProps: GetActorPropsFn;
  9. isOpen: boolean;
  10. };
  11. function DropDownButton({isOpen, getActorProps, checkedQuantity}: Props) {
  12. if (checkedQuantity > 0) {
  13. return (
  14. <StyledDropdownButton
  15. {...getActorProps()}
  16. isOpen={isOpen}
  17. size="small"
  18. hideBottomBorder={false}
  19. priority="primary"
  20. >
  21. {tn('%s Active Filter', '%s Active Filters', checkedQuantity)}
  22. </StyledDropdownButton>
  23. );
  24. }
  25. return (
  26. <StyledDropdownButton
  27. {...getActorProps()}
  28. isOpen={isOpen}
  29. size="small"
  30. hideBottomBorder={false}
  31. >
  32. {t('Filter By')}
  33. </StyledDropdownButton>
  34. );
  35. }
  36. export default DropDownButton;
  37. const StyledDropdownButton = styled(DropdownButton)`
  38. z-index: ${p => p.theme.zIndex.dropdownAutocomplete.actor};
  39. border-radius: ${p => p.theme.borderRadius};
  40. max-width: 200px;
  41. white-space: nowrap;
  42. ${p =>
  43. p.isOpen &&
  44. `
  45. :before,
  46. :after {
  47. position: absolute;
  48. bottom: calc(${space(0.5)} + 1px);
  49. right: 32px;
  50. content: '';
  51. width: 16px;
  52. border: 8px solid transparent;
  53. transform: translateY(calc(50% + 2px));
  54. right: 9px;
  55. border-bottom-color: ${p.theme.backgroundSecondary};
  56. }
  57. :before {
  58. transform: translateY(calc(50% + 1px));
  59. border-bottom-color: ${p.theme.border};
  60. }
  61. `}
  62. @media (min-width: ${p => p.theme.breakpoints.small}) {
  63. border-right: 0;
  64. border-top-right-radius: 0;
  65. border-bottom-right-radius: 0;
  66. }
  67. `;