Skip to content

Commit

Permalink
docs: (core) stackblitz maintenance (#1880)
Browse files Browse the repository at this point in the history
* add files to declaration

* remove modules
  • Loading branch information
stefanoScalzo committed Jan 30, 2020
1 parent 0b92f7e commit 707b82f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 100 deletions.
Expand Up @@ -95,6 +95,9 @@ export class AlertDocsComponent implements OnInit {
fileName: 'alert-component-as-content-example',
code: alertComponentAsContentExample,
component: 'AlertComponentAsContentExampleComponent',
entryComponent: 'AlertContentComponent, AlertComponentAsContentExampleComponent',
declarationArray: 'AlertContentComponent',
imports: `import { AlertContentComponent } from './alert-content.component';`

},
{
Expand All @@ -103,14 +106,7 @@ export class AlertDocsComponent implements OnInit {
name: 'Alert Content',
fileName: 'alert-content',
secondFile: 'alert-content'
},
{
language: 'typescript',
code: alertComponentAsContentExampleModule,
name: 'Module',
module: 'app.module.ts'
}

];

alertInlineExample: ExampleFile[] = [
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -97,19 +97,16 @@ export class ModalDocsComponent implements OnInit {
secondFile: 'modal-content',
fileName: 'modal-content',
component: 'ModalContentComponent',
imports: `import { ModalContentComponent } from './modal-content.component';`,
entryComponent: 'ModalContentComponent, ModalComponentAsContentExampleComponent',
declarationArray: 'ModalContentComponent'
},
{
language: 'typescript',
code: componentAsContentSrc,
fileName: 'modal-component-as-content-example',
component: 'ModalComponentAsContentExampleComponent',
},
{
language: 'typescript',
code: componentAsContentModule,
name: 'Module',
module: 'app.module.ts',
},
];

modalInModalExample: ExampleFile[] = [
Expand All @@ -120,7 +117,11 @@ export class ModalDocsComponent implements OnInit {
name: 'Second Modal',
thirdFile: 'modal-in-modal-second-example',
fileName: 'modal-in-modal-second-example',
component: 'ModalInModalSecondComponent'
component: 'ModalInModalSecondComponent',
imports: `import { ModalInModalFirstComponent } from './modal-in-modal-first-example.component';
import { ModalInModalSecondComponent } from './modal-in-modal-second-example.component';`,
declarationArray: 'ModalInModalComponent, ModalInModalFirstComponent,ModalInModalSecondComponent',
entryComponent: 'ModalInModalComponent, ModalInModalFirstComponent, ModalInModalSecondComponent'
},
{
language: 'typescript',
Expand All @@ -136,12 +137,6 @@ export class ModalDocsComponent implements OnInit {
fileName: 'modal-in-modal-stacked-example',
component: 'ModalInModalComponent'
},
{
language: 'typescript',
code: modalInModalModule,
name: 'Module',
module: 'app.module.ts',
}
];

fullScreenSource: ExampleFile[] = [
Expand Down
Expand Up @@ -49,7 +49,10 @@ export class CodeExampleComponent implements OnInit, AfterViewInit {
app_component_html: '',
app_component_ts: '',
app_component_html_path: '',
app_component_ts_path: ''
app_component_ts_path: '',
app_module_entryComponents: '',
app_module_imports: '',
app_module_declarationArray: ''
};

app_app_component = ``
Expand Down Expand Up @@ -139,6 +142,15 @@ export class CodeExampleComponent implements OnInit, AfterViewInit {
} else {
this.parameters.html_tag = 'fd-' + example.fileName;
}
if (example.entryComponent !== undefined) {
this.parameters.app_module_entryComponents = example.entryComponent;
}
if (example.declarationArray !== undefined) {
this.parameters.app_module_declarationArray = example.declarationArray;
}
if (example.imports !== undefined) {
this.parameters.app_module_imports = example.imports;
}
this.parameters.app_module = 'AppModule';
this.parameters.app_module_file = 'app.module';
this.parameters.app_component = example.component;
Expand Down Expand Up @@ -181,24 +193,23 @@ export class CodeExampleComponent implements OnInit, AfterViewInit {
this.project.files[_pathTS] = example.typescriptFileCode.default;
}
}
if (example.language === 'typescript' && (example.secondFile === undefined && example.thirdFile === undefined && example.module === undefined)) {
if (example.language === 'typescript' && (example.secondFile === undefined && example.thirdFile === undefined)) {
const _pathTS = `src/app/${example.fileName}.component.ts`;
this.project.files[_pathTS] = example.code.default;
}
// tslint:disable-next-line: max-line-length
else if (example.language === 'typescript' && (example.secondFile !== undefined && example.thirdFile === undefined && example.module === undefined)) {
else if (example.language === 'typescript' && (example.secondFile !== undefined && example.thirdFile === undefined)) {
const _pathTS2 = `src/app/${example.secondFile}.component.ts`;
this.project.files[_pathTS2] = example.code.default;

}
// tslint:disable-next-line: max-line-length
else if (example.language === 'typescript' && (example.thirdFile !== undefined && example.secondFile === undefined && example.module === undefined)) {
else if (example.language === 'typescript' && (example.thirdFile !== undefined && example.secondFile === undefined)) {
const _pathTS2 = `src/app/${example.thirdFile}.component.ts`;
this.project.files[_pathTS2] = example.code.default;

}
if (example.module === undefined) {
this.project.files['src/app/app.module.ts'] = `
this.project.files['src/app/app.module.ts'] = `
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
Expand All @@ -212,11 +223,11 @@ export class CodeExampleComponent implements OnInit, AfterViewInit {
import { DragDropModule } from '@angular/cdk/drag-drop';
import {RouterModule, Routes} from '@angular/router'
import { ${this.parameters.app_component} } from './${this.parameters.app_component_basis}';
${this.parameters.app_module_imports}
@NgModule({
declarations: [
${this.parameters.app_component},
${this.parameters.app_component},${this.parameters.app_module_declarationArray}
],
imports: [
BrowserModule,
Expand All @@ -234,14 +245,11 @@ export class CodeExampleComponent implements OnInit, AfterViewInit {
BrowserAnimationsModule
],
providers: [],
entryComponents: [${this.parameters.app_module_entryComponents}],
bootstrap: [${this.parameters.app_component}]
})
export class ${this.parameters.app_module} { }
`;
}
else if (example.language === 'typescript' && example.secondFile === undefined && example.thirdFile === undefined && example.module !== undefined) {
this.project.files['src/app/app.module.ts'] = example.code.default;
}
});

this.project.files['src/index.html'] = `
Expand Down
Expand Up @@ -11,10 +11,11 @@ export interface ExampleFile {
scssFileCode?: {
default: string
};
module?: string;
secondFile?: string;
thirdFile?: string;
component?: string;
fileName?: string;
styleAddon?: string;
entryComponent?: string;
declarationArray?: string;
imports?: string;
}

0 comments on commit 707b82f

Please sign in to comment.