// Adapted from jalcoui (MIT) — github.com/jal-co/ui 'use client'; /* eslint-disable @next/next/no-img-element */ import * as React from 'react'; import { Popover, PopoverContent, PopoverTrigger } from '@djangocfg/ui-core'; import { alpha } from '@djangocfg/ui-core/styles/palette'; import type { Commit } from '../types'; import { formatFullDate, initials } from '../utils'; interface CommitDetailProps { commit: Commit; hashLength: number; railColor: string; children: React.ReactNode; } /** * Popover with the full commit message, refs, tag and parent hashes. The * trigger is the row button — the parent component owns the row markup and * passes it through `children`. * * Requires the host app to mount `` at the root (we do not * remount a Popover provider here — see CONTRACT §5). */ export function CommitDetail({ commit, hashLength, railColor, children, }: CommitDetailProps) { // Pre-compute style strings outside JSX (per project rule: hoist derived // values into named consts before `return (...)`). const tagStyle = { backgroundColor: alpha(railColor, 0.125), color: railColor, }; const initialsLabel = initials(commit.author.name); return ( {children}

{commit.message}

{commit.author.avatarUrl ? ( ) : ( {initialsLabel} )} {commit.author.name} · {commit.hash.slice(0, hashLength)}
{formatFullDate(commit.date)}
{(commit.refs || commit.tag) && (
{commit.refs?.map((ref) => ( {ref} ))} {commit.tag && ( {commit.tag} )}
)} {commit.parents.length > 0 && (
{commit.parents.length === 1 ? 'Parent' : 'Parents'}:{' '} {commit.parents.map((p) => p.slice(0, hashLength)).join(', ')}
)}
); }