Skip to content

Commit a2c3ff4

Browse files
committed
refactor: merge button and tag link
1 parent c907c0a commit a2c3ff4

3 files changed

Lines changed: 23 additions & 47 deletions

File tree

app/components/Button/Link.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const props = withDefaults(
1212
* If you want a button use `TagButton` instead.
1313
* */
1414
type?: never
15-
variant?: 'primary' | 'secondary'
15+
variant?: 'primary' | 'secondary' | 'tag'
1616
} &
1717
/** This makes sure the link always has either `to` or `href` */
1818
(Required<Pick<NuxtLinkProps, 'to'>> | Required<Pick<NuxtLinkProps, 'href'>>) &
@@ -23,16 +23,28 @@ const props = withDefaults(
2323
</script>
2424

2525
<template>
26-
<!-- This is only a placeholder implementation yet. It will probably need some additional styling, but note: A disabled link is just text. -->
27-
<span v-if="disabled" class="opacity-50"><slot /></span>
26+
<span
27+
v-if="disabled"
28+
class="opacity-50 inline-flex gap-x-1 items-center justify-center font-mono border border-border rounded-md"
29+
:class="{
30+
'text-sm px-4 py-2': variant !== 'tag',
31+
'text-xs px-2 py-0.5': variant === 'tag',
32+
'bg-bg-muted text-fg-muted': variant === 'tag',
33+
'text-bg bg-fg': variant === 'primary',
34+
'bg-transparent text-fg': variant === 'secondary',
35+
}"
36+
><slot
37+
/></span>
2838
<NuxtLink
2939
v-else
30-
class="inline-flex gap-x-1 items-center justify-center px-4 py-2 font-mono text-sm border border-border rounded-md transition-all duration-200"
31-
:class="[
32-
variant === 'primary'
33-
? 'text-bg bg-fg hover:enabled:(bg-fg/90)'
34-
: 'bg-transparent text-fg hover:enabled:(bg-fg text-bg border-fg)',
35-
]"
40+
class="cursor-pointer inline-flex gap-x-1 items-center justify-center font-mono border border-border rounded-md transition-all duration-200 aria-current:(bg-fg text-bg border-fg hover:enabled:(text-bg/50))"
41+
:class="{
42+
'text-sm px-4 py-2': variant !== 'tag',
43+
'text-xs px-2 py-0.5': variant === 'tag',
44+
'bg-bg-muted text-fg-muted hover:(text-fg border-border-hover)': variant === 'tag',
45+
'text-bg bg-fg hover:(bg-fg/90)': variant === 'primary',
46+
'bg-transparent text-fg hover:(bg-fg text-bg border-fg)': variant === 'secondary',
47+
}"
3648
>
3749
<slot />
3850
</NuxtLink>

app/components/Package/Keywords.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ defineProps<{
77
<CollapsibleSection v-if="keywords?.length" :title="$t('package.keywords_title')" id="keywords">
88
<ul class="flex flex-wrap gap-1.5 list-none m-0 p-0">
99
<li v-for="keyword in keywords.slice(0, 15)" :key="keyword">
10-
<TagLink :to="{ name: 'search', query: { q: `keywords:${keyword}` } }">
10+
<ButtonLink variant="tag" :to="{ name: 'search', query: { q: `keywords:${keyword}` } }">
1111
{{ keyword }}
12-
</TagLink>
12+
</ButtonLink>
1313
</li>
1414
</ul>
1515
</CollapsibleSection>

app/components/Tag/Link.vue

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)