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

66.66% Statements 2/3
50% Branches 2/4
50% Functions 1/2
66.66% Lines 2/3

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                            616x   616x                                
import { ChevronDown, ChevronsUpDown, ChevronUp } from "lucide-react";
import { Column } from "@tanstack/react-table";
 
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>
  );
}