diff --git a/projects/demo/src/environments/environment.prod.ts b/projects/demo/src/environments/environment.prod.ts index 4717a8800c0b..22521b1bdaf8 100644 --- a/projects/demo/src/environments/environment.prod.ts +++ b/projects/demo/src/environments/environment.prod.ts @@ -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', }; diff --git a/projects/demo/src/modules/app/app.component.ts b/projects/demo/src/modules/app/app.component.ts index b550085b2780..e764765bb986 100644 --- a/projects/demo/src/modules/app/app.component.ts +++ b/projects/demo/src/modules/app/app.component.ts @@ -3,6 +3,7 @@ import {Component, DestroyRef, inject, ViewEncapsulation} from '@angular/core'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import {NavigationEnd, Router} from '@angular/router'; import {changeDetection} from '@demo/emulate/change-detection'; +import {environment} from '@demo/environments/environment'; import {DemoRoute} from '@demo/routes'; import {TuiDemo} from '@demo/utils'; import {WA_LOCAL_STORAGE} from '@ng-web-apis/common'; @@ -61,6 +62,7 @@ export class App extends AbstractDemo implements OnInit { protected readonly router = inject(Router); protected readonly storage = inject(WA_LOCAL_STORAGE); protected readonly routes = DemoRoute; + protected readonly playground = environment.playground; protected readonly isLanding$ = this.router.events.pipe( filter((event) => event instanceof NavigationEnd), diff --git a/projects/demo/src/modules/app/app.template.html b/projects/demo/src/modules/app/app.template.html index b5af570a863c..df9f562ee538 100644 --- a/projects/demo/src/modules/app/app.template.html +++ b/projects/demo/src/modules/app/app.template.html @@ -107,10 +107,12 @@
Here you can reproduce any Taiga UI example

-``` diff --git a/projects/demo/src/modules/app/stackblitz/starter/index.ts b/projects/demo/src/modules/app/stackblitz/starter/index.ts index b4c59f03b43d..698a1b2739d7 100644 --- a/projects/demo/src/modules/app/stackblitz/starter/index.ts +++ b/projects/demo/src/modules/app/stackblitz/starter/index.ts @@ -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 { - if (this.isBrowser) { - await this.openStackblitz(); - } - } - - protected async openStackblitz(): Promise { - 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); } }