Skip to the content

Capsid menu

app/components/admin/media-list-header.tsx

52 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of media-list-header.tsx
FunctionLinesComplexityCoveredCRAPMutation
MediaListHeader14 to 562No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code
<anonymous:26>26 to 499No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports app/lib/media/view.mjs. Imported by app/components/admin/media-grid.tsx.

Source

import { Link } from "react-router";

import { sortHref } from "~/lib/media/view.mjs";

const LIST_COLUMNS: Array<[sortKey: string | null, label: string, num: boolean]> = [
  ["name", "Name", false],
  ["usage", "Usage", false],
  [null, "Dims", true],
  ["size", "Size", true],
  ["added", "Added", true],
];

// Dims is not sortable: half the library has no dimensions, which would collapse into one block.
export function MediaListHeader({
  view,
}: {
  view: Parameters<typeof sortHref>[0];
}) {
  const arrow = view.dir === "asc" ? "↑" : "↓";

  return (
    <tr>
      <th scope="col">
        <span className="cap-sr-only">Select</span>
      </th>
      {LIST_COLUMNS.map(([key, label, num]) =>
        key === null ? (
          <th key={label} scope="col" data-num={num || undefined}>
            {label}
          </th>
        ) : (
          <th
            key={key}
            scope="col"
            data-num={num || undefined}
            aria-sort={view.sort === key ? (view.dir === "asc" ? "ascending" : "descending") : undefined}
          >
            <Link to={sortHref(view, key, { toggle: true })} className="cap-table-sort" data-sort={key}>
              {label}
              <span aria-hidden="true">{view.sort === key ? ` ${arrow}` : ""}</span>
              {/* The sorted column says so in words inside its link. */}
              {view.sort === key ? (
                <span className="cap-sr-only">
                  , sorted {view.dir === "asc" ? "ascending" : "descending"}
                </span>
              ) : null}
            </Link>
          </th>
        ),
      )}
      <th scope="col">
        <span className="cap-sr-only">Copy the address</span>
      </th>
    </tr>
  );
}