mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 16:00:14 +01:00
feat: docs app
This commit is contained in:
parent
62e6828680
commit
165e64eaca
203 changed files with 15928 additions and 6 deletions
|
|
@ -0,0 +1,52 @@
|
|||
import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
Input,
|
||||
Output,
|
||||
EventEmitter,
|
||||
} from '@angular/core';
|
||||
import { forkJoin, of as observableOf, Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { NgxExampleView } from '../../enum.example-view';
|
||||
import { NgxCodeLoaderService } from '../../../@theme/services/code-loader.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-tabbed-example-block',
|
||||
styleUrls: ['./tabbed-example-block.component.scss'],
|
||||
templateUrl: './tabbed-example-block.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class NgxTabbedExampleBlockComponent {
|
||||
|
||||
|
||||
@Input() hasViewSwitch = false;
|
||||
@Output() changeView = new EventEmitter<NgxExampleView>();
|
||||
examples = [];
|
||||
|
||||
@Input()
|
||||
set content({ files }) {
|
||||
forkJoin(files.map(file => this.load(file)))
|
||||
.subscribe(loadedFiles => {
|
||||
(loadedFiles[0] as any).active = true;
|
||||
this.examples = loadedFiles;
|
||||
this.cd.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
constructor(private codeLoader: NgxCodeLoaderService, private cd: ChangeDetectorRef) {
|
||||
}
|
||||
|
||||
switchToLiveView() {
|
||||
this.changeView.emit(NgxExampleView.LIVE);
|
||||
}
|
||||
|
||||
private load(path): Observable<any> {
|
||||
const extension = path.split('.').pop();
|
||||
return this.codeLoader.load(path)
|
||||
.pipe(
|
||||
map(code => ({ code, path, extension })),
|
||||
catchError(e => observableOf('')),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue