Skip to content

Commit

Permalink
Style file header more nicely
Browse files Browse the repository at this point in the history
- show `added`, `deleted`, `moved`, `copied` as colorful badges
- highlight the filename part of the path and make the path subdued
  • Loading branch information
rudolfs committed Jan 28, 2025
1 parent 5902f3e commit 4e4e84b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/components/Changeset/FileDiff.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -201,28 +201,46 @@
padding-left: 0.5rem;
color: var(--color-foreground-dim);
}
.added {
color: var(--color-foreground-success);
background-color: var(--color-fill-diff-green-light);
}
.deleted {
color: var(--color-foreground-red);
background-color: var(--color-fill-diff-red-light);
}
.moved,
.copied {
color: var(--color-foreground-dim);
background: var(--color-fill-ghost);
}
</style>

{#snippet styledPath(fullPath: string)}
<!-- prettier-ignore -->
<span class="txt-small" style:white-space="nowrap"><span style:color="var(--color-fill-gray)" style:font-weight="var(--font-weight-regular)">{fullPath.match(/^.*\/|/)?.values().next().value}</span><span style:font-weight="var(--font-weight-semibold)">{fullPath.split("/").slice(-1)}</span></span>
{/snippet}

<File {expanded}>
{#snippet leftHeader()}
{#if (headerBadgeCaption === "moved" || headerBadgeCaption === "copied") && oldFilePath}
<span style="display: flex; align-items: center; flex-wrap: wrap;">
{oldFilePath}
{@render styledPath(filePath)}
<span style:padding="0 0.5rem">→</span>
{filePath}
{@render styledPath(filePath)}
</span>
{:else}
{filePath}
{@render styledPath(filePath)}
{/if}

{#if headerBadgeCaption === "added"}
added
<span class="global-counter added">added</span>
{:else if headerBadgeCaption === "deleted"}
deleted
<span class="global-counter deleted">deleted</span>
{:else if headerBadgeCaption === "moved"}
moved
<span class="global-counter moved">moved</span>
{:else if headerBadgeCaption === "copied"}
copied
<span class="global-counter copied">copied</span>
{/if}
{/snippet}

Expand Down

0 comments on commit 4e4e84b

Please sign in to comment.