grabber.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import type {MouseEventHandler} from 'react';
  2. import styled from '@emotion/styled';
  3. interface Props {
  4. 'data-is-held': boolean;
  5. 'data-slide-direction': 'leftright' | 'updown';
  6. onDoubleClick: MouseEventHandler<HTMLElement>;
  7. onMouseDown: MouseEventHandler<HTMLElement>;
  8. }
  9. const Grabber = styled('div')<Props>`
  10. position: absolute;
  11. top: 0;
  12. left: 0;
  13. height: 100%;
  14. width: 6px;
  15. transform: translate(-3px, 0);
  16. z-index: ${p => p.theme.zIndex.initial};
  17. user-select: inherit;
  18. &[data-is-held='true'] {
  19. user-select: none;
  20. }
  21. &[data-slide-direction='leftright'] {
  22. cursor: ew-resize;
  23. }
  24. &[data-slide-direction='updown'] {
  25. cursor: ns-resize;
  26. }
  27. &:after {
  28. content: '';
  29. position: absolute;
  30. top: 0;
  31. left: 2.5px;
  32. height: 100%;
  33. width: 1px;
  34. transform: translate(-0.5px, 0);
  35. z-index: ${p => p.theme.zIndex.initial};
  36. background: ${p => p.theme.border};
  37. }
  38. &:hover:after,
  39. &[data-is-held='true']:after {
  40. left: 1.5px;
  41. width: 3px;
  42. background: ${p => p.theme.black};
  43. }
  44. `;
  45. export default Grabber;