sn-tabs-x 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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/sn-tabs",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "sn-tabs-x",
3
+ "version": "0.0.1",
4
+ "description": "SnTabs is an Angular 21 standalone tabs/tab panel 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-tabs"
26
+ },
27
+ "license": "MIT"
28
+ }
@@ -0,0 +1,37 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { SnTabsXComponent } from './sn-tabs-x.component';
3
+
4
+ describe('SnTabsXComponent', () => {
5
+ let component: SnTabsXComponent;
6
+ let fixture: ComponentFixture<SnTabsXComponent>;
7
+
8
+ beforeEach(async () => {
9
+ await TestBed.configureTestingModule({
10
+ imports: [SnTabsXComponent],
11
+ }).compileComponents();
12
+
13
+ fixture = TestBed.createComponent(SnTabsXComponent);
14
+ component = fixture.componentInstance;
15
+ component.tabs = [
16
+ { label: 'Tab 1', content: 'Content 1' },
17
+ { label: 'Tab 2', content: 'Content 2' },
18
+ ];
19
+ fixture.detectChanges();
20
+ });
21
+
22
+ it('should create', () => {
23
+ expect(component).toBeTruthy();
24
+ });
25
+
26
+ it('should default activeIndex to 0', () => {
27
+ expect(component.activeIndex).toBe(0);
28
+ });
29
+
30
+ it('should update activeIndex and emit tabChange when selectTab is called', () => {
31
+ let emittedIndex = -1;
32
+ component.tabChange.subscribe((i: number) => (emittedIndex = i));
33
+ component.selectTab(1);
34
+ expect(component.activeIndex).toBe(1);
35
+ expect(emittedIndex).toBe(1);
36
+ });
37
+ });
@@ -0,0 +1,25 @@
1
+ import { Component, EventEmitter, Input, Output } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+
4
+ export interface SnTab {
5
+ label: string;
6
+ content: string;
7
+ }
8
+
9
+ @Component({
10
+ selector: 'sn-tabs-x',
11
+ standalone: true,
12
+ imports: [CommonModule],
13
+ templateUrl: './sn-tabs-x.html',
14
+ styleUrl: 'sn-tabs-x.scss',
15
+ })
16
+ export class SnTabsXComponent {
17
+ @Input() tabs: SnTab[] = [];
18
+ @Input() activeIndex: number = 0;
19
+ @Output() tabChange = new EventEmitter<number>();
20
+
21
+ selectTab(index: number): void {
22
+ this.activeIndex = index;
23
+ this.tabChange.emit(index);
24
+ }
25
+ }
@@ -0,0 +1,16 @@
1
+ <div class="sn-tabs">
2
+ <div class="sn-tabs-bar" role="tablist">
3
+ @for (tab of tabs; track tab.label; let i = $index) {
4
+ <button
5
+ class="sn-tab-btn"
6
+ [class.active]="i === activeIndex"
7
+ (click)="selectTab(i)"
8
+ role="tab"
9
+ [attr.aria-selected]="i === activeIndex"
10
+ >{{ tab.label }}</button>
11
+ }
12
+ </div>
13
+ <div class="sn-tab-content" role="tabpanel">
14
+ {{ (activeIndex >= 0 && activeIndex < tabs.length) ? tabs[activeIndex].content : '' }}
15
+ </div>
16
+ </div>
@@ -0,0 +1,25 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ .sn-tabs {
6
+ @apply w-full;
7
+
8
+ .sn-tabs-bar {
9
+ @apply flex border-b border-gray-200;
10
+ }
11
+
12
+ .sn-tab-btn {
13
+ @apply px-4 py-2 text-sm font-medium text-gray-500 border-b-2 border-transparent -mb-px cursor-pointer bg-transparent outline-none transition-colors;
14
+
15
+ &:hover { @apply text-gray-700; }
16
+
17
+ &.active {
18
+ @apply text-blue-600 border-blue-600;
19
+ }
20
+ }
21
+
22
+ .sn-tab-content {
23
+ @apply p-4 text-sm text-gray-700;
24
+ }
25
+ }
@@ -0,0 +1 @@
1
+ export * from './lib/sn-tabs-x.component';
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../out-tsc/lib",
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "inlineSources": true,
8
+ "types": []
9
+ },
10
+ "exclude": ["**/*.spec.ts"]
11
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.lib.json",
3
+ "compilerOptions": {
4
+ "declarationMap": false
5
+ },
6
+ "angularCompilerOptions": {
7
+ "compilationMode": "partial"
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../out-tsc/spec",
5
+ "types": ["jasmine"]
6
+ },
7
+ "include": ["**/*.spec.ts", "**/*.d.ts"]
8
+ }