Add badge.component.ts
Create the following file in your project.
import { ChangeDetectionStrategy, Component, computed, input, ViewEncapsulation } from '@angular/core';
import type { ClassValue } from 'clsx';
import { mergeClasses } from '@/shared/utils/merge-classes';
import { badgeVariants, type ZardBadgeTypeVariants } from './badge.variants';
@Component({
selector: 'z-badge, a[z-badge]',
template: `
<ng-content />
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
'[class]': 'classes()',
'[attr.data-variant]': 'zType()',
'data-slot': 'badge',
},
exportAs: 'zBadge',
})
export class ZardBadgeComponent {
readonly zType = input<ZardBadgeTypeVariants>('default');
readonly class = input<ClassValue>('');
protected readonly classes = computed(() => mergeClasses(badgeVariants({ zType: this.zType() }), this.class()));
}