Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

957 B
Raw Blame
import { renderCell, text } from "../render/cell.js";
import type { Ui } from "../render/ui.js";

export type Attached = {
  readonly label: string;
  readonly url: string;
  readonly names: ReadonlyArray<string>;
  readonly target: "description" | "comment";
};

export function attachedSummary(names: ReadonlyArray<string>): string {
  if (names.length === 1) return names[0] ?? "1 file";
  if (names.length === 2) return `${names[0]} and ${names[1]}`;
  return `${names.length} files`;
}

export function renderAttached(ui: Ui, attached: Attached): string[] {
  const { theme, glyphs } = ui;
  const id = renderCell([text(attached.label, theme.strong, attached.url)], ui);
  const where =
    attached.target === "comment"
      ? "posted as a comment"
      : "added to the description";
  return [
    `  ${theme.success(glyphs.tick)} Attached ${attachedSummary(attached.names)} to ${id} ${theme.muted(`${glyphs.separator} ${where}`)}`,
    "",
  ];
}