Improve highlight contrast for selected file explorer rows (#6104)

Apply styling via data attributes and custom CSS in main.css instead
of basic utility classes. This provides a more distinct background color
for selected files in both light and dark modes, and adds a subtle border
to ensure legibility against panel backgrounds.
This commit is contained in:
Jinjing
2026-06-22 18:09:08 -07:00
committed by GitHub
parent ae3d088e5e
commit 889ac6094a
2 changed files with 25 additions and 2 deletions
+20
View File
@@ -922,6 +922,26 @@
/* ── Sidebar ─────────────────────────────────────────── */
[data-file-explorer-row][data-selected='true'] {
/* Why: flat bg-accent ≈ panel background in light mode, so selection mixes
foreground into accent and adds an inset ring to stay legible in both themes. */
background: color-mix(in srgb, var(--foreground) 8%, var(--accent));
box-shadow: inset 0 0 0 1px var(--border);
color: var(--accent-foreground);
}
[data-file-explorer-row][data-selected='true']:hover {
background: color-mix(in srgb, var(--foreground) 10%, var(--accent));
}
.dark [data-file-explorer-row][data-selected='true'] {
background: color-mix(in srgb, var(--accent) 70%, transparent);
}
.dark [data-file-explorer-row][data-selected='true']:hover {
background: color-mix(in srgb, var(--accent) 80%, transparent);
}
.sidebar {
width: 240px;
flex-shrink: 0;
@@ -462,9 +462,12 @@ export function FileExplorerRow({
>
<ContextMenuTrigger asChild>
<button
data-file-explorer-row=""
data-selected={isSelected ? 'true' : undefined}
className={cn(
'flex w-full items-center gap-1 rounded-sm px-2 py-1 text-left text-xs transition-colors hover:bg-accent hover:text-foreground',
isSelected && 'bg-accent text-accent-foreground',
'flex w-full items-center gap-1 rounded-sm px-2 py-1 text-left text-xs transition-colors',
!isSelected && 'hover:bg-accent hover:text-foreground',
isSelected && 'text-accent-foreground',
isFlashing && 'bg-amber-400/20 ring-1 ring-inset ring-amber-400/70'
)}
style={{ paddingLeft: `${node.depth * 16 + 8}px` }}