-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo): add external stackblitz playground (#9084)
- Loading branch information
Showing
9 changed files
with
15 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export const environment = { | ||
production: true, | ||
ym: 87890624, | ||
playground: | ||
'https://stackblitz.com/~/github.com/taiga-family/taiga-playground?file=src/app/app.component.html', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
projects/demo/src/modules/app/stackblitz/starter/files/app.component.ts.md
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
projects/demo/src/modules/app/stackblitz/starter/files/app.template.html.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,17 @@ | ||
import {isPlatformBrowser} from '@angular/common'; | ||
import type {OnInit} from '@angular/core'; | ||
import {ChangeDetectionStrategy, Component, inject, PLATFORM_ID} from '@angular/core'; | ||
import {TuiDemo} from '@demo/utils'; | ||
import {tuiRawLoad, tuiTryParseMarkdownCodeBlock} from '@taiga-ui/addon-doc'; | ||
import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; | ||
import {environment} from '@demo/environments/environment'; | ||
import {WA_WINDOW} from '@ng-web-apis/common'; | ||
import {TuiLoader} from '@taiga-ui/core'; | ||
|
||
import {TuiStackblitzService} from '../stackblitz.service'; | ||
import {appPrefix} from '../utils'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiDemo, TuiLoader], | ||
imports: [TuiLoader], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [TuiStackblitzService], | ||
}) | ||
export default class Page implements OnInit { | ||
private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID)); | ||
private readonly stackblitz = inject(TuiStackblitzService); | ||
|
||
public async ngOnInit(): Promise<void> { | ||
if (this.isBrowser) { | ||
await this.openStackblitz(); | ||
} | ||
} | ||
|
||
protected async openStackblitz(): Promise<void> { | ||
const [appTemplate, appComponent] = await Promise.all( | ||
[ | ||
import('./files/app.template.html.md?raw'), | ||
import('./files/app.component.ts.md?raw'), | ||
].map(tuiRawLoad), | ||
).then((markdowns) => markdowns.map((md) => tuiTryParseMarkdownCodeBlock(md)[0])); | ||
|
||
return this.stackblitz.openStarter( | ||
{ | ||
title: 'Taiga UI Starter', | ||
description: | ||
'A starter with Taiga UI library\nDocumentation: https://taiga-ui.dev', | ||
files: { | ||
[appPrefix`app.template.html`]: appTemplate ?? '', | ||
[appPrefix`app.component.ts`]: appComponent ?? '', | ||
[appPrefix`app.style.less`]: | ||
"@import '@taiga-ui/core/styles/taiga-ui-local.less';", | ||
}, | ||
}, | ||
{ | ||
newWindow: false, | ||
openFile: appPrefix`app.template.html`, | ||
hideExplorer: true, | ||
}, | ||
); | ||
export default class Page { | ||
constructor() { | ||
inject(WA_WINDOW).location.replace(environment.playground); | ||
} | ||
} |