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.

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

export type LinkChange = {
  readonly verb: "Linked" | "Unlinked";
  readonly taskLabel: string;
  readonly taskUrl: string;
  readonly linkTitle: string;
};

export function renderLinkChange(ui: Ui, change: LinkChange): string[] {
  const { theme, glyphs } = ui;
  const reference = renderCell(
    [text(change.taskLabel, theme.strong, change.taskUrl)],
    ui,
  );
  const head = `  ${theme.success(glyphs.tick)} ${change.verb} ${reference} ${theme.muted(glyphs.separator)} `;
  const title = truncate(
    change.linkTitle,
    Math.max(ui.caps.columns - stringWidth(head), 8),
    glyphs.ellipsis,
  );
  return ["", `${head}${title}`, ""];
}