sn-badge 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ng-package.json +7 -0
- package/package.json +28 -0
- package/src/lib/sn-badge.component.spec.ts +33 -0
- package/src/lib/sn-badge.component.ts +24 -0
- package/src/lib/sn-badge.html +3 -0
- package/src/lib/sn-badge.scss +20 -0
- package/src/public-api.ts +1 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +8 -0
package/ng-package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sn-badge",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "SnBadge is an Angular 21 standalone badge/pill component",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Swapnil Nakate",
|
|
7
|
+
"email": "nakate.swapnil7@gmail.com",
|
|
8
|
+
"url": "https://swapnilnakate.in"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@angular/common": "^21.0.0",
|
|
12
|
+
"@angular/core": "^21.0.0"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"tslib": "^2.3.0"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/swapnilnakate7/sn-ui/issues",
|
|
20
|
+
"email": "nakate.swapnil7@gmail.com"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"url": "https://github.com/swapnilnakate7/sn-ui",
|
|
24
|
+
"type": "git",
|
|
25
|
+
"directory": "projects/sn-badge"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT"
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { SnBadgeComponent } from './sn-badge.component';
|
|
3
|
+
|
|
4
|
+
describe('SnBadgeComponent', () => {
|
|
5
|
+
let component: SnBadgeComponent;
|
|
6
|
+
let fixture: ComponentFixture<SnBadgeComponent>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [SnBadgeComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(SnBadgeComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should default scheme to "default"', () => {
|
|
23
|
+
expect(component.scheme).toBe('default');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should default size to "md"', () => {
|
|
27
|
+
expect(component.size).toBe('md');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should default pill to false', () => {
|
|
31
|
+
expect(component.pill).toBeFalse();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component, Input, booleanAttribute } from '@angular/core';
|
|
2
|
+
import { CommonModule, NgClass } from '@angular/common';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'sn-badge',
|
|
6
|
+
standalone: true,
|
|
7
|
+
imports: [CommonModule, NgClass],
|
|
8
|
+
templateUrl: './sn-badge.html',
|
|
9
|
+
styleUrl: 'sn-badge.scss',
|
|
10
|
+
})
|
|
11
|
+
export class SnBadgeComponent {
|
|
12
|
+
@Input() scheme: string = 'default';
|
|
13
|
+
@Input({ transform: booleanAttribute }) pill: boolean = false;
|
|
14
|
+
@Input() size: string = 'md';
|
|
15
|
+
|
|
16
|
+
get classes(): Record<string, boolean> {
|
|
17
|
+
return {
|
|
18
|
+
'sn-badge': true,
|
|
19
|
+
[`scheme-${this.scheme}`]: true,
|
|
20
|
+
[`size-${this.size}`]: true,
|
|
21
|
+
'pill': this.pill,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
.sn-badge {
|
|
6
|
+
@apply inline-flex items-center font-medium leading-none;
|
|
7
|
+
|
|
8
|
+
&.size-sm { @apply px-2 py-0.5 text-xs; }
|
|
9
|
+
&.size-md { @apply px-2.5 py-1 text-sm; }
|
|
10
|
+
&.size-lg { @apply px-3 py-1.5 text-base; }
|
|
11
|
+
|
|
12
|
+
&.pill { @apply rounded-full; }
|
|
13
|
+
&:not(.pill) { @apply rounded; }
|
|
14
|
+
|
|
15
|
+
&.scheme-default { @apply bg-gray-100 text-gray-800; }
|
|
16
|
+
&.scheme-primary { @apply bg-blue-100 text-blue-800; }
|
|
17
|
+
&.scheme-warn { @apply bg-yellow-100 text-yellow-800; }
|
|
18
|
+
&.scheme-danger { @apply bg-red-100 text-red-800; }
|
|
19
|
+
&.scheme-success { @apply bg-green-100 text-green-800; }
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/sn-badge.component';
|