Skip to content

Commit 9435ba8

Browse files
committed
fix: clickable rows & mobile scroll overflow & dynamic line width
1 parent 6acba09 commit 9435ba8

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

app/components/Code/DirectoryListing.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,15 @@ const parentPath = computed(() => {
5959
v-if="parentPath !== null"
6060
class="border-b border-border hover:bg-bg-subtle transition-colors"
6161
>
62-
<td class="py-2 px-4">
62+
<td colspan="2">
6363
<NuxtLink
6464
:to="parentPath ? `${baseUrl}/${parentPath}` : baseUrl"
65-
class="flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors"
65+
class="flex items-center gap-2 py-2 px-4 font-mono text-sm text-fg-muted hover:text-fg transition-colors"
6666
>
6767
<span class="i-carbon:folder w-4 h-4 text-yellow-600" />
6868
<span>..</span>
6969
</NuxtLink>
7070
</td>
71-
<td />
7271
</tr>
7372

7473
<!-- Directory/file rows -->
@@ -77,25 +76,26 @@ const parentPath = computed(() => {
7776
:key="node.path"
7877
class="border-b border-border hover:bg-bg-subtle transition-colors"
7978
>
80-
<td class="py-2 px-4">
79+
<td colspan="2">
8180
<NuxtLink
8281
:to="`${baseUrl}/${node.path}`"
83-
class="flex items-center gap-2 font-mono text-sm hover:text-fg transition-colors"
82+
class="flex items-center gap-2 py-2 px-4 font-mono text-sm hover:text-fg transition-colors"
8483
:class="node.type === 'directory' ? 'text-fg' : 'text-fg-muted'"
8584
>
8685
<span
8786
v-if="node.type === 'directory'"
8887
class="i-carbon:folder w-4 h-4 text-yellow-600"
8988
/>
9089
<span v-else class="w-4 h-4" :class="getFileIcon(node.name)" />
91-
<span>{{ node.name }}</span>
90+
<span class="flex-1">{{ node.name }}</span>
91+
<span
92+
v-if="node.type === 'file' && node.size"
93+
class="text-end font-mono text-xs text-fg-subtle"
94+
>
95+
{{ formatBytes(node.size) }}
96+
</span>
9297
</NuxtLink>
9398
</td>
94-
<td class="py-2 px-4 text-end font-mono text-xs text-fg-subtle">
95-
<span v-if="node.type === 'file' && node.size">
96-
{{ formatBytes(node.size) }}
97-
</span>
98-
</td>
9999
</tr>
100100
</tbody>
101101
</table>

app/components/Code/Viewer.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const lineNumbers = computed(() => {
1616
return Array.from({ length: props.lines }, (_, i) => i + 1)
1717
})
1818
19+
// Dynamically compute line number column width based on digit count
20+
const lineNumberWidth = computed(() => {
21+
const digits = String(props.lines).length
22+
// ch unit matches monospace digit width + 1.5rem for px-3 padding
23+
return `calc(${digits}ch + 1.5rem)`
24+
})
25+
1926
// Check if a line is selected
2027
function isLineSelected(lineNum: number): boolean {
2128
if (!props.selectedLines) return false
@@ -55,10 +62,11 @@ watch(
5562
</script>
5663

5764
<template>
58-
<div class="code-viewer flex min-h-full">
65+
<div class="code-viewer flex min-h-full overflow-hidden max-w-full">
5966
<!-- Line numbers column -->
6067
<div
61-
class="line-numbers shrink-0 bg-bg-subtle border-ie border-border text-end select-none"
68+
class="line-numbers shrink-0 bg-bg-subtle border-r border-solid border-border text-end select-none relative z-10"
69+
:style="{ minWidth: lineNumberWidth }"
6270
aria-hidden="true"
6371
>
6472
<a
@@ -93,10 +101,6 @@ watch(
93101
font-size: 14px;
94102
}
95103
96-
.line-numbers {
97-
min-width: 3.5rem;
98-
}
99-
100104
.code-content :deep(pre) {
101105
margin: 0;
102106
padding: 0;

app/pages/package-code/[...path].vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ defineOgImageComponent('Default', {
389389
</div>
390390

391391
<!-- Main content: file tree + file viewer -->
392-
<div v-else-if="fileTree" class="flex flex-1">
392+
<div v-else-if="fileTree" class="flex flex-1 overflow-hidden">
393393
<!-- File tree sidebar - sticky with internal scroll -->
394394
<aside
395395
class="w-64 lg:w-72 border-ie border-border shrink-0 hidden md:block bg-bg-subtle sticky top-28 self-start h-[calc(100vh-7rem)] overflow-y-auto"
@@ -403,7 +403,7 @@ defineOgImageComponent('Default', {
403403

404404
<!-- File content / Directory listing - sticky with internal scroll on desktop -->
405405
<div
406-
class="flex-1 min-w-0 md:sticky md:top-28 md:self-start md:h-[calc(100vh-7rem)] md:overflow-y-auto"
406+
class="flex-1 min-w-0 overflow-x-hidden md:sticky md:top-28 md:self-start md:h-[calc(100vh-7rem)] md:overflow-y-auto"
407407
>
408408
<!-- File viewer -->
409409
<template v-if="isViewingFile && fileContent">

0 commit comments

Comments
 (0)