aiellie

Search

Find a component, template or page

GitHub
Components

Commit

A commit in one row: its message, author, time and lines changed, with the hash to copy, opening to the files it touched.

  • Changed: app/components/chart.tsxAdded +6Removed −2
  • Added: app/components/use-container-width.tsAdded +18
  • Removed: app/components/chart.cssRemoved −9
Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/commit"

shadcn needs the @aiellie registry in components.json first. npx aiellie add commit adds it on its first run, then installs the same way.

Commit shows a commit in one row: its message, who made it and when, how many lines it added and removed, and its hash to copy. It opens to the files it touched, each marked added, changed or removed in the same ink as File Tree and Code Diff.

Getting started

  1. Pass the commit

    files goes on the root, so the header can count them and the list can show them.

    components/agent-commit.tsx
    import {
      Commit,
      CommitFiles,
      CommitHash,
      CommitHeader,
    } from "@/components/aiellie/commit"
    
    export function AgentCommit() {
      return (
        <Commit
          files={[
            { path: "app/chart.tsx", status: "modified", additions: 6, deletions: 2 },
            { path: "app/use-width.ts", status: "added", additions: 18 },
          ]}
        >
          <CommitHeader
            message="Size the chart from its container"
            author="Ada Lovelace"
            time="42 minutes ago"
          >
            <CommitHash hash="4f2c9e1b7a03d5e8" />
          </CommitHeader>
          <CommitFiles />
        </Commit>
      )
    }

Anatomy

<div data-slot="commit"> {/* Base UI Collapsible */}
  <div data-slot="commit-header">
    <button /> {/* the author, the message and the counts */}
    <button data-slot="commit-hash" />
  </div>
  <div data-slot="commit-files">
    <ul>
      <li data-status="added" />
    </ul>
  </div>
</div>

The header's children sit at its end, outside the button that opens it. Without an avatar the author's initials stand in. A commit with no files doesn't open.

Examples

Open a file

onOpenFile on the list makes each path a button.

  • Changed: Added +3Removed −1
  • Added: Added +40

API reference

Commit

PropTypeDefaultDescription
filesCommitFile[][]What it changed.

All other Collapsible.Root props are forwarded.

CommitHeader

PropTypeDefaultDescription
messageReactNoderequiredThe subject line.
authorstring
avatarstringA picture of the author.
timeReactNodeWhen it was made, like a Timestamp.
childrenReactNodeActions at the header's end.

CommitHash

PropTypeDefaultDescription
hashstringrequiredThe full hash, which is what's copied.
lengthnumber7How much of it to show.
tooltipstring"Copy hash"

CommitFile

FieldTypeDefaultDescription
pathstringrequired
status"added" | "modified" | "removed""modified"
additions, deletionsnumberLines added and removed.

CommitFiles takes onOpenFile: (file: CommitFile) => void.