Skip to content

Commit e132c67

Browse files
committed
feat: collapsible file browser in compare
1 parent 5063edd commit e132c67

1 file changed

Lines changed: 50 additions & 47 deletions

File tree

app/pages/compare/[...path].vue

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -348,57 +348,60 @@ useSeoMeta({
348348
</div>
349349
</div>
350350

351-
<!-- File browser header with dropdown filter -->
352-
<div class="border-b border-border px-3 py-2 shrink-0 bg-bg-muted">
353-
<div class="flex items-center justify-between gap-2">
354-
<h2 class="text-xs font-medium flex items-center gap-1.5">
351+
<!-- File browser collapsible -->
352+
<details class="flex-1 flex flex-col open:flex-1 group" open>
353+
<summary
354+
class="border-b border-border px-3 py-2 shrink-0 bg-bg-muted cursor-pointer list-none flex items-center justify-between gap-2"
355+
>
356+
<span class="text-xs font-medium flex items-center gap-1.5">
355357
<span class="i-carbon-document w-3.5 h-3.5" />
356358
Changed Files
357-
</h2>
358-
359-
<!-- Filter dropdown -->
360-
<select
361-
v-model="fileFilter"
362-
class="text-[10px] px-2 py-1 bg-bg-subtle border border-border rounded font-mono cursor-pointer hover:border-border-hover transition-colors"
363-
>
364-
<option value="all">All ({{ allChanges.length }})</option>
365-
<option value="added">Added ({{ compare.stats.filesAdded }})</option>
366-
<option value="removed">Removed ({{ compare.stats.filesRemoved }})</option>
367-
<option value="modified">Modified ({{ compare.stats.filesModified }})</option>
368-
</select>
369-
</div>
370-
</div>
359+
</span>
360+
<span class="flex items-center gap-2">
361+
<select
362+
v-model="fileFilter"
363+
class="text-[10px] px-2 py-1 bg-bg-subtle border border-border rounded font-mono cursor-pointer hover:border-border-hover transition-colors"
364+
>
365+
<option value="all">All ({{ allChanges.length }})</option>
366+
<option value="added">Added ({{ compare.stats.filesAdded }})</option>
367+
<option value="removed">Removed ({{ compare.stats.filesRemoved }})</option>
368+
<option value="modified">Modified ({{ compare.stats.filesModified }})</option>
369+
</select>
370+
<span class="i-carbon-chevron-right w-3.5 h-3.5 transition-transform group-open:rotate-90" />
371+
</span>
372+
</summary>
373+
374+
<!-- File list (scrollable) -->
375+
<div class="flex-1 overflow-y-auto min-h-0">
376+
<div v-if="filteredChanges.length === 0" class="p-8 text-center text-xs text-fg-muted">
377+
No {{ fileFilter === 'all' ? '' : fileFilter }} files
378+
</div>
371379

372-
<!-- File list (scrollable) -->
373-
<div class="flex-1 overflow-y-auto min-h-0">
374-
<div v-if="filteredChanges.length === 0" class="p-8 text-center text-xs text-fg-muted">
375-
No {{ fileFilter === 'all' ? '' : fileFilter }} files
376-
</div>
380+
<nav v-else class="divide-y divide-border">
381+
<button
382+
v-for="file in filteredChanges"
383+
:key="file.path"
384+
type="button"
385+
class="w-full px-3 py-2 flex items-center gap-2 text-sm text-left hover:bg-bg-muted transition-colors group"
386+
:class="{
387+
'bg-bg-muted border-l-3 border-l-blue-500': selectedFile?.path === file.path,
388+
}"
389+
@click="selectedFile = file"
390+
>
391+
<!-- File icon -->
392+
<span :class="[getFileIcon(file.path), 'w-3.5 h-3.5 shrink-0']" />
377393

378-
<nav v-else class="divide-y divide-border">
379-
<button
380-
v-for="file in filteredChanges"
381-
:key="file.path"
382-
type="button"
383-
class="w-full px-3 py-2 flex items-center gap-2 text-sm text-left hover:bg-bg-muted transition-colors group"
384-
:class="{
385-
'bg-bg-muted border-l-3 border-l-blue-500': selectedFile?.path === file.path,
386-
}"
387-
@click="selectedFile = file"
388-
>
389-
<!-- File icon -->
390-
<span :class="[getFileIcon(file.path), 'w-3.5 h-3.5 shrink-0']" />
391-
392-
<!-- Change type indicator -->
393-
<span :class="[getChangeIcon(file.type), 'w-3 h-3 shrink-0']" />
394-
395-
<!-- File path -->
396-
<span class="font-mono text-[10px] truncate min-w-0 group-hover:text-fg">
397-
{{ file.path }}
398-
</span>
399-
</button>
400-
</nav>
401-
</div>
394+
<!-- Change type indicator -->
395+
<span :class="[getChangeIcon(file.type), 'w-3 h-3 shrink-0']" />
396+
397+
<!-- File path -->
398+
<span class="font-mono text-[10px] truncate min-w-0 group-hover:text-fg">
399+
{{ file.path }}
400+
</span>
401+
</button>
402+
</nav>
403+
</div>
404+
</details>
402405
</aside>
403406

404407
<!-- Right side: Diff viewer -->

0 commit comments

Comments
 (0)