Fix cob commit listing borderline not expanding

This commit is contained in:
Sebastian Martinez
2023-11-20 15:12:34 +01:00
parent 181fcc15af
commit e6c560b58b
10 changed files with 95 additions and 106 deletions
@@ -1,67 +0,0 @@
<script lang="ts">
import type { BaseUrl, CommitHeader } from "@httpd-client";
import { onMount } from "svelte";
import CobCommitTeaser from "@app/views/projects/Cob/CobCommitTeaser.svelte";
export let baseUrl: BaseUrl;
export let commits: CommitHeader[];
export let projectId: string;
let commitsDiv: HTMLElement | undefined = undefined;
const commitsDot: HTMLElement[] = [];
onMount(() => {
if (commitsDiv && commitsDot) {
const lastCommitDot = commitsDot.pop();
if (lastCommitDot?.parentElement) {
// Calculate the position of the last commit-dot relative to the div.commits
const commitDotBottom = lastCommitDot.parentElement.offsetTop + 10.5;
// Set the height of the pseudo-element (border)
commitsDiv.style.setProperty("--border-height", `${commitDotBottom}px`);
}
}
});
</script>
<style>
.commits {
position: relative;
display: flex;
flex-direction: column;
font-size: var(--font-size-small);
margin-left: 1rem;
gap: 0.5rem;
padding: 1rem 1rem;
}
.commits::after {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
border-left: 1px solid var(--color-fill-separator);
height: var(--border-height);
}
.commit-dot {
border-radius: var(--border-radius-round);
width: 4px;
height: 4px;
position: absolute;
top: 0.5rem;
left: -17.5px;
background-color: var(--color-fill-separator);
}
</style>
<div bind:this={commitsDiv} class="commits">
{#each commits.reverse() as commit, index}
<div style:position="relative">
<div class="commit-dot" bind:this={commitsDot[index]} />
<CobCommitTeaser {commit} {baseUrl} {projectId} />
</div>
{/each}
</div>
@@ -56,7 +56,7 @@
}
</style>
<div class="teaser">
<div class="teaser" aria-label="commit-teaser">
<div class="left">
<div class="message">
<span class="global-hash">{formatCommit(commit.id)}</span>
+38 -3
View File
@@ -12,7 +12,7 @@
import { HttpdClient } from "@httpd-client";
import { onMount } from "svelte";
import CobCommitListing from "@app/views/projects/Cob/CobCommitListing.svelte";
import CobCommitTeaser from "@app/views/projects/Cob/CobCommitTeaser.svelte";
import CommentComponent from "@app/components/Comment.svelte";
import DiffStatBadge from "@app/components/DiffStatBadge.svelte";
import DropdownList from "@app/components/DropdownList.svelte";
@@ -24,8 +24,8 @@
import Link from "@app/components/Link.svelte";
import Loading from "@app/components/Loading.svelte";
import Markdown from "@app/components/Markdown.svelte";
import Popover from "@app/components/Popover.svelte";
import NodeId from "@app/components/NodeId.svelte";
import Popover from "@app/components/Popover.svelte";
import Thread from "@app/components/Thread.svelte";
export let baseUrl: BaseUrl;
@@ -196,9 +196,37 @@
font-size: var(--font-size-small);
color: var(--color-fill-gray);
}
.commits {
position: relative;
display: flex;
flex-direction: column;
font-size: 0.875rem;
margin-left: 1rem;
gap: 0.5rem;
padding: 1rem 1rem;
border-left: 1px solid var(--color-fill-separator);
}
.commit:last-of-type::after {
content: "";
position: absolute;
left: -17px;
top: 12px;
bottom: -1rem;
border-left: 1px solid var(--color-background-default);
}
.expanded {
box-shadow: 0 0 0 1px var(--color-border-hint);
}
.commit-dot {
border-radius: var(--border-radius-round);
width: 4px;
height: 4px;
position: absolute;
top: 0.5rem;
left: -18.5px;
background-color: var(--color-fill-separator);
}
.connector {
width: 1px;
height: 1.5rem;
@@ -373,7 +401,14 @@
</div>
{/if}
{#if response?.commits}
<CobCommitListing commits={response.commits} {baseUrl} {projectId} />
<div class="commits">
{#each response.commits.reverse() as commit}
<div class="commit" style:position="relative">
<div class="commit-dot" />
<CobCommitTeaser {commit} {baseUrl} {projectId} />
</div>
{/each}
</div>
{/if}
</div>
{#if error}