Skip to content

Commit 17c0438

Browse files
committed
feat: build a common alert component
1 parent 58da597 commit 17c0438

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

app/components/Alert.vue

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<script setup lang="ts">
2+
interface Props {
3+
variant: 'warning' | 'error'
4+
icon?: string
5+
title?: string
6+
}
7+
8+
defineProps<Props>()
9+
10+
const variantClasses: Record<Props['variant'], string> = {
11+
warning: 'border-amber-400/20 bg-amber-500/8',
12+
error: 'border-red-400/20 bg-red-500/8',
13+
}
14+
15+
const iconClasses: Record<Props['variant'], string> = {
16+
warning: 'text-amber-400/80',
17+
error: 'text-red-400/80',
18+
}
19+
</script>
20+
21+
<template>
22+
<div role="alert" class="border rounded-md px-3 py-2.5" :class="variantClasses[variant]">
23+
<p v-if="icon || title" class="flex items-center gap-1.5 text-sm font-medium text-fg mb-1">
24+
<span
25+
v-if="icon"
26+
:class="[`i-lucide:${icon}`, 'w-3.5 h-3.5 shrink-0', iconClasses[variant]]"
27+
aria-hidden="true"
28+
/>
29+
{{ title }}
30+
</p>
31+
<div class="text-sm text-fg-muted">
32+
<slot />
33+
</div>
34+
</div>
35+
</template>

0 commit comments

Comments
 (0)