Skip to content

docs(v6): Update v6 StackBlitz set up and examples for JavaScript and Angular #4213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
56e257c
docs(v6): update v6 stackblitz setup for Angular and JS
soundproofboot Jul 18, 2025
c625d4d
docs(v6): update Angular examples for accordion
soundproofboot Jul 21, 2025
b595e1e
docs(v6): update Angular examples for action-sheet
soundproofboot Jul 21, 2025
1170b47
docs(v6): update Angular examples for alert
soundproofboot Jul 21, 2025
fbbde06
docs(v6): update Angular examples for breadcrumbs
soundproofboot Jul 21, 2025
40e55c0
docs(v6): update Angular examples for content
soundproofboot Jul 21, 2025
9c37e15
docs(v6): update Angular examples for datetime
soundproofboot Jul 21, 2025
edf261f
docs(v6): update Angular examples for picker
soundproofboot Jul 21, 2025
e54bffb
docs(v6): update Angular examples for infinite-scroll
soundproofboot Jul 23, 2025
a27f649
docs(v6): update Angular example for icon
soundproofboot Jul 23, 2025
f6bbe3e
docs(v6): update Angular example for input
soundproofboot Jul 23, 2025
067d6aa
docs(v6): update Angular example for item
soundproofboot Jul 23, 2025
09130ff
docs(v6): update Angular examples for item
soundproofboot Jul 23, 2025
9af634d
docs(v6): update Angular example for menu
soundproofboot Jul 23, 2025
710cf89
docs(v6): update Angular examples for modal
soundproofboot Jul 23, 2025
89b3478
docs(v6): update Angular example for nav
soundproofboot Jul 23, 2025
b105668
docs(v6): update Angular examples for popover
soundproofboot Jul 23, 2025
b367f11
docs(v6): update Angular examples for loading
soundproofboot Jul 23, 2025
45666ff
docs(v6): update Angular examples for progress-bar
soundproofboot Jul 23, 2025
107b465
docs(v6): update Angular example for skeleton-text
soundproofboot Jul 23, 2025
47ef967
docs(v6): update Angular examples for range
soundproofboot Jul 23, 2025
dc66afa
docs(v6): update Angular examples for refresher
soundproofboot Jul 23, 2025
7eea39b
docs(v6): update Angular examples for reorder
soundproofboot Jul 23, 2025
1d609aa
docs(v6): update Angular examples for searchbar
soundproofboot Jul 23, 2025
143d9ef
docs(v6): update Angular examples for segment
soundproofboot Jul 23, 2025
34fcc9b
docs(v6): update Angular examples for segment-button
soundproofboot Jul 24, 2025
0501513
docs(v6): update Angular example for segment-button
soundproofboot Jul 24, 2025
626a46f
docs(v6): update Angular examples for select
soundproofboot Jul 24, 2025
d243ff3
docs(v6): update Angular example for router
soundproofboot Jul 24, 2025
2ee2ea9
docs(v6): update Angular examples for toast
soundproofboot Jul 24, 2025
5934210
docs(v6): update Angular examples for toolbar
soundproofboot Jul 25, 2025
28795fb
docs(v6): update Angular example for buttons
soundproofboot Jul 25, 2025
b9b4fd0
docs(v6): update Angular examples for back-button
soundproofboot Jul 25, 2025
f48db54
docs(v6): update Angular example for text
soundproofboot Jul 25, 2025
50c1e6f
docs(v6): revert changes required to build v6 docs locally
soundproofboot Jul 25, 2025
d49391b
docs(v6): run linter
soundproofboot Jul 25, 2025
362e902
docs(v6): update JavaScript example for icon
soundproofboot Jul 28, 2025
3ef6fd8
docs(v6): update JavaScript example for accordion
soundproofboot Jul 28, 2025
c3340ae
docs(v6): update JavaScript example for back-button
soundproofboot Jul 28, 2025
ec26bf2
docs(v6): update JavaScript examples for breadcrumbs
soundproofboot Jul 28, 2025
bf28ee7
docs(v6): update JavaScript example for buttons
soundproofboot Jul 30, 2025
f994a43
docs(v6): update JavaScript examples for item
soundproofboot Jul 30, 2025
1fdbb55
docs(v6): update JavaScript example for refresher
soundproofboot Jul 30, 2025
3f8b81e
docs(v6): update JavaScript example for reorder
soundproofboot Jul 30, 2025
12a2bc4
docs(v6): update JavaScript examples for searchbar
soundproofboot Jul 30, 2025
f28c3c7
docs(v6): update JavaScript examples for segment
soundproofboot Jul 30, 2025
9a04992
docs(v6): update JavaScript examples for segment-button
soundproofboot Jul 30, 2025
7fa5d9d
docs(v6): update JavaScript example for tabs
soundproofboot Jul 30, 2025
f7a8988
docs(v6): update JavaScript examples for text
soundproofboot Jul 30, 2025
7e67fc0
docs(v6): update JavaScript example for toast
soundproofboot Jul 30, 2025
f136105
docs(v6): update JavaScript example for toolbar
soundproofboot Jul 30, 2025
a722c87
revert changes required to build v6 docs locally
soundproofboot Jul 30, 2025
7853751
docs(v6): run linter
soundproofboot Jul 30, 2025
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
2 changes: 1 addition & 1 deletion src/components/global/Playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function Playground({
* The major version of Ionic to use in the generated StackBlitz examples.
* This will also load assets for StackBlitz from the specified version directory.
*/
version: number;
version: string;
}) {
if (!code || Object.keys(code).length === 0) {
console.warn('No code usage examples provided for this Playground example.');
Expand Down
13 changes: 10 additions & 3 deletions src/components/global/Playground/stackblitz.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export interface EditorOptions {
*/
mode?: string;

version?: number;
version?: string;
}

const loadSourceFiles = async (files: string[], version: number) => {
const loadSourceFiles = async (files: string[], version: string) => {
const versionDir = `v${version}`;
const sourceFiles = await Promise.all(files.map((f) => fetch(`/docs/code/stackblitz/${versionDir}/${f}`)));
return await Promise.all(sourceFiles.map((res) => res.text()));
Expand Down Expand Up @@ -155,7 +155,14 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {
...options?.files,
};

files[main] = files[main].replace('provideIonicAngular()', `provideIonicAngular({ mode: '${options?.mode}' })`);
if (options?.version === '6') {
files[main] = files[main].replace(
'importProvidersFrom(IonicModule.forRoot({ }))',
`importProvidersFrom(IonicModule.forRoot({ mode: '${options?.mode}' }))`
);
} else {
files[main] = files[main].replace('provideIonicAngular()', `provideIonicAngular({ mode: '${options?.mode}' })`);
}

sdk.openProject({
template: 'node',
Expand Down
122 changes: 69 additions & 53 deletions static/code/stackblitz/v6/angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,64 @@
"newProjectRoot": "projects",
"projects": {
"app": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"polyfills": [
"src/polyfills.ts"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "assets"
}
],
"styles": ["src/styles.css", "src/global.css", "src/theme/variables.css"],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
},
"ci": {
"progress": false
}
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
Expand All @@ -57,8 +71,15 @@
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"development": {
"browserTarget": "app:build:development"
},
"ci": {
"progress": false
}
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
Expand All @@ -73,46 +94,41 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["src/styles.css"],
"scripts": [],
"assets": ["src/favicon.ico", "src/assets"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
},
"app-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "app:serve"
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "assets"
}
],
"styles": ["src/styles.css", "src/global.css", "src/theme/variables.css"],
"scripts": []
},
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
"ci": {
"progress": false,
"watch": false
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
}
}
}
},
"defaultProject": "app"
"cli": {
"schematicCollections": ["@ionic/angular-toolkit"]
},
"schematics": {
"@angular-eslint/schematics:application": {
"setParserOptionsProject": true
},
"@angular-eslint/schematics:library": {
"setParserOptionsProject": true
}
}
}
4 changes: 3 additions & 1 deletion static/code/stackblitz/v6/angular/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<ion-app>
<app-example class="ion-page"></app-example>
<app-example class="ion-page">
<router-outlet></router-outlet>
</app-example>
</ion-app>
7 changes: 6 additions & 1 deletion static/code/stackblitz/v6/angular/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { RouterOutlet } from '@angular/router';
import { ExampleComponent } from './example.component';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
styleUrls: ['app.component.css'],
imports: [IonicModule, ExampleComponent, RouterOutlet],
standalone: true
})
export class AppComponent { }
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<ion-app>
<ion-content class="ion-padding">
<app-example></app-example>
<app-example>
<router-outlet></router-outlet>
</app-example>
</ion-content>
</ion-app>
15 changes: 15 additions & 0 deletions static/code/stackblitz/v6/angular/app.component.withContent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { RouterOutlet } from '@angular/router';
import { ExampleComponent } from './example.component';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
imports: [IonicModule, ExampleComponent, RouterOutlet],
standalone: true
})
export class AppComponent {
constructor() {}
}
13 changes: 13 additions & 0 deletions static/code/stackblitz/v6/angular/app.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Routes } from '@angular/router';

export const routes: Routes = [
{
path: 'example',
loadComponent: () => import('./example.component').then((m) => m.ExampleComponent),
},
{
path: '',
redirectTo: 'example',
pathMatch: 'full',
},
];
5 changes: 4 additions & 1 deletion static/code/stackblitz/v6/angular/example.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css']
styleUrls: ['example.component.css'],
imports: [IonicModule],
standalone: true
})
export class ExampleComponent { }
16 changes: 16 additions & 0 deletions static/code/stackblitz/v6/angular/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ionic App</title>
</head>

<body>
<app-root>
</app-root>
</body>

</html>
19 changes: 13 additions & 6 deletions static/code/stackblitz/v6/angular/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { bootstrapApplication } from '@angular/platform-browser';
import { RouteReuseStrategy, provideRouter, withPreloading, PreloadAllModules } from '@angular/router';
import { IonicRouteStrategy, IonicModule } from '@ionic/angular';
import { importProvidersFrom } from '@angular/core';
import { routes } from './app/app.routes';
import { AppComponent } from './app/app.component';

import { AppModule } from './app/app.module';

platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch((err: any) => console.error(err));
bootstrapApplication(AppComponent, {
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
importProvidersFrom(IonicModule.forRoot({ })),
provideRouter(routes, withPreloading(PreloadAllModules)),
],
})
26 changes: 25 additions & 1 deletion static/code/stackblitz/v6/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
{
"name": "angular-starter",
"private": true,
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build"
},
"dependencies": {
"@angular/animations": "^15.0.0",
"@angular/common": "^15.0.0",
"@angular/compiler": "^15.0.0",
"@angular/core": "^15.0.0",
"@angular/forms": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/platform-browser-dynamic": "^15.0.0",
"@angular/router": "^15.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0",
"@ionic/angular": "^6.0.0",
"@ionic/core": "^6.0.0",
"@angular/platform-browser-dynamic": "17.3.2"
"ionicons": "8.0.13"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.0.0",
"@angular/cli": "^15.0.0",
"@angular/compiler-cli": "^15.0.0",
"typescript": "~4.9.4"
}
}
9 changes: 9 additions & 0 deletions static/code/stackblitz/v6/angular/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.d.ts"]
}
11 changes: 8 additions & 3 deletions static/code/stackblitz/v6/html/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<html>
<!DOCTYPE html>
<html lang="en">

<head>
<link rel="stylesheet" type="text/css" href="https://cdn.skypack.dev/@ionic/core/css/core.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.skypack.dev/@ionic/core/css/ionic.bundle.css" />
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ionic App</title>
</head>

<body>
<ion-app>
{{ TEMPLATE }}
</ion-app>

<script type="module" src="./index.ts"></script>
</body>

</html>
Loading
Loading