• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

react-ui-org / react-ui / 14831340595

05 May 2025 07:31AM UTC coverage: 77.116% (-13.2%) from 90.283%
14831340595

Pull #636

github

web-flow
Merge c233dddc7 into b73b8ec0f
Pull Request #636: Refactoring/miscellaneous jest to playwright

626 of 897 branches covered (69.79%)

Branch coverage included in aggregate %.

695 of 816 relevant lines covered (85.17%)

43.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.5
/src/components/Table/_components/TableHeaderCell/TableHeaderCell.jsx
1
import PropTypes from 'prop-types';
2
import React from 'react';
3
import { Button } from '../../../Button';
4
import styles from '../TableCell.module.scss';
5

6
export const TableHeaderCell = ({
2✔
7
  column,
8
  id,
9
  sort,
10
}) => {
11
  const sortDirection = sort && column.name === sort.column ? sort.direction : 'asc';
×
12
  const isSortingActive = sort && column.name === sort.column;
×
13

14
  return (
×
15
    <th
16
      className={isSortingActive ? styles.isTableHeadCellSortingActive : styles.tableHeadCell}
×
17
      id={id}
18
    >
19
      <span className={styles.tableHeadCellLayout}>
20
        {sort && column.isSortable && (
×
21
          <Button
22
            aria-pressed={isSortingActive}
23
            beforeLabel={
24
              sortDirection === 'asc'
×
25
                ? sort.ascendingIcon
26
                : sort.descendingIcon
27
            }
28
            color={isSortingActive ? 'selected' : 'secondary'}
×
29
            id={id && `${id}__sortButton`}
×
30
            label={sortDirection}
31
            labelVisibility="none"
32
            onClick={() => sort.onClick(column.name, sortDirection)}
×
33
            priority="flat"
34
            size="small"
35
          />
36
        )}
37
        {column.label}
38
      </span>
39
    </th>
40
  );
41
};
42

43
TableHeaderCell.defaultProps = {
2✔
44
  id: undefined,
45
  sort: null,
46
};
47

48
TableHeaderCell.propTypes = {
2✔
49
  /**
50
   * Table data column, optionally sortable. The `format` function can be used to process the
51
   * column data before displaying them.
52
   */
53
  column: PropTypes.shape({
54
    isSortable: PropTypes.bool,
55
    label: PropTypes.string,
56
    name: PropTypes.string.isRequired,
57
  }).isRequired,
58
  /**
59
   * ID of the HTML <th> element and nested button for sorting.
60
   */
61
  id: PropTypes.string,
62
  /**
63
   * Sorting configuration required to make columns sortable.
64
   */
65
  sort: PropTypes.shape({
66
    ascendingIcon: PropTypes.node.isRequired,
67
    column: PropTypes.string.isRequired,
68
    descendingIcon: PropTypes.node.isRequired,
69
    direction: PropTypes.oneOf(['asc', 'desc']).isRequired,
70
    onClick: PropTypes.func.isRequired,
71
  }),
72
};
73

74
export default TableHeaderCell;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc