-
-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathEntrypointSelector.vue
More file actions
28 lines (25 loc) · 889 Bytes
/
EntrypointSelector.vue
File metadata and controls
28 lines (25 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script setup lang="ts">
const props = defineProps<{
packageName: string
version: string
currentEntrypoint: string
entrypoints: string[]
}>()
function getEntrypointUrl(entrypoint: string): string {
return `/package-docs/${props.packageName}/v/${props.version}/${entrypoint}`
}
function onSelect(event: Event) {
const target = event.target as HTMLSelectElement
navigateTo(getEntrypointUrl(target.value))
}
</script>
<template>
<select
:value="currentEntrypoint"
aria-label="Select entrypoint"
class="text-fg-subtle font-mono text-sm bg-transparent border border-border rounded px-2 py-1 hover:text-fg hover:border-border-subtle transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring shrink-0"
@change="onSelect"
>
<option v-for="ep in entrypoints" :key="ep" :value="ep">./{{ ep }}</option>
</select>
</template>