Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit dbeede0

Browse files
bdryanovskibbogdanov
authored andcommitted
feat(adoption): provide builder page to create StackBlitz demos
Signed-off-by: Bozhidar Dryanovski <[email protected]>
1 parent 1be6169 commit dbeede0

26 files changed

+685
-131
lines changed

src/app/app-routing.module.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { LandingPage } from './pages/landing.page';
4646
import { OverviewPage } from './pages/overview.page';
4747
import { ApproachesPage } from './pages/approaches.page';
4848
import { DifferencesPage } from './pages/differences.page';
49-
49+
import { TemplateBuilderPage } from './pages/template-builder.page';
5050
export const componentRoutes = [
5151
{ path: 'overview', component: OverviewPage },
5252
{ path: 'accordion', component: AccordionPage },
@@ -88,6 +88,7 @@ export const getStartedRoutes = [
8888
{ path: 'get-started', component: GettingStartedPage },
8989
{ path: 'differences', component: DifferencesPage },
9090
{ path: 'approaches', component: ApproachesPage },
91+
{ path: 'builder', component: TemplateBuilderPage },
9192
];
9293

9394
const routes: Routes = [

src/app/app.module.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import { ApproachesPage } from './pages/approaches.page';
5858
import { MenuTitlePipe } from './pipes/menu-title.pipe';
5959
import { OverviewPage } from './pages/overview.page';
6060
import { DifferencesPage } from './pages/differences.page';
61+
import { TemplateBuilderPage } from './pages/template-builder.page';
62+
import { FormsModule } from '@angular/forms';
6163

6264
@NgModule({
6365
declarations: [
@@ -105,6 +107,8 @@ import { DifferencesPage } from './pages/differences.page';
105107
TooltipPage,
106108
AdoptionToolingPage,
107109

110+
TemplateBuilderPage,
111+
108112
/* Interface Components */
109113
EslintIntroBlockComponent,
110114
SourceCodeComponent,
@@ -114,7 +118,7 @@ import { DifferencesPage } from './pages/differences.page';
114118

115119
MenuTitlePipe,
116120
],
117-
imports: [BrowserModule, BrowserAnimationsModule, CdsModule, AppRoutingModule, ClarityModule],
121+
imports: [BrowserModule, BrowserAnimationsModule, FormsModule, CdsModule, AppRoutingModule, ClarityModule],
118122
providers: [],
119123
bootstrap: [AppComponent],
120124
})

src/app/components/demo.component.ts

+1-31
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,18 @@ import { SupportedTemplates } from '../templates';
1515
// Icons
1616
import {
1717
ClarityIcons,
18-
landscapeIcon,
1918
boltIcon,
20-
terminalIcon,
21-
codeIcon,
22-
betaIcon,
23-
viewColumnsIcon,
2419
} from '@cds/core/icon';
2520

26-
ClarityIcons.addIcons(landscapeIcon, boltIcon, terminalIcon, codeIcon, betaIcon, viewColumnsIcon);
21+
ClarityIcons.addIcons(boltIcon);
2722

2823
export interface DemoTabData {
29-
id?: string;
3024
name: string;
3125
files: { [filename: string]: string };
3226
language?: SourceCodeLanguages;
3327
template: SupportedTemplates;
3428
}
3529

36-
// Generate Preview IDs
37-
let PreviewID = 0;
38-
3930
@Component({
4031
selector: 'demo',
4132
template: `
@@ -60,31 +51,10 @@ let PreviewID = 0;
6051
providers: [StackblitzService],
6152
})
6253
export class Demo {
63-
inOverflow = true;
64-
6554
@Input('tabs') tabs: DemoTabData[] = [];
6655

6756
constructor(private stackblitz: StackblitzService) {}
6857

69-
ngOnInit(): void {
70-
if (Array.isArray(this.tabs)) {
71-
// auto attach unique id for every tab - later used for embedding the preview
72-
this.tabs = this.tabs.map(tab => {
73-
tab.id = this.generateId();
74-
return tab;
75-
});
76-
}
77-
}
78-
79-
/**
80-
* Generate hash key for attaching preview container
81-
*
82-
* @returns number
83-
*/
84-
public generateId(): string {
85-
return PreviewID++ + '';
86-
}
87-
8858
public async openStackblitz(tab: DemoTabData): Promise<void> {
8959
await this.stackblitz.open(tab.template, tab.files);
9060
}

src/app/components/sourcecode.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type SourceCodeLanguages = 'ts' | 'js' | 'html' | 'bash' | 'json' | undef
3030
export class SourceCodeComponent {
3131
@Input() content: string | null = '';
3232
@Input() language: SourceCodeLanguages = 'ts';
33-
@Input() src = '';
33+
@Input() src: string = '' ;
3434
formattedContent = '';
3535

3636
ngOnInit() {

src/app/pages/accordion.page.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { DemoTabData } from '../components/demo.component';
2626
</status-block>
2727
2828
<demo [tabs]="demo1">
29-
<h3 cds-text="section">With expanded, disabled and exapandable panels</h3>
29+
<h3 cds-text="section">With expanded, disabled and expandable panels</h3>
3030
</demo>
3131
`,
3232
})
@@ -37,15 +37,15 @@ export class AccordionPage {
3737
files: {
3838
'src/app/app.component.ts': 'accordion/accordion.1.angular.txt',
3939
},
40-
language: 'ts',
40+
4141
template: 'angular',
4242
},
4343
{
4444
name: 'Core',
4545
files: {
4646
'src/app/app.component.ts': 'accordion/accordion.1.core.txt',
4747
},
48-
language: 'ts',
48+
4949
template: 'core',
5050
},
5151
];

src/app/pages/alert.page.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export class AlertPage {
4242
files: {
4343
'src/app/app.component.ts': 'alert/alert.1.angular.txt',
4444
},
45-
language: 'ts',
45+
4646
template: 'angular',
4747
},
4848
{
4949
name: 'Core',
5050
files: {
5151
'src/app/app.component.ts': 'alert/alert.1.core.txt',
5252
},
53-
language: 'ts',
53+
5454
template: 'core',
5555
},
5656
];
@@ -61,15 +61,15 @@ export class AlertPage {
6161
files: {
6262
'src/app/app.component.ts': 'alert/alert.2.angular.txt',
6363
},
64-
language: 'ts',
64+
6565
template: 'angular',
6666
},
6767
{
6868
name: 'Core',
6969
files: {
7070
'src/app/app.component.ts': 'alert/alert.2.core.txt',
7171
},
72-
language: 'ts',
72+
7373
template: 'core',
7474
},
7575
];
@@ -80,15 +80,15 @@ export class AlertPage {
8080
files: {
8181
'src/app/app.component.ts': 'alert/alert.3.angular.txt',
8282
},
83-
language: 'ts',
83+
8484
template: 'angular',
8585
},
8686
{
8787
name: 'Core',
8888
files: {
8989
'src/app/app.component.ts': 'alert/alert.3.core.txt',
9090
},
91-
language: 'ts',
91+
9292
template: 'core',
9393
},
9494
];

src/app/pages/badge.page.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ export class BadgePage {
3131
files: {
3232
'src/app/app.component.ts': 'badges/badge.1.angular.txt',
3333
},
34-
language: 'ts',
34+
3535
template: 'angular',
3636
},
3737
{
3838
name: 'Core',
3939
files: {
4040
'src/app/app.component.ts': 'badges/badge.1.core.txt',
4141
},
42-
language: 'ts',
42+
4343
template: 'core',
4444
},
4545
];
@@ -50,15 +50,15 @@ export class BadgePage {
5050
files: {
5151
'src/app/app.component.ts': 'badges/badge.2.angular.txt',
5252
},
53-
language: 'ts',
53+
5454
template: 'angular',
5555
},
5656
{
5757
name: 'Core',
5858
files: {
5959
'src/app/app.component.ts': 'badges/badge.2.core.txt',
6060
},
61-
language: 'ts',
61+
6262
template: 'core',
6363
},
6464
];

src/app/pages/button.page.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ export class ButtonPage {
4949
files: {
5050
'src/app/app.component.ts': 'button/button.1.angular.txt',
5151
},
52-
language: 'ts',
52+
5353
template: 'angular',
5454
},
5555
{
5656
name: 'Core',
5757
files: {
5858
'src/app/app.component.ts': 'button/button.1.core.txt',
5959
},
60-
language: 'ts',
60+
6161
template: 'core',
6262
},
6363
];
@@ -68,15 +68,15 @@ export class ButtonPage {
6868
files: {
6969
'src/app/app.component.ts': 'button/button.2.angular.txt',
7070
},
71-
language: 'ts',
71+
7272
template: 'angular',
7373
},
7474
{
7575
name: 'Core',
7676
files: {
7777
'src/app/app.component.ts': 'button/button.2.core.txt',
7878
},
79-
language: 'ts',
79+
8080
template: 'core',
8181
},
8282
];
@@ -87,15 +87,15 @@ export class ButtonPage {
8787
files: {
8888
'src/app/app.component.ts': 'button/button.3.angular.txt',
8989
},
90-
language: 'ts',
90+
9191
template: 'angular',
9292
},
9393
{
9494
name: 'Core',
9595
files: {
9696
'src/app/app.component.ts': 'button/button.3.core.txt',
9797
},
98-
language: 'ts',
98+
9999
template: 'core',
100100
},
101101
];
@@ -106,15 +106,15 @@ export class ButtonPage {
106106
files: {
107107
'src/app/app.component.ts': 'button/button.4.angular.txt',
108108
},
109-
language: 'ts',
109+
110110
template: 'angular',
111111
},
112112
{
113113
name: 'Core',
114114
files: {
115115
'src/app/app.component.ts': 'button/button.4.core.txt',
116116
},
117-
language: 'ts',
117+
118118
template: 'core',
119119
},
120120
];
@@ -125,15 +125,15 @@ export class ButtonPage {
125125
files: {
126126
'src/app/app.component.ts': 'button/button.5.angular.txt',
127127
},
128-
language: 'ts',
128+
129129
template: 'angular',
130130
},
131131
{
132132
name: 'Core',
133133
files: {
134134
'src/app/app.component.ts': 'button/button.5.core.txt',
135135
},
136-
language: 'ts',
136+
137137
template: 'core',
138138
},
139139
];
@@ -144,15 +144,15 @@ export class ButtonPage {
144144
files: {
145145
'src/app/app.component.ts': 'button/button.6.angular.txt',
146146
},
147-
language: 'ts',
147+
148148
template: 'angular',
149149
},
150150
{
151151
name: 'Core',
152152
files: {
153153
'src/app/app.component.ts': 'button/button.6.core.txt',
154154
},
155-
language: 'ts',
155+
156156
template: 'core',
157157
},
158158
];

src/app/pages/card.page.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export class CardPage {
2323
files: {
2424
'src/app/app.component.ts': 'card/card.1.angular.txt',
2525
},
26-
language: 'ts',
26+
2727
template: 'angular',
2828
},
2929
{
3030
name: 'Core',
3131
files: {
3232
'src/app/app.component.ts': 'card/card.1.core.txt',
3333
},
34-
language: 'ts',
34+
3535
template: 'core',
3636
},
3737
];
@@ -42,15 +42,15 @@ export class CardPage {
4242
files: {
4343
'src/app/app.component.ts': 'card/card.2.angular.txt',
4444
},
45-
language: 'ts',
45+
4646
template: 'angular',
4747
},
4848
{
4949
name: 'Core',
5050
files: {
5151
'src/app/app.component.ts': 'card/card.2.core.txt',
5252
},
53-
language: 'ts',
53+
5454
template: 'core',
5555
},
5656
];

0 commit comments

Comments
 (0)