splitDivider.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import type {DOMAttributes, MouseEventHandler} from 'react';
  2. import styled from '@emotion/styled';
  3. import {IconGrabbable} from 'sentry/icons';
  4. import {space} from 'sentry/styles/space';
  5. type Props = {
  6. 'data-is-held': boolean;
  7. 'data-slide-direction': 'leftright' | 'updown';
  8. onDoubleClick: MouseEventHandler<HTMLElement>;
  9. onMouseDown: MouseEventHandler<HTMLElement>;
  10. };
  11. const SplitDivider = styled((props: Props & DOMAttributes<HTMLDivElement>) => (
  12. <div {...props}>
  13. <IconGrabbable size="sm" />
  14. </div>
  15. ))<Props>`
  16. display: grid;
  17. place-items: center;
  18. height: 100%;
  19. width: 100%;
  20. user-select: inherit;
  21. background: inherit;
  22. &:hover,
  23. &[data-is-held='true'] {
  24. background: ${p => p.theme.hover};
  25. }
  26. &[data-is-held='true'] {
  27. user-select: none;
  28. }
  29. &[data-slide-direction='leftright'] {
  30. cursor: ew-resize;
  31. height: 100%;
  32. width: ${space(2)};
  33. }
  34. &[data-slide-direction='updown'] {
  35. cursor: ns-resize;
  36. width: 100%;
  37. & > svg {
  38. transform: rotate(90deg);
  39. }
  40. }
  41. `;
  42. export default SplitDivider;