Merge branch 'new-theme' of code-repo.d4science.org:MaDgIK/openaire-library into new-theme

This commit is contained in:
Konstantinos Triantafyllou 2022-04-06 18:24:21 +03:00
commit 8205f303a7
4 changed files with 387 additions and 346 deletions

View File

@ -89,9 +89,56 @@
<div *ngIf="dataProviderInfo != null"> <div *ngIf="dataProviderInfo != null">
<!-- *ngIf="numberOfTabs > 0; else loadingBlock"--> <!-- *ngIf="numberOfTabs > 0; else loadingBlock"-->
<div class="main-tabs-div"> <div class="main-tabs-div" uk-sticky="offset: 100; ">
<ng-template #summary_tab> <my-tabs (selectedActiveTab)="onSelectActiveTab($event)" >
<div class="uk-grid uk-margin-remove">
<my-tab
[tabTitle]="'Summary'" [tabId]="'summary'" [active]="true">
</my-tab>
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"
[tabTitle]="'Projects'" [tabNumber]="fetchProjects.searchUtils.totalResults"
[tabId]="'projects'" >
</my-tab>
<my-tab *ngIf="fetchDataproviders.searchUtils.totalResults > 0"
[tabTitle]="'Content Providers'" [tabNumber]="fetchDataproviders.searchUtils.totalResults"
[tabId]="'datasources'" >
</my-tab>
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
[tabTitle]="'Related Content Providers'" [tabId]="'relatedDatasources'"
>
</my-tab>
<my-tab *ngIf="fetchPublications.searchUtils.totalResults > 0"
[tabTitle]="'Publications'" [tabNumber]="fetchPublications.searchUtils.totalResults"
[tabId]="'publications'" >
</my-tab>
<my-tab *ngIf="fetchDatasets.searchUtils.totalResults > 0"
[tabTitle]="'Research Data'" [tabNumber]="fetchDatasets.searchUtils.totalResults"
[tabId]="'datasets'" >
</my-tab>
<my-tab *ngIf="fetchSoftware.searchUtils.totalResults > 0"
[tabTitle]="'Software'" [tabNumber]="fetchSoftware.searchUtils.totalResults"
[tabId]="'software'">
</my-tab>
<my-tab *ngIf="fetchOrps.searchUtils.totalResults > 0"
[tabTitle]="'Other Research'" [tabNumber]="fetchOrps.searchUtils.totalResults"
[tabId]="'other'">
</my-tab>
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
[tabTitle]="'Statistics'" customClass="statistics" [tabId]="'statistics'" [active]="false"
>
</my-tab>
</my-tabs>
</div>
<!--Summary-->
<div #summary_tab>
<div id="summary" class="uk-grid uk-margin-remove landing-section">
<div *ngIf="hasPrimaryInfo || (!aggregationStatusIsInitialized || hasAggregationStatusInfo)" <div *ngIf="hasPrimaryInfo || (!aggregationStatusIsInitialized || hasAggregationStatusInfo)"
class="uk-width-expand uk-padding uk-inline"> class="uk-width-expand uk-padding uk-inline">
<!-- Description --> <!-- Description -->
@ -132,11 +179,11 @@
<span class="uk-text-muted">Results with funding information: </span> <span class="uk-text-muted">Results with funding information: </span>
{{dataProviderInfo.fundedContent | number}} {{dataProviderInfo.fundedContent | number}}
</span> </span>
<!-- <span *ngIf="dataProviderInfo.aggregationStatus.lastUpdateDate"--> <!-- <span *ngIf="dataProviderInfo.aggregationStatus.lastUpdateDate"-->
<!-- class="uk-display-inline-block">--> <!-- class="uk-display-inline-block">-->
<!-- <span class="uk-text-muted">Latest data aggregation: </span>--> <!-- <span class="uk-text-muted">Latest data aggregation: </span>-->
<!-- {{dataProviderInfo.aggregationStatus.lastUpdateDate | date}}--> <!-- {{dataProviderInfo.aggregationStatus.lastUpdateDate | date}}-->
<!-- </span>--> <!-- </span>-->
</div> </div>
<div *ngIf="!aggregationStatusIsInitialized || !dataProviderInfo.fundedContent" <div *ngIf="!aggregationStatusIsInitialized || !dataProviderInfo.fundedContent"
class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert"> class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">
@ -240,9 +287,10 @@
</div> </div>
</div> </div>
</div> </div>
</ng-template> </div>
<ng-template #projects_tab> <!--Projects-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="fetchProjects.searchUtils.totalResults > 0">
<div id="projects" class="uk-grid uk-margin-remove landing-section">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<search-tab [fetch]="fetchProjects" resultType="project" <search-tab [fetch]="fetchProjects" resultType="project"
[params]="getParamsForSearchLink()" [params]="getParamsForSearchLink()"
@ -250,11 +298,12 @@
[properties]="properties"> [properties]="properties">
</search-tab> </search-tab>
</div> </div>
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>--> <!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
</div> </div>
</ng-template> </ng-container>
<ng-template #datasources_tab> <!--Content Providers-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
<div id="datasources" class="uk-grid uk-margin-remove landing-section">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<search-tab [fetch]="fetchDataproviders" resultType="dataprovider" <search-tab [fetch]="fetchDataproviders" resultType="dataprovider"
[params]="getParamsForSearchLink()" [params]="getParamsForSearchLink()"
@ -262,11 +311,13 @@
[properties]="properties"> [properties]="properties">
</search-tab> </search-tab>
</div> </div>
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>--> <!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
</div> </div>
</ng-template> </ng-container>
<ng-template #relatedDatasources_tab> <!--Related Content Providers-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)">
<div id="relatedDatasources" class="uk-grid uk-margin-remove landing-section">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<relatedDatasourcesTab <relatedDatasourcesTab
[dataproviderId]="datasourceId" [dataproviderId]="datasourceId"
@ -279,9 +330,10 @@
</relatedDatasourcesTab> </relatedDatasourcesTab>
</div> </div>
</div> </div>
</ng-template> </ng-container>
<ng-template #publications_tab> <!--Publications-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="fetchPublications.searchUtils.totalResults > 0">
<div id="publications" class="uk-grid uk-margin-remove landing-section">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<search-tab [fetch]="fetchPublications" resultType="publication" <search-tab [fetch]="fetchPublications" resultType="publication"
[params]="getParamsForSearchLink('publications')" [params]="getParamsForSearchLink('publications')"
@ -289,11 +341,12 @@
[properties]="properties"> [properties]="properties">
</search-tab> </search-tab>
</div> </div>
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>--> <!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
</div> </div>
</ng-template> </ng-container>
<ng-template #datasets_tab> <!--Research Data-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="fetchDatasets.searchUtils.totalResults > 0">
<div id="datasets" class="uk-grid uk-margin-remove">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<search-tab [fetch]="fetchDatasets" resultType="dataset" <search-tab [fetch]="fetchDatasets" resultType="dataset"
[params]="getParamsForSearchLink('datasets')" [params]="getParamsForSearchLink('datasets')"
@ -301,11 +354,12 @@
[properties]="properties"> [properties]="properties">
</search-tab> </search-tab>
</div> </div>
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>--> <!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
</div> </div>
</ng-template> </ng-container>
<ng-template #software_tab> <!--Software-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="fetchSoftware.searchUtils.totalResults > 0">
<div id="software" class="uk-grid uk-margin-remove">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<search-tab [fetch]="fetchSoftware" resultType="software" <search-tab [fetch]="fetchSoftware" resultType="software"
[params]="getParamsForSearchLink('software')" [params]="getParamsForSearchLink('software')"
@ -313,11 +367,12 @@
[properties]="properties"> [properties]="properties">
</search-tab> </search-tab>
</div> </div>
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>--> <!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
</div> </div>
</ng-template> </ng-container>
<ng-template #other_tab> <!--Other-->
<div class="uk-grid uk-margin-remove"> <ng-container *ngIf="fetchOrps.searchUtils.totalResults > 0">
<div id="other" class="uk-grid uk-margin-remove">
<div class="uk-width-expand uk-padding"> <div class="uk-width-expand uk-padding">
<search-tab [fetch]="fetchOrps" resultType="other" <search-tab [fetch]="fetchOrps" resultType="other"
[params]="getParamsForSearchLink('other')" [params]="getParamsForSearchLink('other')"
@ -325,12 +380,14 @@
[properties]="properties"> [properties]="properties">
</search-tab> </search-tab>
</div> </div>
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>--> <!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
</div> </div>
</ng-template> </ng-container>
<ng-template #statistics_tab> <!--Statistics-->
<div class=""> <ng-container *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
<div class="uk-width-expand uk-padding"> || fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)">
<div id="statistics" class="uk-width-expand uk-padding">
<errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status, <errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status,
fetchSoftware.searchUtils.status, fetchOrps.searchUtils.status]" fetchSoftware.searchUtils.status, fetchOrps.searchUtils.status]"
[type]="'statistics'" tab_error_class=true></errorMessages> [type]="'statistics'" tab_error_class=true></errorMessages>
@ -345,131 +402,8 @@
</statisticsTab> </statisticsTab>
</div> </div>
</div> </div>
</div>
</ng-template>
<!-- [class]="numberOfTabs > 2 ? 'uk-visible@m' : ''"--> </ng-container>
<my-tabs (selectedActiveTab)="onSelectActiveTab($event)">
<!-- *ngIf="hasPrimaryInfo || hasSecondaryInfo"-->
<!-- [class]="(firstTab === 'summary')?'uk-active':''"-->
<my-tab
[tabTitle]="'Summary'" [tabId]="'summary'" class="uk-active">
<ng-container *ngTemplateOutlet="summary_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'projects')?'uk-active':''"-->
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"
[tabTitle]="'Projects'" [tabNumber]="fetchProjects.searchUtils.totalResults"
[tabId]="'projects'" >
<ng-container *ngTemplateOutlet="projects_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'datasources')?'uk-active':''"-->
<my-tab *ngIf="fetchDataproviders.searchUtils.totalResults > 0"
[tabTitle]="'Content Providers'" [tabNumber]="fetchDataproviders.searchUtils.totalResults"
[tabId]="'datasources'" >
<ng-container *ngTemplateOutlet="datasources_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'relatedDatasources')?'uk-active':''"-->
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
[tabTitle]="'Related Content Providers'" [tabId]="'relatedDatasources'"
>
<ng-container *ngTemplateOutlet="relatedDatasources_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'publications')?'uk-active':''"-->
<my-tab *ngIf="fetchPublications.searchUtils.totalResults > 0"
[tabTitle]="'Publications'" [tabNumber]="fetchPublications.searchUtils.totalResults"
[tabId]="'publications'" >
<ng-container *ngTemplateOutlet="publications_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'datasets')?'uk-active':''"-->
<my-tab *ngIf="fetchDatasets.searchUtils.totalResults > 0"
[tabTitle]="'Research Data'" [tabNumber]="fetchDatasets.searchUtils.totalResults"
[tabId]="'datasets'" >
<ng-container *ngTemplateOutlet="datasets_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'software')?'uk-active':''"-->
<my-tab *ngIf="fetchSoftware.searchUtils.totalResults > 0"
[tabTitle]="'Software'" [tabNumber]="fetchSoftware.searchUtils.totalResults"
[tabId]="'software'">
<ng-container *ngTemplateOutlet="software_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'other')?'uk-active':''"-->
<my-tab *ngIf="fetchOrps.searchUtils.totalResults > 0"
[tabTitle]="'Other Research'" [tabNumber]="fetchOrps.searchUtils.totalResults"
[tabId]="'other'">
<ng-container *ngTemplateOutlet="other_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'statistics')?'uk-active':''"-->
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
[tabTitle]="'Statistics'" customClass="statistics" [tabId]="'statistics'"
>
<ng-container *ngTemplateOutlet="statistics_tab;"></ng-container>
</my-tab>
</my-tabs>
<!-- <div *ngIf="numberOfTabs() > 2">TEST!!!</div>-->
<!-- *ngIf="numberOfTabs > 2"-->
<my-small-tabs (selectedActiveTab)="onSelectActiveTab($event)">
<!-- *ngIf="hasPrimaryInfo || hasSecondaryInfo"-->
<!-- [class]="(firstTab === 'summary')?'uk-active':''"-->
<my-tab
[tabTitle]="'Summary'" [tabId]="'summary'" class="uk-active">
<ng-container *ngTemplateOutlet="summary_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'projects')?'uk-active':''"-->
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"
[tabTitle]="'Projects'" [tabNumber]="fetchProjects.searchUtils.totalResults"
[tabId]="'projects'" >
<ng-container *ngTemplateOutlet="projects_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'datasources')?'uk-active':''"-->
<my-tab *ngIf="fetchDataproviders.searchUtils.totalResults > 0"
[tabTitle]="'Content Providers'" [tabNumber]="fetchDataproviders.searchUtils.totalResults"
[tabId]="'datasources'" >
<ng-container *ngTemplateOutlet="datasources_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'relatedDatasources')?'uk-active':''"-->
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
[tabTitle]="'Related Content Providers'" [tabId]="'relatedDatasources'"
>
<ng-container *ngTemplateOutlet="relatedDatasources_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'publications')?'uk-active':''"-->
<my-tab *ngIf="fetchPublications.searchUtils.totalResults > 0"
[tabTitle]="'Publications'" [tabNumber]="fetchPublications.searchUtils.totalResults"
[tabId]="'publications'" >
<ng-container *ngTemplateOutlet="publications_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'datasets')?'uk-active':''"-->
<my-tab *ngIf="fetchDatasets.searchUtils.totalResults > 0"
[tabTitle]="'Research Data'" [tabNumber]="fetchDatasets.searchUtils.totalResults"
[tabId]="'datasets'" >
<ng-container *ngTemplateOutlet="datasets_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'software')?'uk-active':''"-->
<my-tab *ngIf="fetchSoftware.searchUtils.totalResults > 0"
[tabTitle]="'Software'" [tabNumber]="fetchSoftware.searchUtils.totalResults"
[tabId]="'software'">
<ng-container *ngTemplateOutlet="software_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'other')?'uk-active':''"-->
<my-tab *ngIf="fetchOrps.searchUtils.totalResults > 0"
[tabTitle]="'Other Research'" [tabNumber]="fetchOrps.searchUtils.totalResults"
[tabId]="'other'">
<ng-container *ngTemplateOutlet="other_tab;"></ng-container>
</my-tab>
<!-- [class]="(firstTab === 'statistics')?'uk-active':''"-->
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
[tabTitle]="'Statistics'" customClass="statistics" [tabId]="'statistics'"
>
<ng-container *ngTemplateOutlet="statistics_tab;"></ng-container>
</my-tab>
</my-small-tabs>
</div>
<!-- <ng-template #loadingBlock>--> <!-- <ng-template #loadingBlock>-->
<!-- <div *ngIf="!tabsAreInitialized" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">--> <!-- <div *ngIf="!tabsAreInitialized" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">-->
<!-- <span class="loading-gif uk-align-center" ></span>--> <!-- <span class="loading-gif uk-align-center" ></span>-->

View File

@ -26,6 +26,7 @@ import {ResultPreview} from "../../utils/result-preview/result-preview";
import {IndexInfoService} from "../../utils/indexInfo.service"; import {IndexInfoService} from "../../utils/indexInfo.service";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {TabComponent} from "../../utils/tabs/tab.component";
@Component({ @Component({
@ -596,7 +597,7 @@ export class DataProviderComponent {
} }
public onSelectActiveTab(activeTabId) { public onSelectActiveTab(activeTabId) {
if (this.activeTab != "activaTabId") { // tab really changed if (this.activeTab != activeTabId) { // tab really changed
if (activeTabId == 'summary') { if (activeTabId == 'summary') {
this.activeTab = 'summary'; this.activeTab = 'summary';
} else if (activeTabId == 'publications') { } else if (activeTabId == 'publications') {

View File

@ -27,4 +27,6 @@ export class TabComponent {
@Input('customClass') customClass:string = ""; @Input('customClass') customClass:string = "";
@Input('tabId') tabId: string; @Input('tabId') tabId: string;
@Input('tabIcon') tabIcon: TabIcon; @Input('tabIcon') tabIcon: TabIcon;
@Input ('active') active: boolean = false;
@Input ('disabled') disabled: boolean = false;
} }

View File

@ -2,15 +2,60 @@
* The main component that renders single TabComponent * The main component that renders single TabComponent
* instances. * instances.
*/ */
import {AfterContentInit, Component, ContentChildren, EventEmitter, Input, Output, QueryList,} from '@angular/core'; import {
AfterContentInit,
Component,
ContentChildren,
EventEmitter,
HostListener,
Output,
QueryList,
} from '@angular/core';
import {TabComponent} from './tab.component'; import {TabComponent} from './tab.component';
@Component({ @Component({
selector: 'my-tabs', selector: 'my-tabs',
template: ` template: `
<ul class="uk-tab" [ngClass]="customClass" uk-tab="connect: .tabs-content"> <div class="uk-grid uk-margin-remove-left">
<!-- [class.uk-active]="selected === tab.tabId"-->
<li *ngFor="let tab of tabs.toArray(); let i=index" [ngClass]="tab.customClass" (click)="selectTab(tab)"> <div class="uk-margin-medium-right uk-padding-small uk-width-expand" >
<div class=" uk-width-1-1" uk-slider="finite: true">
<div class="uk-position-relative " >
<div class="uk-slider-container ">
<ul class=" uk-slider-items " style="flex-wrap: nowrap !important;" >
<ng-container *ngFor="let tab of tabs.toArray(); let i=index">
<ng-container *ngIf="!tab.customClass">
<li [ngClass]="tab.customClass" (click)="selectTab(tab)" >
<ul class="uk-tab">
<li [class.uk-active]="tab.active" [class.uk-disabled]="tab.disabled">
<a class="uk-width-1-1 uk-height-1-1 uk-flex uk-flex-center" [ngClass]="tab.tabIcon ? 'uk-flex-column' : ''">
<icon *ngIf="tab.tabIcon" [svg]="tab.tabIcon.svg" [ratio]="tab.tabIcon.ratio?tab.tabIcon.ratio:1" class="uk-margin-small-bottom"
[ngClass]="(selected === tab.tabId)?tab.tabIcon.active:null"></icon>
<div>{{tab.title}}</div>
<div *ngIf="tab.num && !tab.disabled" class="">({{tab.num | number}})</div>
<div *ngIf="tab.disabled" class="">(-)</div>
</a>
</li>
</ul>
</li>
</ng-container>
</ng-container>
</ul>
</div>
<div class="">
<a class="uk-position-center-left-out" uk-slider-item="previous"><span uk-icon="chevron-left"></span></a>
<a class="uk-position-center-right-out" uk-slider-item="next"><span uk-icon="chevron-right"></span></a>
</div>
</div>
</div>
</div>
<ng-container *ngFor="let tab of tabs.toArray(); let i=index">
<ng-container *ngIf="tab.customClass">
<div class="uk-width-small uk-padding-small">
<ul class="uk-tab">
<li [ngClass]="tab.customClass" (click)="selectTab(tab)" [class.uk-active]="tab.active" >
<a class="uk-width-1-1 uk-height-1-1 uk-flex uk-flex-center" [ngClass]="tab.tabIcon ? 'uk-flex-column' : ''"> <a class="uk-width-1-1 uk-height-1-1 uk-flex uk-flex-center" [ngClass]="tab.tabIcon ? 'uk-flex-column' : ''">
<icon *ngIf="tab.tabIcon" [svg]="tab.tabIcon.svg" [ratio]="tab.tabIcon.ratio?tab.tabIcon.ratio:1" class="uk-margin-small-bottom" <icon *ngIf="tab.tabIcon" [svg]="tab.tabIcon.svg" [ratio]="tab.tabIcon.ratio?tab.tabIcon.ratio:1" class="uk-margin-small-bottom"
[ngClass]="(selected === tab.tabId)?tab.tabIcon.active:null"></icon> [ngClass]="(selected === tab.tabId)?tab.tabIcon.active:null"></icon>
@ -19,26 +64,85 @@ import {TabComponent} from './tab.component';
</a> </a>
</li> </li>
</ul> </ul>
<div class="uk-switcher tabs-content">
<ng-content></ng-content>
</div> </div>
</ng-container>
</ng-container>
</div>
` `
}) })
export class TabsComponent implements AfterContentInit { export class TabsComponent implements AfterContentInit {
@Input()
public customClass: string; public customClass: string;
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>; @ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter(); @Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
public selected: string; public selected: string;
disableScroll = false;
@HostListener("window:scroll", [])
onWindowScroll() {
this.scroll();
}
ngAfterContentInit() { ngAfterContentInit() {
if(this.tabs.length > 0) { if(this.tabs.length > 0) {
this.selected = this.tabs.get(0).tabId; this.selected = this.tabs.get(0).tabId;
} }
} }
selectTab(tab: TabComponent){ selectTab(tab: TabComponent, scroll=true){
console.log("Select tab ",tab.tabId);
this.unSelectTab(this.selected, tab.tabId);
tab.active = true;
this.selected = tab.tabId; this.selected = tab.tabId;
this.selectedActiveTab.emit(tab.tabId); this.selectedActiveTab.emit(tab.tabId);
if(scroll) {
this.disableScroll = true;
setTimeout(() => {
window.scrollTo({
top: document.getElementById(tab.tabId) ? document.getElementById(tab.tabId).offsetTop - 180 : 250,
behavior: 'smooth'
});
setTimeout(() => {
this.disableScroll = false;
}, 600);
console.log(window.scrollY, tab.tabId, document.getElementById(tab.tabId))
}, 200);
}
}
scroll(){
if(this.disableScroll){
return;
}
// console.log(window.scrollY)
let currentTabView = null;
let windowInnerHeight = window && window.innerHeight ? window.innerHeight : 300;
// console.log("find CT", windowInnerHeight)
for (let tab of this.tabs) {
let distanceFromCurrentViewTop = document.getElementById(tab.tabId) ? document.getElementById(tab.tabId).getBoundingClientRect().top : null;
// console.log(pos, distanceFromCurrentViewTop, windowInnerHeight/2);
if (distanceFromCurrentViewTop != null && distanceFromCurrentViewTop <= windowInnerHeight / 2) {
currentTabView = tab;
} else if (distanceFromCurrentViewTop != null && distanceFromCurrentViewTop > windowInnerHeight) {
break;
}
}
// console.log("current currentTabView", currentTabView.tabId)
if (currentTabView && this.selected != currentTabView.tabId) {
this.selectTab(currentTabView, false);
this.disableScroll =true;
setTimeout(() => {
this.disableScroll = false;
}, 600);
}
}
unSelectTab(oldTabId, newTabId){
for (let tab of this.tabs) {
if(tab.tabId == oldTabId){
tab.active = false;
break;
}
}
this.selected = newTabId;
} }
} }