Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions src/components/global/Playground/stackblitz.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
options?.includeIonContent ? 'html/index.withContent.html' : 'html/index.html',
'html/variables.css',
'html/package.json',
'html/package-lock.json',
'html/tsconfig.json',
'html/vite.config.ts',
],
Expand All @@ -72,11 +73,12 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
const indexHtml = 'index.html';
const files = {
'package.json': JSON.stringify(package_json, null, 2),
'package-lock.json': defaultFiles[4],
'index.ts': defaultFiles[0],
[indexHtml]: defaultFiles[1],
'theme/variables.css': defaultFiles[2],
'tsconfig.json': defaultFiles[4],
'vite.config.ts': defaultFiles[5],
'tsconfig.json': defaultFiles[5],
'vite.config.ts': defaultFiles[6],
...options?.files,
};

Expand Down Expand Up @@ -106,6 +108,7 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {
const defaultFiles = await loadSourceFiles(
[
'angular/package.json',
'angular/package-lock.json',
'angular/angular.json',
'angular/tsconfig.json',
'angular/tsconfig.app.json',
Expand Down Expand Up @@ -136,22 +139,23 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {

const files = {
'package.json': JSON.stringify(package_json, null, 2),
'angular.json': defaultFiles[1],
'tsconfig.json': defaultFiles[2],
'tsconfig.app.json': defaultFiles[3],
[main]: defaultFiles[4],
'src/index.html': defaultFiles[5],
'package-lock.json': defaultFiles[1],
'angular.json': defaultFiles[2],
'tsconfig.json': defaultFiles[3],
'tsconfig.app.json': defaultFiles[4],
[main]: defaultFiles[5],
'src/index.html': defaultFiles[6],
'src/polyfills.ts': `import 'zone.js';`,
'src/app/app.routes.ts': defaultFiles[6],
'src/app/app.component.ts': defaultFiles[7],
'src/app/app.component.css': defaultFiles[8],
'src/app/app.component.html': defaultFiles[9],
'src/app/example.component.ts': defaultFiles[10],
'src/app/app.routes.ts': defaultFiles[7],
'src/app/app.component.ts': defaultFiles[8],
'src/app/app.component.css': defaultFiles[9],
'src/app/app.component.html': defaultFiles[10],
'src/app/example.component.ts': defaultFiles[11],
'src/app/example.component.html': code,
'src/app/example.component.css': '',
'src/styles.css': defaultFiles[11],
'src/global.css': defaultFiles[12],
'src/theme/variables.css': defaultFiles[13],
'src/styles.css': defaultFiles[12],
'src/global.css': defaultFiles[13],
'src/theme/variables.css': defaultFiles[14],
...options?.files,
};

Expand All @@ -173,6 +177,7 @@ const openReactEditor = async (code: string, options?: EditorOptions) => {
'react/variables.css',
'react/tsconfig.json',
'react/package.json',
'react/package-lock.json',
'react/index.html',
'react/vite.config.js',
'react/browserslistrc',
Expand All @@ -192,16 +197,17 @@ const openReactEditor = async (code: string, options?: EditorOptions) => {

const appTsx = 'src/App.tsx';
const files = {
'.eslintrc.js': defaultFiles[8],
'.browserslistrc': defaultFiles[7],
'vite.config.js': defaultFiles[6],
'index.html': defaultFiles[5],
'.eslintrc.js': defaultFiles[9],
'.browserslistrc': defaultFiles[8],
'vite.config.js': defaultFiles[7],
'index.html': defaultFiles[6],
'src/index.tsx': defaultFiles[0],
[appTsx]: defaultFiles[1],
'src/main.tsx': code,
'src/theme/variables.css': defaultFiles[2],
'tsconfig.json': defaultFiles[3],
'package.json': JSON.stringify(package_json, null, 2),
'package-lock.json': defaultFiles[5],
...options?.files,
'.stackblitzrc': `{
"startCommand": "yarn run start"
Expand All @@ -222,6 +228,7 @@ const openVueEditor = async (code: string, options?: EditorOptions) => {
const defaultFiles = await loadSourceFiles(
[
'vue/package.json',
'vue/package-lock.json',
'vue/index.html',
'vue/variables.css',
'vue/vite.config.ts',
Expand All @@ -244,15 +251,16 @@ const openVueEditor = async (code: string, options?: EditorOptions) => {

const mainTs = 'src/main.ts';
const files = {
'src/App.vue': defaultFiles[5],
'src/App.vue': defaultFiles[6],
'src/components/Example.vue': code,
[mainTs]: defaultFiles[4],
'src/theme/variables.css': defaultFiles[2],
'index.html': defaultFiles[1],
'vite.config.ts': defaultFiles[3],
[mainTs]: defaultFiles[5],
'src/theme/variables.css': defaultFiles[3],
'index.html': defaultFiles[2],
'vite.config.ts': defaultFiles[4],
'package.json': JSON.stringify(package_json, null, 2),
'tsconfig.json': defaultFiles[6],
'tsconfig.node.json': defaultFiles[7],
'package-lock.json': defaultFiles[1],
'tsconfig.json': defaultFiles[7],
'tsconfig.node.json': defaultFiles[8],
...options?.files,
'.stackblitzrc': `{
"startCommand": "yarn run dev"
Expand Down
79 changes: 67 additions & 12 deletions static/code/stackblitz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,98 @@

This directory contains the source files for generating the individual framework targets for a playground examples. The contents of the files will be loaded and injected into the StackBlitz example that is opened from the Playground.

## Structure

The files are organized by Ionic version (`v6`, `v7`, `v8`) and framework (`angular`, `html`, `react`, `vue`):

```
stackblitz/
├── v6/
│ ├── angular/
│ ├── html/
│ ├── react/
│ └── vue/
├── v7/
│ ├── angular/
│ ├── html/
│ ├── react/
│ └── vue/
└── v8/
├── angular/
├── html/
├── react/
└── vue/
```

## Angular

| File | Description |
| ------------------ | ------------------------------------------------------ |
| `angular.json` | Main configuration file for any Angular application. |
| `app.component.ts` | Primary component class/entry point. |
| `app.module.ts` | Primary `AppModule`. Specifies required `IonicModule`. |
| `main.ts` | Responsive for bootstrapping the main `AppModule`. |
| `styles.css` | Ionic default styles |
| File | Description |
| -------------------- | ------------------------------------------------------ |
| `angular.json` | Main configuration file for any Angular application. |
| `app.component.css` | App component styles. |
| `app.component.html` | App component template. |
| `app.component.ts` | App component class/entry point. |
| `app.component.withContent.html` | App component template with `ion-content` wrapper. |
| `app.component.withContent.ts` | App component class/entry point with `ion-content` wrapper. |
| `app.routes.ts` | Application routing configuration. |
| `example.component.ts` | Example component for demos. |
| `global.css` | Global styles. |
| `index.html` | Main HTML template. |
| `main.ts` | Responsible for bootstrapping the application. |
| `package.json` | Project dependencies. |
| `package-lock.json` | Locked dependency versions. |
| `styles.css` | Ionic default styles. |
| `tsconfig.app.json` | TypeScript configuration for the app. |
| `tsconfig.json` | TypeScript configuration. |
| `variables.css` | CSS variables for theming. |

## HTML

| File | Description |
| ------------ | ----------------------------------------------------------------- |
| `index.html` | Main template file with CDN link to latest `@ionic/core` release. |
| `index.withContent.html` | Main template with `ion-content` wrapper. |
| `index.ts` | Defines the Stencil hydrated bundle for Ionic. |
| `package.json` | Project dependencies. |
| `package-lock.json` | Locked dependency versions. |
| `tsconfig.json` | TypeScript configuration. |
| `variables.css` | CSS variables for theming. |
| `vite.config.ts` | Vite configuration file. |

## React

| File | Description |
| ---------- | -------------------------------------------------------------------------------------------- |
| `app.tsx` | Imports required Ionic styles and `setupIonicReact()` function to initialize web components. |
| `index.js` | Boilerplate to render a React app. |
| `app.withContent.tsx` | App component with `ion-content` wrapper. |
| `browserslistrc` | Browser support configuration. |
| `eslintrc.js` | ESLint configuration. |
| `index.html` | The HTML template to create an element to mount React to. |
| `index.tsx` | Boilerplate to render a React app. |
| `package.json` | Project dependencies. |
| `package-lock.json` | Locked dependency versions. |
| `tsconfig.json` | TypeScript configuration. |
| `variables.css` | CSS variables for theming. |
| `vite.config.js` | Vite configuration file. |

## Vue

| File | Description |
| ---------------- | ------------------------------------------------------------- |
| `App.vue` | Main Vue component that wraps each example in `ion-app`. |
| `App.withContent.vue` | Main Vue component with `ion-content` wrapper. |
| `index.html` | The HTML template to create an element to mount Vue to. |
| `main.js` | Initializes Ionic Vue and imports global styles. |
| `package.json` | Project specific dependencies to create an example with Vite. |
| `vite.config.js` | Vite configuration file. |
| `main.ts` | Initializes Ionic Vue and imports global styles. |
| `package.json` | Project dependencies. |
| `package-lock.json` | Locked dependency versions. |
| `tsconfig.json` | TypeScript configuration. |
| `tsconfig.node.json` | TypeScript configuration for Node. |
| `variables.css` | CSS variables for theming. |
| `vite.config.ts` | Vite configuration file. |


## Dotfiles

Dotfiles must be saved without the dot otherwise they will not be fetched correctly. However, when creating the StackBlitz project the dot can be used.

For example, if you had an `.eslintrc.js` file you would save it as `eslintrc.js` in this repo. When creating the StackBlitz project the contents of that file can then be saved as `.eslintrc.js`
For example, if you had an `.eslintrc.js` file you would save it as `eslintrc.js` in this repo. When creating the StackBlitz project the contents of that file can then be saved as `.eslintrc.js`.
Loading