-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
252 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
<div class="jumbotron"> | ||
<h1 class="it-works">{{text}}!!!</h1> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
projects/wvr-elements/src/lib/wvr-tabs/wvr-tab/wvr-tab.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<li class="nav-item"> | ||
<a [id]="htmlId" class="nav-link" [ngClass]="{active: active}" href="#" (click)="clickActivation($event)" role="tab" [attr.aria-controls]="parent?.tabContentID"> | ||
{{tabText}} | ||
</a> | ||
</li> | ||
|
||
<template> | ||
<div class="tab-content"> | ||
<ng-content></ng-content> | ||
</div> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
projects/wvr-elements/src/lib/wvr-tabs/wvr-tab/wvr-tab.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import "../../shared/styles/wvr-variables.scss"; | ||
|
||
:host { | ||
font-family: var(--wvr-font-family-sans-serif); | ||
} |
30 changes: 30 additions & 0 deletions
30
projects/wvr-elements/src/lib/wvr-tabs/wvr-tab/wvr-tab.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { WvrTabComponent } from './wvr-tab.component'; | ||
|
||
describe('WvrTabComponent', () => { | ||
let component: WvrTabComponent; | ||
let fixture: ComponentFixture<WvrTabComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [BrowserAnimationsModule], | ||
declarations: [WvrTabComponent], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WvrTabComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component) | ||
.toBeTruthy(); | ||
}); | ||
}); |
58 changes: 58 additions & 0 deletions
58
projects/wvr-elements/src/lib/wvr-tabs/wvr-tab/wvr-tab.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { AfterViewInit, Component, Injector, Input } from '@angular/core'; | ||
import { SafeHtml } from '@angular/platform-browser'; | ||
import { WvrBaseComponent } from '../../shared/wvr-base.component'; | ||
import { WvrTabsComponent } from '../wvr-tabs.component'; | ||
|
||
@Component({ | ||
selector: 'wvr-tab-element', | ||
templateUrl: './wvr-tab.component.html', | ||
styleUrls: ['./wvr-tab.component.scss'] | ||
}) | ||
export class WvrTabComponent extends WvrBaseComponent implements AfterViewInit { | ||
|
||
parent: WvrTabsComponent; | ||
|
||
active = false; | ||
|
||
htmlId = `wvr-tab-link-${this.id}`; | ||
|
||
@Input() tabText = `Tab ${this.id}`; | ||
|
||
constructor(injector: Injector) { | ||
super(injector); | ||
} | ||
|
||
clickActivation($event: MouseEvent): void { | ||
$event.preventDefault(); | ||
this.activate(); | ||
} | ||
|
||
activate(): void { | ||
this.parent.deactivateTabs(); | ||
this.active = true; | ||
this.parent.activateTab(this); | ||
} | ||
|
||
deActivate(): void { | ||
this.active = false; | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
const tabsElements: HTMLElement = (this._eRef.nativeElement as HTMLElement).closest('wvr-tabs'); | ||
if (tabsElements) { | ||
this.parent = this.componentRegistry.getComponentByElement(tabsElements) as WvrTabsComponent; | ||
this.parent.addTab(this); | ||
} else { | ||
console.warn('The wvr-tab component must be contained within a wvr-tabs component.'); | ||
} | ||
} | ||
|
||
getTabContent(): SafeHtml { | ||
const elem = (this._eRef.nativeElement as HTMLElement); | ||
const contentTemplate = elem.querySelectorAll('template')[0]; | ||
const safeHtml = this._domSanitizer.bypassSecurityTrustHtml(contentTemplate.querySelectorAll('.tab-content')[0].innerHTML); | ||
|
||
return safeHtml; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
projects/wvr-elements/src/lib/wvr-tabs/wvr-tabs.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<ul class="nav nav-tabs" role="tablist"> | ||
<ng-container *ngTemplateOutlet="content"></ng-container> | ||
</ul> | ||
|
||
<tab-content [innerHTML]="activeTabContent" [id]="tabContentID" role="tabpanel" [attr.aria-labelledby]="activeTab?.htmlId"></tab-content> | ||
|
||
<ng-template #content> | ||
<ng-content select="wvr-tab, wvr-tab-element"></ng-content> | ||
</ng-template> |
15 changes: 15 additions & 0 deletions
15
projects/wvr-elements/src/lib/wvr-tabs/wvr-tabs.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@import "../shared/styles/wvr-variables.scss"; | ||
|
||
:host { | ||
|
||
--tab-content-display: block; | ||
--tab-content-padding: 25px 0px; | ||
|
||
font-family: var(--wvr-font-family-sans-serif); | ||
|
||
tab-content { | ||
display: var(--tab-content-display); | ||
padding: var(--tab-content-padding); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
projects/wvr-elements/src/lib/wvr-tabs/wvr-tabs.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { WvrTabsComponent } from './wvr-tabs.component'; | ||
|
||
describe('WvrTabsComponent', () => { | ||
let component: WvrTabsComponent; | ||
let fixture: ComponentFixture<WvrTabsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [BrowserAnimationsModule], | ||
declarations: [WvrTabsComponent], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WvrTabsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component) | ||
.toBeTruthy(); | ||
}); | ||
|
||
}); |
41 changes: 41 additions & 0 deletions
41
projects/wvr-elements/src/lib/wvr-tabs/wvr-tabs.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component, Injector } from '@angular/core'; | ||
import { SafeHtml } from '@angular/platform-browser'; | ||
import { WvrBaseComponent } from '../shared/wvr-base.component'; | ||
import { WvrTabComponent } from './wvr-tab/wvr-tab.component'; | ||
|
||
@Component({ | ||
selector: 'wvr-tabs-element', | ||
templateUrl: './wvr-tabs.component.html', | ||
styleUrls: ['./wvr-tabs.component.scss'] | ||
}) | ||
export class WvrTabsComponent extends WvrBaseComponent { | ||
|
||
private tabs = new Array<WvrTabComponent>(); | ||
|
||
activeTab: WvrTabComponent; | ||
|
||
tabContentID = `wvr-tab-content-${this.id}`; | ||
|
||
activeTabContent: SafeHtml = 'Tab Content'; | ||
|
||
constructor(injector: Injector) { | ||
super(injector); | ||
} | ||
|
||
addTab(tab: WvrTabComponent): void { | ||
if (!this.tabs.length) { | ||
tab.activate(); | ||
} | ||
this.tabs.push(tab); | ||
} | ||
|
||
activateTab(tab: WvrTabComponent): void { | ||
this.activeTab = tab; | ||
this.activeTabContent = tab.getTabContent(); | ||
} | ||
|
||
deactivateTabs(): void { | ||
this.tabs.forEach(t => t.deActivate()); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
projects/wvr-elements/src/lib/wvr-tabs/wvr-tabs.component.ud-examples.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<example name="Weaver Tabs Default"> | ||
<desciption> | ||
The default <code>wvr-tabs</code> component with no customizations. | ||
</desciption> | ||
<snippet> | ||
<wvr-tabs> | ||
<wvr-tab tab-text="Tab One"> | ||
<h3><wvr-text value="First Tab Header"></wvr-text></h3> | ||
<wvr-text value="My First Tab Content"></wvr-text> | ||
</wvr-tab> | ||
<wvr-tab tab-text="Tab Two"> | ||
<h3><wvr-text value="Second Tab Header"></wvr-text></h3> | ||
<wvr-text value="My Second Tab Content"></wvr-text> | ||
</wvr-tab> | ||
</wvr-tabs> | ||
</snippet> | ||
</example> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters