accessibilityHeaderCell.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. ];
  28. export const COLUMN_COUNT = COLUMNS.length;
  29. const AccessibilityHeaderCell = forwardRef<HTMLButtonElement, Props>(
  30. ({handleSort, index, sortConfig, style}: Props, ref) => {
  31. const {field, label, tooltipTitle} = COLUMNS[index];
  32. return (
  33. <HeaderCell
  34. ref={ref}
  35. handleSort={handleSort}
  36. field={field}
  37. label={label}
  38. tooltipTitle={tooltipTitle}
  39. sortConfig={sortConfig}
  40. style={style}
  41. />
  42. );
  43. }
  44. );
  45. export default AccessibilityHeaderCell;