row.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import styled from '@emotion/styled';
  2. import {ROW_HEIGHT} from 'sentry/components/performance/waterfall/constants';
  3. import {getBackgroundColor} from 'sentry/components/performance/waterfall/utils';
  4. interface RowProps extends React.HTMLAttributes<HTMLDivElement> {
  5. cursor?: 'pointer' | 'default';
  6. showBorder?: boolean;
  7. visible?: boolean;
  8. }
  9. export const Row = styled('div')<RowProps>`
  10. display: ${p => (p.visible ? 'block' : 'none')};
  11. border-top: ${p => (p.showBorder ? `1px solid ${p.theme.border}` : null)};
  12. margin-top: ${p => (p.showBorder ? '-1px' : null)}; /* to prevent offset on toggle */
  13. position: relative;
  14. overflow: hidden;
  15. min-height: ${ROW_HEIGHT}px;
  16. cursor: ${p => p.cursor ?? 'pointer'};
  17. transition: background-color 0.15s ease-in-out;
  18. &:last-child {
  19. & > [data-component='span-detail'] {
  20. border-bottom: none !important;
  21. }
  22. }
  23. `;
  24. type RowCellProps = {
  25. showDetail?: boolean;
  26. showStriping?: boolean;
  27. };
  28. export const RowCellContainer = styled('div')<RowCellProps>`
  29. display: flex;
  30. position: relative;
  31. height: ${ROW_HEIGHT}px;
  32. /* for virtual scrollbar */
  33. overflow: hidden;
  34. user-select: none;
  35. &:hover > div[data-type='span-row-cell'] {
  36. background-color: ${p =>
  37. p.showDetail ? p.theme.textColor : p.theme.backgroundSecondary};
  38. }
  39. `;
  40. export const RowCell = styled('div')<RowCellProps>`
  41. position: relative;
  42. height: 100%;
  43. overflow: hidden;
  44. background-color: ${p => getBackgroundColor(p)};
  45. transition: background-color 125ms ease-in-out;
  46. color: ${p => (p.showDetail ? p.theme.background : 'inherit')};
  47. display: flex;
  48. align-items: center;
  49. `;