-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbadge.ts
More file actions
53 lines (48 loc) · 1.93 KB
/
Copy pathbadge.ts
File metadata and controls
53 lines (48 loc) · 1.93 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Component, ChangeDetectionStrategy, input } from '@angular/core';
export type BadgeVariant = 'primary' | 'success' | 'warning' | 'error' | 'info' | 'neutral';
@Component({
selector: 'app-badge',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './badge.html',
styleUrl: './badge.css',
})
export class BadgeComponent {
readonly variant = input<BadgeVariant>('neutral');
readonly size = input<'sm' | 'md'>('md');
get badgeClasses(): () => string {
return () => {
const base =
'inline-flex items-center font-medium leading-none whitespace-nowrap rounded-md tracking-wide';
const sz = this.size() === 'sm' ? 'px-1.5 py-0.5 text-[10px]' : 'px-2 py-1 text-xs';
let colors = '';
switch (this.variant()) {
case 'primary':
colors =
'bg-[#EAF4EE] text-[#4F8A6B] dark:bg-[#4F8A6B]/20 dark:text-[#5BAE6A] border border-[#4F8A6B]/30';
break;
case 'success':
colors =
'bg-emerald-50 text-[#5BAE6A] dark:bg-emerald-950/50 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800/50';
break;
case 'warning':
colors =
'bg-amber-50 text-amber-700 dark:bg-amber-950/50 dark:text-[#E9B949] border border-amber-200 dark:border-amber-800/50';
break;
case 'error':
colors =
'bg-rose-50 text-[#D66A6A] dark:bg-rose-950/50 dark:text-rose-400 border border-rose-200 dark:border-rose-800/50';
break;
case 'info':
colors =
'bg-blue-50 text-[#5A8DEE] dark:bg-blue-950/50 dark:text-blue-400 border border-blue-200 dark:border-blue-800/50';
break;
case 'neutral':
colors =
'bg-gray-100 text-gray-700 dark:bg-slate-800 dark:text-slate-300 border border-gray-200 dark:border-slate-700';
break;
}
return `${base} ${sz} ${colors}`;
};
}
}