container.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import styled from '@emotion/styled';
  2. import space from 'sentry/styles/space';
  3. import theme from 'sentry/utils/theme';
  4. import {CLASSNAMES} from './resizePanel';
  5. // This is the generated SVG from https://github.com/getsentry/sentry/blob/master/static/app/icons/iconGrabbable.tsx
  6. // I couldn't sort out how to extract it from the react component. I think it
  7. // could be done react-dom-server or to render it inside an unmounted dom node
  8. // then copy the html content. All that seemed slower to build and slower to
  9. // exec compared to having an encoded svg.
  10. const GrabberColor = encodeURIComponent(theme.gray300);
  11. const GrabberSVG =
  12. `url('data:image/svg+xml,` +
  13. `%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="${GrabberColor}" height="16px" width="16px"%3E` +
  14. '%3Ccircle cx="4.73" cy="8" r="1.31"%3E%3C/circle%3E' +
  15. '%3Ccircle cx="4.73" cy="1.31" r="1.31"%3E%3C/circle%3E' +
  16. '%3Ccircle cx="11.27" cy="8" r="1.31"%3E%3C/circle%3E' +
  17. '%3Ccircle cx="11.27" cy="1.31" r="1.31"%3E%3C/circle%3E' +
  18. '%3Ccircle cx="4.73" cy="14.69" r="1.31"%3E%3C/circle%3E' +
  19. '%3Ccircle cx="11.27" cy="14.69" r="1.31"%3E%3C/circle%3E' +
  20. '%3C/svg%3E' +
  21. `')`;
  22. const Container = styled('div')`
  23. width: 100%;
  24. height: 100%;
  25. max-height: 100%;
  26. display: flex;
  27. flex-flow: nowrap column;
  28. overflow: hidden;
  29. padding: ${space(2)};
  30. .${CLASSNAMES.bar.width} {
  31. cursor: ew-resize;
  32. height: 100%;
  33. width: ${space(2)};
  34. }
  35. .${CLASSNAMES.bar.height} {
  36. cursor: ns-resize;
  37. height: ${space(2)};
  38. width: 100%;
  39. }
  40. .${CLASSNAMES.bar.height}.overlapDown {
  41. height: calc(16px + 34px); /* Spacing between components + height of <FocusTabs> */
  42. margin-bottom: -34px; /* The height of the <FocusTabs> text + border */
  43. z-index: ${p => p.theme.zIndex.initial};
  44. }
  45. .${CLASSNAMES.bar.height}, .${CLASSNAMES.bar.width} {
  46. background: transparent;
  47. display: flex;
  48. align-items: center;
  49. align-content: center;
  50. justify-content: center;
  51. }
  52. .${CLASSNAMES.bar.height}:hover, .${CLASSNAMES.bar.width}:hover {
  53. background: ${p => p.theme.hover};
  54. }
  55. .${CLASSNAMES.handle.width} {
  56. height: ${space(3)};
  57. width: ${space(2)};
  58. }
  59. .${CLASSNAMES.handle.height} {
  60. height: ${space(2)};
  61. width: ${space(3)};
  62. transform: rotate(90deg);
  63. }
  64. .${CLASSNAMES.handle.height} > span,
  65. .${CLASSNAMES.handle.width} > span {
  66. display: block;
  67. background: transparent ${GrabberSVG} center center no-repeat;
  68. width: 100%;
  69. height: 100%;
  70. }
  71. `;
  72. export default Container;