Skip to content

Commit bfc8452

Browse files
docs(angular): update playgrounds to standalone and StackBlitz previews to use WebContainers (#3905)
1 parent e465294 commit bfc8452

File tree

1,867 files changed

+16060
-2951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,867 files changed

+16060
-2951
lines changed

docs/api/infinite-scroll.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ The Infinite Scroll component calls an action to be performed when the user scro
2121

2222
The expression assigned to the `ionInfinite` event is called when the user reaches that defined distance. When this expression has finished any and all tasks, it should call the `complete()` method on the infinite scroll instance.
2323

24+
## Basic Usage
25+
2426
import Basic from '@site/static/usage/v8/infinite-scroll/basic/index.md';
2527

2628
<Basic />
@@ -118,4 +120,4 @@ interface InfiniteScrollCustomEvent extends CustomEvent {
118120
<CustomProps />
119121

120122
## Slots
121-
<Slots />
123+
<Slots />

docs/api/reorder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ In order to sort the array upon completion of the reorder, the array should be p
6767

6868
In some cases, it may be necessary for an app to reorder both the array and the DOM nodes on its own. If this is required, `false` should be passed as a parameter to the `complete` method. This will prevent Ionic from reordering any DOM nodes inside of the reorder group.
6969

70-
Regardless of the approach taken, a stable identity should be provided to reorder items if provided in a loop. This means using `trackBy` for Angular, and `key` for React and Vue.
70+
Regardless of the approach taken, a stable identity should be provided to reorder items if provided in a loop. This means using `track` for Angular, and `key` for React and Vue.
7171

7272
import UpdatingData from '@site/static/usage/v8/reorder/updating-data/index.md';
7373

src/components/global/Playground/stackblitz.utils.ts

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -105,67 +105,63 @@ const openHtmlEditor = async (code: string, options?: EditorOptions) => {
105105
const openAngularEditor = async (code: string, options?: EditorOptions) => {
106106
const defaultFiles = await loadSourceFiles(
107107
[
108+
'angular/package.json',
109+
'angular/angular.json',
110+
'angular/tsconfig.json',
111+
'angular/tsconfig.app.json',
108112
'angular/main.ts',
109-
'angular/app.module.ts',
110-
'angular/app.component.ts',
113+
'angular/index.html',
114+
'angular/app.routes.ts',
115+
options?.includeIonContent ? 'angular/app.component.withContent.ts' : 'angular/app.component.ts',
111116
'angular/app.component.css',
112117
options?.includeIonContent ? 'angular/app.component.withContent.html' : 'angular/app.component.html',
113118
'angular/example.component.ts',
114119
'angular/styles.css',
115120
'angular/global.css',
116121
'angular/variables.css',
117-
'angular/angular.json',
118-
'angular/tsconfig.json',
119-
'angular/package.json',
120122
],
121123
options.version
122124
);
123125

124-
const appModule = 'src/app/app.module.ts';
126+
const package_json = JSON.parse(defaultFiles[0]);
127+
128+
if (options?.dependencies) {
129+
package_json.dependencies = {
130+
...package_json.dependencies,
131+
...options.dependencies,
132+
};
133+
}
134+
135+
const main = 'src/main.ts';
136+
125137
const files = {
126-
'src/main.ts': defaultFiles[0],
138+
'package.json': JSON.stringify(package_json, null, 2),
139+
'angular.json': defaultFiles[1],
140+
'tsconfig.json': defaultFiles[2],
141+
'tsconfig.app.json': defaultFiles[3],
142+
[main]: defaultFiles[4],
143+
'src/index.html': defaultFiles[5],
127144
'src/polyfills.ts': `import 'zone.js';`,
128-
[appModule]: defaultFiles[1],
129-
'src/app/app.component.ts': defaultFiles[2],
130-
'src/app/app.component.css': defaultFiles[3],
131-
'src/app/app.component.html': defaultFiles[4],
132-
'src/app/example.component.ts': defaultFiles[5],
145+
'src/app/app.routes.ts': defaultFiles[6],
146+
'src/app/app.component.ts': defaultFiles[7],
147+
'src/app/app.component.css': defaultFiles[8],
148+
'src/app/app.component.html': defaultFiles[9],
149+
'src/app/example.component.ts': defaultFiles[10],
133150
'src/app/example.component.html': code,
134151
'src/app/example.component.css': '',
135-
'src/index.html': '<app-root></app-root>',
136-
'src/styles.css': defaultFiles[6],
137-
'src/global.css': defaultFiles[7],
138-
'src/theme/variables.css': defaultFiles[8],
139-
'angular.json': defaultFiles[9],
140-
'tsconfig.json': defaultFiles[10],
152+
'src/styles.css': defaultFiles[11],
153+
'src/global.css': defaultFiles[12],
154+
'src/theme/variables.css': defaultFiles[13],
141155
...options?.files,
142-
...options?.dependencies,
143156
};
144157

145-
const package_json = defaultFiles[11];
146-
147-
files[appModule] = files[appModule].replace(
148-
'IonicModule.forRoot({})',
149-
`IonicModule.forRoot({ mode: '${options?.mode}' })`
150-
);
151-
152-
let dependencies = {};
153-
try {
154-
dependencies = {
155-
...dependencies,
156-
...JSON.parse(package_json).dependencies,
157-
...options?.dependencies,
158-
};
159-
} catch (e) {
160-
console.error('Failed to parse package.json contents', e);
161-
}
158+
files[main] = files[main].replace('provideIonicAngular()', `provideIonicAngular({ mode: '${options?.mode}' })`);
162159

163160
sdk.openProject({
164-
template: 'angular-cli',
161+
template: 'node',
165162
title: options?.title ?? DEFAULT_EDITOR_TITLE,
166163
description: options?.description ?? DEFAULT_EDITOR_DESCRIPTION,
167164
files,
168-
dependencies,
169165
});
170166
};
171167

static/code/stackblitz/v7/angular/angular.json

Lines changed: 79 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,130 @@
44
"newProjectRoot": "projects",
55
"projects": {
66
"app": {
7+
"projectType": "application",
78
"root": "",
89
"sourceRoot": "src",
9-
"projectType": "application",
1010
"prefix": "app",
11-
"schematics": {},
1211
"architect": {
1312
"build": {
14-
"builder": "@angular-devkit/build-angular:browser",
13+
"builder": "@angular-devkit/build-angular:application",
1514
"options": {
16-
"outputPath": "dist",
15+
"outputPath": {
16+
"base": "www"
17+
},
1718
"index": "src/index.html",
18-
"main": "src/main.ts",
19-
"polyfills": "src/polyfills.ts",
20-
"tsConfig": "src/tsconfig.app.json",
21-
"assets": ["src/favicon.ico", "src/assets"],
19+
"polyfills": [
20+
"src/polyfills.ts"
21+
],
22+
"tsConfig": "tsconfig.app.json",
23+
"assets": [
24+
{
25+
"glob": "**/*",
26+
"input": "src/assets",
27+
"output": "assets"
28+
}
29+
],
2230
"styles": ["src/styles.css", "src/global.css", "src/theme/variables.css"],
23-
"scripts": []
31+
"scripts": [],
32+
"browser": "src/main.ts"
2433
},
2534
"configurations": {
2635
"production": {
27-
"fileReplacements": [
28-
{
29-
"replace": "src/environments/environment.ts",
30-
"with": "src/environments/environment.prod.ts"
31-
}
32-
],
33-
"optimization": true,
34-
"outputHashing": "all",
35-
"sourceMap": false,
36-
"extractCss": true,
37-
"namedChunks": false,
38-
"aot": true,
39-
"extractLicenses": true,
40-
"vendorChunk": false,
41-
"buildOptimizer": true,
4236
"budgets": [
4337
{
4438
"type": "initial",
4539
"maximumWarning": "2mb",
4640
"maximumError": "5mb"
41+
},
42+
{
43+
"type": "anyComponentStyle",
44+
"maximumWarning": "2kb",
45+
"maximumError": "4kb"
4746
}
48-
]
47+
],
48+
"fileReplacements": [
49+
{
50+
"replace": "src/environments/environment.ts",
51+
"with": "src/environments/environment.prod.ts"
52+
}
53+
],
54+
"outputHashing": "all"
55+
},
56+
"development": {
57+
"optimization": false,
58+
"extractLicenses": false,
59+
"sourceMap": true,
60+
"namedChunks": true
61+
},
62+
"ci": {
63+
"progress": false
4964
}
50-
}
65+
},
66+
"defaultConfiguration": "production"
5167
},
5268
"serve": {
5369
"builder": "@angular-devkit/build-angular:dev-server",
54-
"options": {
55-
"browserTarget": "app:build"
56-
},
5770
"configurations": {
5871
"production": {
59-
"browserTarget": "app:build:production"
72+
"buildTarget": "app:build:production"
73+
},
74+
"development": {
75+
"buildTarget": "app:build:development"
76+
},
77+
"ci": {
78+
"progress": false
6079
}
61-
}
80+
},
81+
"defaultConfiguration": "development"
6282
},
6383
"extract-i18n": {
6484
"builder": "@angular-devkit/build-angular:extract-i18n",
6585
"options": {
66-
"browserTarget": "app:build"
86+
"buildTarget": "app:build"
6787
}
6888
},
6989
"test": {
7090
"builder": "@angular-devkit/build-angular:karma",
7191
"options": {
7292
"main": "src/test.ts",
7393
"polyfills": "src/polyfills.ts",
74-
"tsConfig": "src/tsconfig.spec.json",
75-
"karmaConfig": "src/karma.conf.js",
76-
"styles": ["src/styles.css"],
77-
"scripts": [],
78-
"assets": ["src/favicon.ico", "src/assets"]
79-
}
80-
},
81-
"lint": {
82-
"builder": "@angular-devkit/build-angular:tslint",
83-
"options": {
84-
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
85-
"exclude": ["**/node_modules/**"]
86-
}
87-
}
88-
}
89-
},
90-
"app-e2e": {
91-
"root": "e2e/",
92-
"projectType": "application",
93-
"prefix": "",
94-
"architect": {
95-
"e2e": {
96-
"builder": "@angular-devkit/build-angular:protractor",
97-
"options": {
98-
"protractorConfig": "e2e/protractor.conf.js",
99-
"devServerTarget": "app:serve"
94+
"tsConfig": "tsconfig.spec.json",
95+
"karmaConfig": "karma.conf.js",
96+
"assets": [
97+
{
98+
"glob": "**/*",
99+
"input": "src/assets",
100+
"output": "assets"
101+
}
102+
],
103+
"styles": ["src/styles.css", "src/global.css", "src/theme/variables.css"],
104+
"scripts": []
100105
},
101106
"configurations": {
102-
"production": {
103-
"devServerTarget": "app:serve:production"
107+
"ci": {
108+
"progress": false,
109+
"watch": false
104110
}
105111
}
106112
},
107113
"lint": {
108-
"builder": "@angular-devkit/build-angular:tslint",
114+
"builder": "@angular-eslint/builder:lint",
109115
"options": {
110-
"tsConfig": "e2e/tsconfig.e2e.json",
111-
"exclude": ["**/node_modules/**"]
116+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
112117
}
113118
}
114119
}
115120
}
116121
},
117-
"defaultProject": "app"
122+
"cli": {
123+
"schematicCollections": ["@ionic/angular-toolkit"]
124+
},
125+
"schematics": {
126+
"@angular-eslint/schematics:application": {
127+
"setParserOptionsProject": true
128+
},
129+
"@angular-eslint/schematics:library": {
130+
"setParserOptionsProject": true
131+
}
132+
}
118133
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { Component } from '@angular/core';
2+
import { IonApp } from '@ionic/angular/standalone';
3+
import { ExampleComponent } from './example.component';
24

35
@Component({
46
selector: 'app-root',
57
templateUrl: 'app.component.html',
6-
styleUrls: ['app.component.css']
8+
styleUrls: ['app.component.css'],
9+
imports: [ExampleComponent, IonApp],
710
})
8-
export class AppComponent { }
11+
export class AppComponent {
12+
constructor() {}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component } from '@angular/core';
2+
import { IonApp, IonContent } from '@ionic/angular/standalone';
3+
import { ExampleComponent } from './example.component';
4+
5+
@Component({
6+
selector: 'app-root',
7+
templateUrl: 'app.component.html',
8+
styleUrls: ['app.component.css'],
9+
imports: [ExampleComponent, IonApp, IonContent],
10+
})
11+
export class AppComponent {
12+
constructor() {}
13+
}

static/code/stackblitz/v7/angular/app.module.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Routes } from '@angular/router';
2+
3+
export const routes: Routes = [
4+
{
5+
path: 'example',
6+
loadComponent: () => import('./example.component').then((m) => m.ExampleComponent),
7+
},
8+
{
9+
path: '',
10+
redirectTo: 'example',
11+
pathMatch: 'full',
12+
},
13+
];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="icon" href="/favicon.ico" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Ionic App</title>
9+
</head>
10+
11+
<body>
12+
<app-root></app-root>
13+
</body>
14+
15+
</html>

0 commit comments

Comments
 (0)