expander.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import styled from '@emotion/styled';
  2. import Button from 'sentry/components/button';
  3. import {STACKTRACE_PREVIEW_TOOLTIP_DELAY} from 'sentry/components/stacktracePreview';
  4. import {IconChevron} from 'sentry/icons/iconChevron';
  5. import {t} from 'sentry/locale';
  6. import space from 'sentry/styles/space';
  7. import {PlatformType} from 'sentry/types';
  8. import {isDotnet} from '../utils';
  9. type Props = {
  10. isExpandable: boolean;
  11. onToggleContext: (evt: React.MouseEvent) => void;
  12. platform: PlatformType;
  13. isExpanded?: boolean;
  14. isHoverPreviewed?: boolean;
  15. };
  16. function Expander({
  17. isExpandable,
  18. isHoverPreviewed,
  19. isExpanded,
  20. platform,
  21. onToggleContext,
  22. }: Props) {
  23. if (!isExpandable) {
  24. return null;
  25. }
  26. return (
  27. <StyledButton
  28. className="btn-toggle"
  29. css={isDotnet(platform) && {display: 'block !important'}} // remove important once we get rid of css files
  30. size="zero"
  31. title={t('Toggle Context')}
  32. tooltipProps={
  33. isHoverPreviewed ? {delay: STACKTRACE_PREVIEW_TOOLTIP_DELAY} : undefined
  34. }
  35. onClick={onToggleContext}
  36. >
  37. <IconChevron direction={isExpanded ? 'up' : 'down'} size="8px" />
  38. </StyledButton>
  39. );
  40. }
  41. export default Expander;
  42. // the Button's label has the padding of 3px because the button size has to be 16x16 px.
  43. const StyledButton = styled(Button)`
  44. margin-left: ${space(1)};
  45. span:first-child {
  46. padding: 3px;
  47. }
  48. `;