Skip to content

Commit 4cccb2b

Browse files
committed
Add indicator for when file/lines in file are selected to file tree
1 parent 2710137 commit 4cccb2b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

web/src/routes/Sidebar.svelte

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { type TreeNode } from "$lib/components/tree/index.svelte";
66
import { on } from "svelte/events";
77
import { type Attachment } from "svelte/attachments";
8+
import { boolAttr } from "runed";
89
910
const viewer = MultiFileDiffViewerState.get();
1011
@@ -76,13 +77,14 @@
7677
<div class="h-100">
7778
{#snippet fileSnippet(value: FileDetails)}
7879
<div
79-
class="flex cursor-pointer items-center justify-between btn-ghost px-2 py-1 text-sm focus:ring-2 focus:ring-primary focus:outline-none focus:ring-inset"
80+
class="file flex cursor-pointer items-center justify-between btn-ghost px-2 py-1 text-sm focus:ring-2 focus:ring-primary focus:outline-none focus:ring-inset"
8081
onclick={(e) => scrollToFileClick(e, value.index)}
8182
{@attach focusFileDoubleClick(value)}
8283
onkeydown={(e) => e.key === "Enter" && viewer.scrollToFile(value.index)}
8384
role="button"
8485
tabindex="0"
8586
id={"file-tree-file-" + value.index}
87+
data-selected={boolAttr(viewer.selection?.file.index === value.index)}
8688
>
8789
<span
8890
class="{getFileStatusProps(value.status).iconClasses} me-1 flex size-4 shrink-0 items-center justify-center"
@@ -152,4 +154,16 @@
152154
background-color: var(--color-gray-500);
153155
display: block;
154156
}
157+
.file[data-selected] {
158+
position: relative;
159+
&::after {
160+
content: "";
161+
position: absolute;
162+
top: 0;
163+
left: 0;
164+
width: 100%;
165+
height: 100%;
166+
box-shadow: inset 4px 0 0 0 var(--color-primary);
167+
}
168+
}
155169
</style>

0 commit comments

Comments
 (0)