accessibilityHeaderCell.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {ComponentProps, CSSProperties, forwardRef, ReactNode} from 'react';
  2. import HeaderCell from 'sentry/components/replays/virtualizedGrid/headerCell';
  3. import {Tooltip} from 'sentry/components/tooltip';
  4. import {t} from 'sentry/locale';
  5. import useSortAccessibility from 'sentry/views/replays/detail/accessibility/useSortAccessibility';
  6. type SortConfig = ReturnType<typeof useSortAccessibility>['sortConfig'];
  7. type Props = {
  8. handleSort: ReturnType<typeof useSortAccessibility>['handleSort'];
  9. index: number;
  10. sortConfig: SortConfig;
  11. style: CSSProperties;
  12. };
  13. const COLUMNS: {
  14. field: SortConfig['by'];
  15. label: ReactNode;
  16. tooltipTitle?: ComponentProps<typeof Tooltip>['title'];
  17. }[] = [
  18. {
  19. field: 'impact',
  20. label: '',
  21. },
  22. {
  23. field: 'id',
  24. label: t('Type'),
  25. },
  26. {field: 'element', label: t('Element')},
  27. {field: 'timestampMs', label: t('Timestamp')},
  28. ];
  29. export const COLUMN_COUNT = COLUMNS.length;
  30. const AccessibilityHeaderCell = forwardRef<HTMLButtonElement, Props>(
  31. ({handleSort, index, sortConfig, style}: Props, ref) => {
  32. const {field, label, tooltipTitle} = COLUMNS[index];
  33. return (
  34. <HeaderCell
  35. ref={ref}
  36. handleSort={handleSort}
  37. field={field}
  38. label={label}
  39. tooltipTitle={tooltipTitle}
  40. sortConfig={sortConfig}
  41. style={style}
  42. />
  43. );
  44. }
  45. );
  46. export default AccessibilityHeaderCell;