feat: demo version additions

This commit is contained in:
Sergey Andrievskiy 2021-08-06 18:48:35 +03:00
parent 0eec54695f
commit eee950248e
322 changed files with 23456 additions and 188 deletions

View file

@ -0,0 +1,56 @@
import { Injectable } from '@angular/core';
@Injectable()
export class NgxTabbedService {
determineTabs(tabs: any): { [tab: string]: boolean } {
return {
'overview': this.hasOverview(tabs),
'api': this.hasAPI(tabs),
'theme': this.hasTheme(tabs),
'examples': this.hasExample(tabs),
};
}
hasOverview(tabs: any): boolean {
return tabs.source.some(source => this.componentHasOverview(source));
}
hasExample(tabs: any): boolean {
return tabs.source.some(source => this.componentHasExamples(source));
}
hasTheme(tabs: any): boolean {
return tabs.source.some(source => this.componentHasTheme(source));
}
hasAPI(tabs: any): boolean {
return tabs.source.some(source => this.componentHasMethods(source) || this.componentHasProps(source));
}
componentHasTheme(component): boolean {
return component.styles &&
component.styles.length > 0;
}
componentHasProps(component): boolean {
return component &&
component.props &&
component.props.length > 0;
}
componentHasMethods(component): boolean {
return component &&
component.methods &&
component.methods.length > 0 &&
component.methods.some(method => method.shortDescription || method.description);
}
componentHasOverview(component): boolean {
return component && component.overview && component.overview.length > 0;
}
componentHasExamples(component): boolean {
return component.liveExamples && component.liveExamples.length > 0;
}
}