All files / src/pages/flowsheet-page/pinch-analysis/TableColumns SortWrap.tsx

50% Statements 1/2
50% Branches 2/4
100% Functions 0/0
50% Lines 1/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                            1053x                                    
import { Column } from "@tanstack/react-table";
import { ChevronDown, ChevronsUpDown, ChevronUp } from "lucide-react";
 
export default function SortWrap({
  children,
  column,
}: {
  children: React.ReactNode;
  column: Column<unknown, unknown>;
}) {
  function handleClick() {
    column.toggleSorting();
  }
 
  const isSorted = column.getIsSorted();
 
  return (
    <div
      className="cursor-pointer flex flex-row items-center gap-[2px] hover:opacity-75 select-none"
      onClick={handleClick}
    >
      {isSorted === "asc" ? (
        <ChevronUp width={15} />
      ) : isSorted === "desc" ? (
        <ChevronDown width={15} />
      ) : (
        <ChevronsUpDown width={15} />
      )}
      {children}
    </div>
  );
}