Skip to content

Commit 90a1bf2

Browse files
committed
Merge branch 'main' of https://github.com/npmx-dev/npmx.dev into feat/number-locale-formatting
2 parents 8e26dbf + 9867a47 commit 90a1bf2

6 files changed

Lines changed: 34 additions & 25 deletions

File tree

app/components/Button/Base.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const el = useTemplateRef('el')
2525
2626
defineExpose({
2727
focus: () => el.value?.focus(),
28+
getBoundingClientRect: () => el.value?.getBoundingClientRect(),
2829
})
2930
</script>
3031

app/components/Code/DirectoryListing.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,15 @@ const bytesFormatter = useBytesFormatter()
7575
v-if="parentPath !== null"
7676
class="border-b border-border hover:bg-bg-subtle transition-colors"
7777
>
78-
<td class="py-2 px-4">
78+
<td colspan="2">
7979
<NuxtLink
8080
:to="getCodeRoute(parentPath || undefined)"
81-
class="flex items-center gap-2 font-mono text-sm text-fg-muted hover:text-fg transition-colors"
81+
class="flex items-center gap-2 py-2 px-4 font-mono text-sm text-fg-muted hover:text-fg transition-colors"
8282
>
8383
<span class="i-carbon:folder w-4 h-4 text-yellow-600" />
8484
<span>..</span>
8585
</NuxtLink>
8686
</td>
87-
<td />
8887
</tr>
8988

9089
<!-- Directory/file rows -->
@@ -93,25 +92,26 @@ const bytesFormatter = useBytesFormatter()
9392
:key="node.path"
9493
class="border-b border-border hover:bg-bg-subtle transition-colors"
9594
>
96-
<td class="py-2 px-4">
95+
<td colspan="2">
9796
<NuxtLink
9897
:to="getCodeRoute(node.path)"
99-
class="flex items-center gap-2 font-mono text-sm hover:text-fg transition-colors"
98+
class="flex items-center gap-2 py-2 px-4 font-mono text-sm hover:text-fg transition-colors"
10099
:class="node.type === 'directory' ? 'text-fg' : 'text-fg-muted'"
101100
>
102101
<span
103102
v-if="node.type === 'directory'"
104103
class="i-carbon:folder w-4 h-4 text-yellow-600"
105104
/>
106105
<span v-else class="w-4 h-4" :class="getFileIcon(node.name)" />
107-
<span>{{ node.name }}</span>
106+
<span class="flex-1">{{ node.name }}</span>
107+
<span
108+
v-if="node.type === 'file' && node.size"
109+
class="text-end font-mono text-xs text-fg-subtle"
110+
>
111+
{{ bytesFormatter.format(node.size) }}
112+
</span>
108113
</NuxtLink>
109114
</td>
110-
<td class="py-2 px-4 text-end font-mono text-xs text-fg-subtle">
111-
<span v-if="node.type === 'file' && node.size">
112-
{{ bytesFormatter.format(node.size) }}
113-
</span>
114-
</td>
115115
</tr>
116116
</tbody>
117117
</table>

app/components/Code/Viewer.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const lineNumbers = computed(() => {
1616
return Array.from({ length: props.lines }, (_, i) => i + 1)
1717
})
1818
19+
// Used for CSS calculation of line number column width
20+
const lineDigits = computed(() => {
21+
return String(props.lines).length
22+
})
23+
1924
// Check if a line is selected
2025
function isLineSelected(lineNum: number): boolean {
2126
if (!props.selectedLines) return false
@@ -55,10 +60,11 @@ watch(
5560
</script>
5661

5762
<template>
58-
<div class="code-viewer flex min-h-full">
63+
<div class="code-viewer flex min-h-full max-w-full">
5964
<!-- Line numbers column -->
6065
<div
61-
class="line-numbers shrink-0 bg-bg-subtle border-ie border-border text-end select-none"
66+
class="line-numbers shrink-0 bg-bg-subtle border-ie border-solid border-border text-end select-none relative"
67+
:style="{ '--line-digits': lineDigits }"
6268
aria-hidden="true"
6369
>
6470
<a
@@ -94,7 +100,8 @@ watch(
94100
}
95101
96102
.line-numbers {
97-
min-width: 3.5rem;
103+
/* 1ch per digit + 1.5rem (px-3 * 2) padding */
104+
min-width: calc(var(--line-digits) * 1ch + 1.5rem);
98105
}
99106
100107
.code-content :deep(pre) {

app/components/ReadmeTocDropdown.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ function toggle() {
7979
if (isOpen.value) {
8080
close()
8181
} else {
82-
if (triggerRef.value) {
83-
const rect = triggerRef.value.getBoundingClientRect()
82+
const rect = triggerRef.value?.getBoundingClientRect()
83+
if (rect) {
8484
dropdownPosition.value = {
8585
top: rect.bottom + 4,
8686
right: rect.right,
@@ -145,18 +145,18 @@ function handleKeydown(event: KeyboardEvent) {
145145
</script>
146146

147147
<template>
148-
<button
148+
<ButtonBase
149149
ref="triggerRef"
150150
type="button"
151-
class="flex items-center gap-1.5 px-2 py-2 font-mono text-xs text-fg-muted bg-bg-subtle border border-border-subtle border-solid rounded-md transition-colors duration-150 hover:(text-fg border-border-hover) active:scale-95 focus:border-border-hover focus-visible:outline-accent/70 hover:text-fg"
152151
:aria-expanded="isOpen"
153152
aria-haspopup="listbox"
154153
:aria-label="$t('package.readme.toc_title')"
155154
:aria-controls="listboxId"
156155
@click="toggle"
157156
@keydown="handleKeydown"
157+
classicon="i-carbon:list"
158+
class="px-2.5 flex items-center"
158159
>
159-
<span class="i-carbon:list w-3.5 h-3.5" aria-hidden="true" />
160160
<span
161161
class="i-carbon:chevron-down w-3 h-3"
162162
:class="[
@@ -165,7 +165,7 @@ function handleKeydown(event: KeyboardEvent) {
165165
]"
166166
aria-hidden="true"
167167
/>
168-
</button>
168+
</ButtonBase>
169169

170170
<Teleport to="body">
171171
<Transition

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ defineOgImageComponent('Default', {
409409

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

modules/lunaria.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import process from 'node:process'
21
import { defineNuxtModule, useNuxt } from 'nuxt/kit'
32
import { execSync } from 'node:child_process'
43
import { join } from 'node:path'
54
import { existsSync, mkdirSync } from 'node:fs'
65
import { isCI, isTest } from 'std-env'
6+
import { getEnv } from '../config/env.ts'
77

88
export default defineNuxtModule({
99
meta: {
@@ -33,9 +33,10 @@ export default defineNuxtModule({
3333
cwd: nuxt.options.rootDir,
3434
})
3535
} catch (e) {
36-
// do not throw when building for staging
37-
const env = process.env.VERCEL_ENV
38-
if (!isCI || (env && env === 'production')) {
36+
// Always throw in local dev.
37+
// In CI, only throw if building for production.
38+
const { env } = await getEnv(!isCI)
39+
if (env === 'dev' || env === 'release') {
3940
throw e
4041
}
4142
}

0 commit comments

Comments
 (0)