forked from npmx-dev/npmx.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLicenseDisplay.vue
More file actions
35 lines (31 loc) · 1.06 KB
/
LicenseDisplay.vue
File metadata and controls
35 lines (31 loc) · 1.06 KB
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
29
30
31
32
33
34
35
<script setup lang="ts">
import { parseLicenseExpression } from '#shared/utils/spdx'
const props = defineProps<{
license: string
}>()
const tokens = computed(() => parseLicenseExpression(props.license))
const hasAnyValidLicense = computed(() => tokens.value.some(t => t.type === 'license' && t.url))
</script>
<template>
<span class="inline-flex items-baseline gap-x-1.5 flex-wrap gap-y-0.5">
<template v-for="(token, i) in tokens" :key="i">
<a
v-if="token.type === 'license' && token.url"
:href="token.url"
target="_blank"
rel="noopener noreferrer"
class="link-subtle"
:title="$t('package.license.view_spdx')"
>
{{ token.value }}
</a>
<span v-else-if="token.type === 'license'">{{ token.value }}</span>
<span v-else-if="token.type === 'operator'" class="text-4xs">{{ token.value }}</span>
</template>
<span
v-if="hasAnyValidLicense"
class="i-carbon-scales w-3.5 h-3.5 text-fg-subtle flex-shrink-0 self-center"
aria-hidden="true"
/>
</span>
</template>