Skip to content

Commit c907c0a

Browse files
committed
refactor: merge button and tag button
1 parent 2e093db commit c907c0a

5 files changed

Lines changed: 18 additions & 34 deletions

File tree

app/components/Button/Base.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const props = withDefaults(
33
defineProps<{
44
disabled?: boolean
55
type?: 'button' | 'submit'
6-
variant?: 'primary' | 'secondary'
6+
variant?: 'primary' | 'secondary' | 'tag'
77
}>(),
88
{
99
type: 'button',
@@ -21,12 +21,14 @@ defineExpose({
2121
<template>
2222
<button
2323
ref="el"
24-
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 disabled:(opacity-40 cursor-not-allowed)"
25-
:class="[
26-
variant === 'primary'
27-
? 'text-bg bg-fg hover:enabled:(bg-fg/90)'
28-
: 'bg-transparent text-fg hover:enabled:(bg-fg text-bg border-fg)',
29-
]"
24+
class="cursor-pointer inline-flex gap-x-1 items-center justify-center font-mono border border-border rounded-md transition-all duration-200 disabled:(opacity-40 cursor-not-allowed) aria-pressed:(bg-fg text-bg border-fg hover:enabled:(text-bg/50))"
25+
:class="{
26+
'text-sm px-4 py-2': variant !== 'tag',
27+
'text-xs px-2 py-0.5': variant === 'tag',
28+
'bg-bg-muted text-fg-muted hover:enabled:(text-fg border-border-hover)': variant === 'tag',
29+
'text-bg bg-fg hover:enabled:(bg-fg/90)': variant === 'primary',
30+
'bg-transparent text-fg hover:enabled:(bg-fg text-bg border-fg)': variant === 'secondary',
31+
}"
3032
:type="props.type"
3133
:disabled="disabled ? true : undefined"
3234
>

app/components/Filter/Panel.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,15 @@ const hasActiveFilters = computed(() => !!filterSummary.value)
307307
{{ $t('filters.keywords') }}
308308
</legend>
309309
<div class="flex flex-wrap gap-1.5" role="group" :aria-label="$t('filters.keywords')">
310-
<TagButton
310+
<ButtonBase
311311
v-for="keyword in displayedKeywords"
312312
:key="keyword"
313+
variant="tag"
313314
:aria-pressed="filters.keywords.includes(keyword)"
314315
@click="emit('toggleKeyword', keyword)"
315316
>
316317
{{ keyword }}
317-
</TagButton>
318+
</ButtonBase>
318319
<button
319320
v-if="hasMoreKeywords"
320321
type="button"

app/components/Package/Card.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,17 @@ const pkgDescription = useMarkdown(() => ({
162162
:aria-label="$t('package.card.keywords')"
163163
class="relative z-10 flex flex-wrap gap-1.5 mt-3 pt-3 border-t border-border list-none m-0 p-0 pointer-events-none items-center"
164164
>
165-
<TagButton
165+
<ButtonBase
166166
v-for="keyword in result.package.keywords.slice(0, 5)"
167167
class="pointer-events-auto"
168+
variant="tag"
168169
:key="keyword"
169170
:aria-pressed="props.filters?.keywords.includes(keyword)"
170171
:title="`Filter by ${keyword}`"
171172
@click.stop="emit('clickKeyword', keyword)"
172173
>
173174
{{ keyword }}
174-
</TagButton>
175+
</ButtonBase>
175176
<span
176177
v-if="result.package.keywords.length > 5"
177178
class="text-fg-subtle text-xs pointer-events-auto"

app/components/Package/TableRow.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,17 @@ const allMaintainersText = computed(() => {
126126
class="flex flex-wrap gap-1 justify-end"
127127
:aria-label="$t('package.card.keywords')"
128128
>
129-
<TagButton
129+
<ButtonBase
130130
v-for="keyword in pkg.keywords.slice(0, 3)"
131131
:key="keyword"
132+
variant="tag"
132133
:aria-pressed="props.filters?.keywords.includes(keyword)"
133134
:title="`Filter by ${keyword}`"
134135
@click.stop="emit('clickKeyword', keyword)"
135136
:class="{ 'group-hover:bg-bg-elevated': !props.filters?.keywords.includes(keyword) }"
136137
>
137138
{{ keyword }}
138-
</TagButton>
139+
</ButtonBase>
139140
<span
140141
v-if="pkg.keywords.length > 3"
141142
class="text-fg-subtle text-xs"

app/components/Tag/Button.vue

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

0 commit comments

Comments
 (0)