2020-05-18 14:37:52 +02:00
|
|
|
/**
|
|
|
|
* The main component that renders single TabComponent
|
|
|
|
* instances.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
ContentChildren,
|
|
|
|
QueryList,
|
|
|
|
AfterContentInit, Output, EventEmitter,
|
|
|
|
} from '@angular/core';
|
|
|
|
|
|
|
|
import { TabComponent } from './tab.component';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-tabs',
|
|
|
|
template: `
|
2020-05-29 16:15:35 +02:00
|
|
|
<ul [class]="(tabs.toArray().length > 2 ? 'uk-visible@m' : '') + ' uk-tab main-tabs uk-margin-remove uk-child-width-expand'"
|
2020-05-26 22:12:37 +02:00
|
|
|
uk-tab uk-switcher="connect: .tabs-content" uk-height-match="target: .tab-header">
|
|
|
|
<li *ngFor="let tab of tabs.toArray(); let i=index"
|
|
|
|
[class]="'uk-padding-remove'+(tab.statistics ? ' statistics ' : '') + (i == 0?' uk-active':'')"
|
|
|
|
(click)="selectTab(tab)">
|
2020-05-18 14:37:52 +02:00
|
|
|
<a class="uk-width-1-1 uk-height-1-1">
|
|
|
|
<div class="tab-header">{{tab.title}}</div>
|
|
|
|
<div *ngIf="tab.num" class="number">{{tab.num | number}}</div>
|
|
|
|
<div *ngIf="tab.statistics" class="number">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
|
|
<path d="M0 0h24v24H0z" fill="none"></path>
|
|
|
|
<path d="M10 20h4V4h-4v16zm-6 0h4v-8H4v8zM16 9v11h4V9h-4z"></path>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2020-05-29 16:15:35 +02:00
|
|
|
<div [class]="(tabs.toArray().length > 2 ? 'uk-visible@m' : '') + ' uk-switcher tabs-content main-tabs-content'">
|
2020-05-18 14:37:52 +02:00
|
|
|
<ng-content></ng-content>
|
|
|
|
</div>
|
2020-05-25 13:27:07 +02:00
|
|
|
`
|
2020-05-18 14:37:52 +02:00
|
|
|
})
|
2020-05-25 20:58:13 +02:00
|
|
|
export class TabsComponent {
|
2020-05-18 14:37:52 +02:00
|
|
|
|
|
|
|
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
|
|
|
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
2020-05-26 22:12:37 +02:00
|
|
|
|
|
|
|
selectTab(tab: TabComponent){
|
|
|
|
// activate the tab the user has clicked on.
|
|
|
|
this.selectedActiveTab.emit(tab.tabId);
|
|
|
|
}
|
2020-05-18 14:37:52 +02:00
|
|
|
}
|