added diff info and hover for commits

This commit is contained in:
2026-11-11 16:18:03 +00:00
parent a3a418a037
commit 0b958ae3eb
2 changed files with 53 additions and 23 deletions

View File

@@ -7,6 +7,13 @@ export interface GitCommit {
url: string; url: string;
timestamp: Date; timestamp: Date;
user: string; user: string;
diff: Diff;
}
export interface Diff {
additions: number;
deletions: number;
total: number;
} }
const CACHE_TTL = 3 * 60 * 60 * 1000; const CACHE_TTL = 3 * 60 * 60 * 1000;
@@ -68,12 +75,17 @@ async function fetchLatestCommits(
let newCommit: GitCommit = { let newCommit: GitCommit = {
message: commit.commit.message, message: commit.commit.message,
hash: commit.sha, hash: commit.sha,
shortHash: commit.sha.substring(0, 8), shortHash: commit.sha.substring(0, 6),
timestamp: new Date(commit.created), timestamp: new Date(commit.created),
url: commit.html_url, url: commit.html_url,
parentRepo: repo.full_name, parentRepo: repo.full_name,
parentBranch: 'main', // I know this is a shit solution parentBranch: 'main', // I know this is a shit solution
user: commit.commit.author.name user: commit.commit.author.name,
diff: {
additions: commit.stats.additions,
deletions: commit.stats.deletions,
total: commit.stats.total
}
}; };
commitList.push(newCommit); commitList.push(newCommit);
} }

View File

@@ -162,35 +162,53 @@
</svg> </svg>
<div bind:this={listElement} class=" mr-3 grid grid-flow-row auto-rows-min"> <div bind:this={listElement} class=" mr-3 grid grid-flow-row auto-rows-min">
{#each visibleItems as item, index (item.hash)} {#each visibleItems as commit, index (commit.hash)}
<div class="relative z-10 grid grid-cols-[1.25rem_minmax(0,1fr)] gap-x-3.5 gap-y-2 pb-2"> <div class="relative z-10 grid grid-cols-[1.25rem_minmax(0,1fr)] gap-x-3.5 gap-y-2 pb-2">
<!-- Timeline space --> <!-- Timeline space -->
<div></div> <div></div>
<div class="min-w-0"> <div class="min-w-0">
<a href={item.link} class="group block"> <div class="block">
{#if visibleItems[index - 1]?.parentRepo != item.parentRepo} {#if visibleItems[index - 1]?.parentRepo != commit.parentRepo}
<p class="flex flex-row pt-2"> <p>
<svg <span class="text-ctp-red">
xmlns="http://www.w3.org/2000/svg" <svg
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
height="20px" viewBox="0 0 24 24"
width="20px" height="20px"
class="pt-1" width="20px"
fill="#e3e3e3" class="mr-1 inline-flex items-center whitespace-nowrap"
><path d="M16.18,13H4V11H16.18l-5.6-5.6L12,4l8,8l-8,8l-1.42-1.4l5.6-5.6Z" /></svg fill="var(--ctp-peach)"
><path
d="M16.18,13H4V11H16.18l-5.6-5.6L12,4l8,8l-8,8l-1.42-1.4l5.6-5.6Z"
/></svg
><a
class="hover:font-medium hover:underline"
href={'https://git.voidarc.co.uk/' + commit.user}>{commit.user}</a
></span
> >
<span class="mx-[1ch] text-ctp-red">{item.user}</span> on on
<span class="ml-[1ch] text-ctp-mauve">{item.parentRepo}</span><span <a href={'https://git.voidarc.co.uk/' + commit.parentRepo} class="group">
class="text-ctp-yellow">@</span <span class="text-ctp-mauve group-hover:font-medium group-hover:underline"
><span class="text-ctp-green">{item.parentBranch}</span> >{commit.parentRepo}</span
><span class="text-ctp-yellow group-hover:font-medium group-hover:underline"
>@</span
><span class="text-ctp-green group-hover:font-medium group-hover:underline"
>{commit.parentBranch}</span
>
</a>
</p> </p>
{/if} {/if}
<div class="flex"> <a href={commit.url} style="cursor: pointer;" class="group flex justify-items-stretch">
<p class="rounded-md bg-ctp-surface2 px-1">{item.shortHash}</p> <p
<p class="ml-2 line-clamp-1">{item.message}</p> class="rounded-md bg-ctp-surface2 px-1 group-hover:font-bold group-hover:text-ctp-mauve group-hover:underline"
</div> >
</a> {commit.shortHash}
</p>
<p class="ml-2 line-clamp-1 group-hover:font-semibold">{commit.message}</p>
<div class="justify-content-end flex text-align-right flex-1"><div>some</div></div>
</a>
</div>
</div> </div>
</div> </div>
{/each} {/each}