Skip to content

Commit 884033f

Browse files
committed
feat(ui): display all engines in Compatibility section and make common ones pretty
This PR makes Compatibility section more generic, making it display any engine that is actually set in packument. On top of that, it makes the list prettier by not displaying raw machine-oriented data but icons and labels for most popular engines.
1 parent d7bb811 commit 884033f

1 file changed

Lines changed: 37 additions & 15 deletions

File tree

app/components/Package/Compatibility.vue

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,50 @@
11
<script setup lang="ts">
22
const props = defineProps<{
3-
engines?: {
4-
node?: string
5-
npm?: string
6-
}
3+
engines?: Record<string, string>
74
}>()
5+
6+
const engineNames: Record<string, string> = {
7+
bun: 'Bun',
8+
node: 'Node.js',
9+
npm: 'npm',
10+
}
11+
12+
// Map engine name to icon class
13+
const engineIcons: Record<string, string> = {
14+
bun: 'i-simple-icons:bun',
15+
node: 'i-simple-icons:nodedotjs',
16+
npm: 'i-simple-icons:npm',
17+
}
18+
19+
function getName(engine: string): string {
20+
return engineNames[engine] || engine
21+
}
22+
23+
function getIcon(engine: string): string {
24+
return engineIcons[engine] || 'i-carbon:code'
25+
}
826
</script>
927
<template>
1028
<CollapsibleSection
11-
v-if="engines && (engines.node || engines.npm)"
29+
v-if="engines && Object.keys(engines).length"
1230
:title="$t('package.compatibility')"
1331
id="compatibility"
1432
>
1533
<dl class="space-y-2">
16-
<div v-if="engines.node" class="flex justify-between gap-4 py-1">
17-
<dt class="text-fg-muted text-sm shrink-0">node</dt>
18-
<dd class="font-mono text-sm text-fg text-end" :title="engines.node">
19-
{{ engines.node }}
20-
</dd>
21-
</div>
22-
<div v-if="engines.npm" class="flex justify-between gap-4 py-1">
23-
<dt class="text-fg-muted text-sm shrink-0">npm</dt>
24-
<dd class="font-mono text-sm text-fg text-end" :title="engines.npm">
25-
{{ engines.npm }}
34+
<div
35+
v-for="(version, engine) in engines"
36+
:key="engine"
37+
class="flex justify-between gap-4 py-1"
38+
>
39+
<dt class="flex items-center gap-2 text-fg-muted text-sm shrink-0">
40+
<span
41+
:class="[getIcon(engine), 'inline-block w-4 h-4 shrink-0 text-fg-muted']"
42+
aria-hidden="true"
43+
/>
44+
{{ getName(engine) }}
45+
</dt>
46+
<dd class="font-mono text-sm text-fg text-end" :title="version">
47+
{{ version }}
2648
</dd>
2749
</div>
2850
</dl>

0 commit comments

Comments
 (0)