EntryBadges

tcmts.share.EntryBadges · #uzhkpy7o · term · runs anywhere

An entry's changes as badges: edited, added, removed, renamed, and what only re-hashed.

import type { EntrySummary } from "#codebase/tcmts/share";

export function EntryBadges({ e }: { e: EntrySummary }) {
  const b = (n: number, cls: string, label: string) =>
    n ? (
      <span className={`badge ${cls}`} key={label}>
        {n} {label}
      </span>
    ) : null;
  const all = [b(e.edited.length, "b-edit", "edited"), b(e.added.length, "b-new", "added"), b(e.removed.length, "b-rm", "removed"), b(e.renamed.length, "b-ren", "renamed"), b(e.propagated, "b-prop", "re-hashed")].filter((x) => x !== null);
  return all.length ? <>{all}</> : <span className="muted" style={{ fontSize: 12 }}>no name changes</span>;
}

uses

used by