From 69a3aca011cb8e23b124dda2a6ca01e1ff4567b8 Mon Sep 17 00:00:00 2001 From: splincode Date: Wed, 18 Sep 2024 21:54:13 +0300 Subject: [PATCH] chore(demo): add external stackblitz playground --- projects/demo/src/modules/app/app.routes.ts | 5 -- projects/demo/src/modules/app/demo-routes.ts | 3 +- .../stackblitz-edit => edit}/index.less | 0 .../stackblitz-edit => edit}/index.ts | 0 .../app/stackblitz/stackblitz.service.ts | 2 +- .../starter/files/app.component.ts.md | 11 ---- .../starter/files/app.template.html.md | 3 - .../modules/app/stackblitz/starter/index.html | 6 -- .../modules/app/stackblitz/starter/index.less | 8 --- .../modules/app/stackblitz/starter/index.ts | 56 ------------------- 10 files changed, 3 insertions(+), 91 deletions(-) rename projects/demo/src/modules/app/stackblitz/{starter/stackblitz-edit => edit}/index.less (100%) rename projects/demo/src/modules/app/stackblitz/{starter/stackblitz-edit => edit}/index.ts (100%) delete mode 100644 projects/demo/src/modules/app/stackblitz/starter/files/app.component.ts.md delete mode 100644 projects/demo/src/modules/app/stackblitz/starter/files/app.template.html.md delete mode 100644 projects/demo/src/modules/app/stackblitz/starter/index.html delete mode 100644 projects/demo/src/modules/app/stackblitz/starter/index.less delete mode 100644 projects/demo/src/modules/app/stackblitz/starter/index.ts diff --git a/projects/demo/src/modules/app/app.routes.ts b/projects/demo/src/modules/app/app.routes.ts index 592439abb41d8..ada344ec993b4 100644 --- a/projects/demo/src/modules/app/app.routes.ts +++ b/projects/demo/src/modules/app/app.routes.ts @@ -1058,11 +1058,6 @@ export const ROUTES: Routes = [ loadComponent: async () => import('../components/animations'), title: 'Animations', }), - route({ - path: DemoRoute.StackblitzStarter, - loadComponent: async () => import('./stackblitz/starter'), - title: 'Stackblitz Starter', - }), route({ path: DemoRoute.MigrationGuide, loadComponent: async () => import('../info/migration-guide'), diff --git a/projects/demo/src/modules/app/demo-routes.ts b/projects/demo/src/modules/app/demo-routes.ts index 97d819ed51eae..cfec021e3f8d8 100644 --- a/projects/demo/src/modules/app/demo-routes.ts +++ b/projects/demo/src/modules/app/demo-routes.ts @@ -209,6 +209,7 @@ export const DemoRoute = { Tokens: '/utils/tokens', Pure: '/utils/pure', Animations: '/animations', - StackblitzStarter: '/stackblitz', + StackblitzStarter: + 'https://stackblitz.com/~/github.com/taiga-family/taiga-playground', MigrationGuide: '/migration-guide', } as const; diff --git a/projects/demo/src/modules/app/stackblitz/starter/stackblitz-edit/index.less b/projects/demo/src/modules/app/stackblitz/edit/index.less similarity index 100% rename from projects/demo/src/modules/app/stackblitz/starter/stackblitz-edit/index.less rename to projects/demo/src/modules/app/stackblitz/edit/index.less diff --git a/projects/demo/src/modules/app/stackblitz/starter/stackblitz-edit/index.ts b/projects/demo/src/modules/app/stackblitz/edit/index.ts similarity index 100% rename from projects/demo/src/modules/app/stackblitz/starter/stackblitz-edit/index.ts rename to projects/demo/src/modules/app/stackblitz/edit/index.ts diff --git a/projects/demo/src/modules/app/stackblitz/stackblitz.service.ts b/projects/demo/src/modules/app/stackblitz/stackblitz.service.ts index 0b0c1e8786236..92e6e1193937e 100644 --- a/projects/demo/src/modules/app/stackblitz/stackblitz.service.ts +++ b/projects/demo/src/modules/app/stackblitz/stackblitz.service.ts @@ -5,9 +5,9 @@ import type {TuiCodeEditor} from '@taiga-ui/addon-doc'; import {PolymorpheusComponent} from '@taiga-ui/polymorpheus'; import {TsFileComponentParser} from '../classes'; +import {StackblitzEditButton} from './edit'; import {StackblitzDepsService} from './stackblitz-deps.service'; import {AbstractTuiStackblitzResourcesLoader} from './stackblitz-resources-loader'; -import {StackblitzEditButton} from './starter/stackblitz-edit'; import {appPrefix, getSupportFiles, prepareLess, prepareSupportFiles} from './utils'; const APP_COMP_META = { diff --git a/projects/demo/src/modules/app/stackblitz/starter/files/app.component.ts.md b/projects/demo/src/modules/app/stackblitz/starter/files/app.component.ts.md deleted file mode 100644 index f045e4655a737..0000000000000 --- a/projects/demo/src/modules/app/stackblitz/starter/files/app.component.ts.md +++ /dev/null @@ -1,11 +0,0 @@ -```ts -import {Component} from '@angular/core'; - -@Component({ - standalone: true, - selector: 'app', - templateUrl: './app.template.html', - styleUrls: ['./app.style.less'], -}) -export class App {} -``` diff --git a/projects/demo/src/modules/app/stackblitz/starter/files/app.template.html.md b/projects/demo/src/modules/app/stackblitz/starter/files/app.template.html.md deleted file mode 100644 index 089678127766c..0000000000000 --- a/projects/demo/src/modules/app/stackblitz/starter/files/app.template.html.md +++ /dev/null @@ -1,3 +0,0 @@ -```html -

Here you can reproduce any Taiga UI example

-``` diff --git a/projects/demo/src/modules/app/stackblitz/starter/index.html b/projects/demo/src/modules/app/stackblitz/starter/index.html deleted file mode 100644 index 5afa6d01c82ba..0000000000000 --- a/projects/demo/src/modules/app/stackblitz/starter/index.html +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/projects/demo/src/modules/app/stackblitz/starter/index.less b/projects/demo/src/modules/app/stackblitz/starter/index.less deleted file mode 100644 index ee11fc9aefbd6..0000000000000 --- a/projects/demo/src/modules/app/stackblitz/starter/index.less +++ /dev/null @@ -1,8 +0,0 @@ -@import '@taiga-ui/core/styles/taiga-ui-local'; - -.loader { - .fullsize(fixed); - - z-index: 1; - background: var(--tui-background-base); -} diff --git a/projects/demo/src/modules/app/stackblitz/starter/index.ts b/projects/demo/src/modules/app/stackblitz/starter/index.ts deleted file mode 100644 index b4c59f03b43d2..0000000000000 --- a/projects/demo/src/modules/app/stackblitz/starter/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -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 {TuiLoader} from '@taiga-ui/core'; - -import {TuiStackblitzService} from '../stackblitz.service'; -import {appPrefix} from '../utils'; - -@Component({ - standalone: true, - imports: [TuiDemo, 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, - }, - ); - } -}