Skip to content

Commit 778cfb1

Browse files
committed
refactor: extract reusable Card component
1 parent 4801787 commit 778cfb1

4 files changed

Lines changed: 30 additions & 35 deletions

File tree

app/components/Card.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
/** Whether this suggestion is currently selected (keyboard nav) */
4+
selected?: boolean
5+
/** Whether this is an exact match for the query */
6+
isExactMatch?: boolean
7+
}>()
8+
</script>
9+
10+
<template>
11+
<article
12+
class="group bg-bg-subtle border border-border rounded-lg p-4 sm:p-6 transition-[border-color,background-color] duration-200 hover:(border-border-hover bg-bg-muted) cursor-pointer relative focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-bg focus-within:ring-offset-2 focus-within:ring-fg/50"
13+
:class="{
14+
'bg-bg-muted border-border-hover': selected,
15+
'border-accent/30 bg-accent/5': isExactMatch,
16+
}"
17+
>
18+
<!-- Glow effect for exact matches -->
19+
<div
20+
v-if="isExactMatch"
21+
class="absolute -inset-px rounded-lg bg-gradient-to-r from-accent/0 via-accent/20 to-accent/0 opacity-100 blur-sm -z-1 pointer-events-none motion-reduce:opacity-50"
22+
aria-hidden="true"
23+
/>
24+
<slot />
25+
</article>
26+
</template>

app/components/PackageCard.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,7 @@ const emit = defineEmits<{
2727
</script>
2828

2929
<template>
30-
<article
31-
class="group card-interactive scroll-mt-48 scroll-mb-6 relative focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-bg focus-within:ring-offset-2 focus-within:ring-fg/50"
32-
:class="{
33-
'bg-bg-muted border-border-hover': selected,
34-
'border-accent/30 bg-accent/5': isExactMatch,
35-
}"
36-
>
37-
<!-- Glow effect for exact matches -->
38-
<div
39-
v-if="isExactMatch"
40-
class="absolute -inset-px rounded-lg bg-gradient-to-r from-accent/0 via-accent/20 to-accent/0 opacity-100 blur-sm -z-1 pointer-events-none motion-reduce:opacity-50"
41-
aria-hidden="true"
42-
/>
30+
<Card :selected="selected" :isExactMatch="isExactMatch">
4331
<div class="mb-2 flex items-baseline justify-start gap-2">
4432
<component
4533
:is="headingLevel ?? 'h3'"
@@ -173,5 +161,5 @@ const emit = defineEmits<{
173161
{{ keyword }}
174162
</li>
175163
</ul>
176-
</article>
164+
</Card>
177165
</template>

app/components/SearchSuggestionCard.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,7 @@ const emit = defineEmits<{
1818
</script>
1919

2020
<template>
21-
<article
22-
class="group card-interactive relative focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-bg focus-within:ring-offset-2 focus-within:ring-fg/50"
23-
:class="{
24-
'bg-bg-muted border-border-hover': selected,
25-
'border-accent/30 bg-accent/5': isExactMatch,
26-
}"
27-
>
28-
<!-- Glow effect for exact matches -->
29-
<div
30-
v-if="isExactMatch"
31-
class="absolute -inset-px rounded-lg bg-gradient-to-r from-accent/0 via-accent/20 to-accent/0 opacity-100 blur-sm -z-1 pointer-events-none motion-reduce:opacity-50"
32-
aria-hidden="true"
33-
/>
21+
<Card :selected="selected" :isExactMatch="isExactMatch">
3422
<NuxtLink
3523
:to="type === 'user' ? `/~${name}` : `/@${name}`"
3624
:data-suggestion-index="index"
@@ -81,5 +69,5 @@ const emit = defineEmits<{
8169
aria-hidden="true"
8270
/>
8371
</NuxtLink>
84-
</article>
72+
</Card>
8573
</template>

uno.config.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ export default defineConfig({
136136
],
137137
['link-subtle', 'text-fg-muted hover:text-fg transition-colors duration-200 focus-ring'],
138138

139-
// Cards
140-
[
141-
'card',
142-
'bg-bg-subtle border border-border rounded-lg p-4 sm:p-6 transition-[border-color,background-color] duration-200',
143-
],
144-
['card-interactive', 'card hover:(border-border-hover bg-bg-muted) cursor-pointer'],
145-
146139
// Form elements
147140
[
148141
'input-base',

0 commit comments

Comments
 (0)