Skip to content

Commit c07312e

Browse files
authored
fix(angular): ng add @ionic/angular in standalone projects (#28523)
Issue number: Resolves #28514 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> When using the `@ionic/angular` schematic in an Angular 17 project (`ng add @ionic/angular`), developers will receive an error preventing the schematic from running. Additionally, the previous implementations of the schematic are out of sync with the current state of the Ionic starters: - `variables.css` is empty and missing Ionic's defaults - `ionic.config.json` is not created - Schematic does not have support for module vs. standalone projects. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `ng add @ionic/angular` works with Angular 17 projects - `ng add @ionic/angular` has fallback behavior for Angular 16 projects using `AppModule` - Schematics now includes the proper `variables.css` from Ionic starters - Ionicons assets will no longer be copied when being added to a standalone project - Refactors a majority of the implementation to use the utilities that come directly from `@angular-devkit/schematics` and `@schematics/angular`. - Sets the `@ionic/angular-toolkit` CLI configuration and schematics configuration in the `angular.json` - Creates missing `ionic.config.json` ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev-build: `7.5.5-dev.11700239837.1925bbdb` To test this PR: 1. Install Angular CLI v17 - `npm install -g @angular/cli@17` 2. Create a new project - `ng new angular-17` 3. Use the dev-build: - `ng add @ionic/[email protected]` 4. Confirm the prompts 5. Validate that `provideIonicAngular({})` is added to the `app.config.ts` 6. Validate that `ionic.config.json` was created 7. Validate that `angular.json` was updated with the `@ionic/angular-devkit` configurations Now verify legacy behavior: 1. Install Angular CLI v16 - `npm install -g @angular/cli@16` 2. Create a new project - `ng new angular-16` 3. Use the dev-build - `ng add @ionic/[email protected]` 4. Confirm the prompts 5. Validate that `IonicModule.forRoot({})` is added to the `app.module.ts` 8. Validate the ionicons glob pattern is added to the `angular.json` 9. Validate the `ionic.config.json` was created 10. Validate the `angular.json` was updated with the `@ionic/angular-devkit` configurations
1 parent 388d19e commit c07312e

File tree

10 files changed

+3230
-1042
lines changed

10 files changed

+3230
-1042
lines changed

packages/angular/package-lock.json

Lines changed: 2812 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/angular/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@
6161
"zone.js": ">=0.11.0"
6262
},
6363
"devDependencies": {
64-
"@angular-devkit/core": "^14.0.0",
65-
"@angular-devkit/schematics": "^14.0.0",
64+
"@angular-devkit/core": "^17.0.0",
65+
"@angular-devkit/schematics": "^17.0.0",
6666
"@angular-eslint/eslint-plugin": "^14.0.0",
6767
"@angular-eslint/eslint-plugin-template": "^14.0.0",
6868
"@angular-eslint/template-parser": "^14.0.0",
69+
"@angular/cli": "^14.0.0",
6970
"@angular/common": "^14.0.0",
7071
"@angular/compiler": "^14.0.0",
7172
"@angular/compiler-cli": "^14.0.0",
@@ -76,7 +77,7 @@
7677
"@angular/router": "^14.0.0",
7778
"@ionic/eslint-config": "^0.3.0",
7879
"@ionic/prettier-config": "^2.0.0",
79-
"@schematics/angular": "^14.0.0",
80+
"@schematics/angular": "^17.0.0",
8081
"@types/node": "12.12.5",
8182
"@typescript-eslint/eslint-plugin": "^5.0.0",
8283
"@typescript-eslint/parser": "^5.0.0",

packages/angular/src/schematics/add/files/root/theme/variables.css

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,244 @@
44

55
/* To quickly generate your own theme, check out the color generator */
66
/* https://ionicframework.com/docs/theming/color-generator */
7+
8+
/** Ionic CSS Variables **/
9+
:root {
10+
/** primary **/
11+
--ion-color-primary: #3880ff;
12+
--ion-color-primary-rgb: 56, 128, 255;
13+
--ion-color-primary-contrast: #ffffff;
14+
--ion-color-primary-contrast-rgb: 255, 255, 255;
15+
--ion-color-primary-shade: #3171e0;
16+
--ion-color-primary-tint: #4c8dff;
17+
18+
/** secondary **/
19+
--ion-color-secondary: #3dc2ff;
20+
--ion-color-secondary-rgb: 61, 194, 255;
21+
--ion-color-secondary-contrast: #ffffff;
22+
--ion-color-secondary-contrast-rgb: 255, 255, 255;
23+
--ion-color-secondary-shade: #36abe0;
24+
--ion-color-secondary-tint: #50c8ff;
25+
26+
/** tertiary **/
27+
--ion-color-tertiary: #5260ff;
28+
--ion-color-tertiary-rgb: 82, 96, 255;
29+
--ion-color-tertiary-contrast: #ffffff;
30+
--ion-color-tertiary-contrast-rgb: 255, 255, 255;
31+
--ion-color-tertiary-shade: #4854e0;
32+
--ion-color-tertiary-tint: #6370ff;
33+
34+
/** success **/
35+
--ion-color-success: #2dd36f;
36+
--ion-color-success-rgb: 45, 211, 111;
37+
--ion-color-success-contrast: #ffffff;
38+
--ion-color-success-contrast-rgb: 255, 255, 255;
39+
--ion-color-success-shade: #28ba62;
40+
--ion-color-success-tint: #42d77d;
41+
42+
/** warning **/
43+
--ion-color-warning: #ffc409;
44+
--ion-color-warning-rgb: 255, 196, 9;
45+
--ion-color-warning-contrast: #000000;
46+
--ion-color-warning-contrast-rgb: 0, 0, 0;
47+
--ion-color-warning-shade: #e0ac08;
48+
--ion-color-warning-tint: #ffca22;
49+
50+
/** danger **/
51+
--ion-color-danger: #eb445a;
52+
--ion-color-danger-rgb: 235, 68, 90;
53+
--ion-color-danger-contrast: #ffffff;
54+
--ion-color-danger-contrast-rgb: 255, 255, 255;
55+
--ion-color-danger-shade: #cf3c4f;
56+
--ion-color-danger-tint: #ed576b;
57+
58+
/** dark **/
59+
--ion-color-dark: #222428;
60+
--ion-color-dark-rgb: 34, 36, 40;
61+
--ion-color-dark-contrast: #ffffff;
62+
--ion-color-dark-contrast-rgb: 255, 255, 255;
63+
--ion-color-dark-shade: #1e2023;
64+
--ion-color-dark-tint: #383a3e;
65+
66+
/** medium **/
67+
--ion-color-medium: #92949c;
68+
--ion-color-medium-rgb: 146, 148, 156;
69+
--ion-color-medium-contrast: #ffffff;
70+
--ion-color-medium-contrast-rgb: 255, 255, 255;
71+
--ion-color-medium-shade: #808289;
72+
--ion-color-medium-tint: #9d9fa6;
73+
74+
/** light **/
75+
--ion-color-light: #f4f5f8;
76+
--ion-color-light-rgb: 244, 245, 248;
77+
--ion-color-light-contrast: #000000;
78+
--ion-color-light-contrast-rgb: 0, 0, 0;
79+
--ion-color-light-shade: #d7d8da;
80+
--ion-color-light-tint: #f5f6f9;
81+
}
82+
83+
@media (prefers-color-scheme: dark) {
84+
/*
85+
* Dark Colors
86+
* -------------------------------------------
87+
*/
88+
89+
body {
90+
--ion-color-primary: #428cff;
91+
--ion-color-primary-rgb: 66, 140, 255;
92+
--ion-color-primary-contrast: #ffffff;
93+
--ion-color-primary-contrast-rgb: 255, 255, 255;
94+
--ion-color-primary-shade: #3a7be0;
95+
--ion-color-primary-tint: #5598ff;
96+
97+
--ion-color-secondary: #50c8ff;
98+
--ion-color-secondary-rgb: 80, 200, 255;
99+
--ion-color-secondary-contrast: #ffffff;
100+
--ion-color-secondary-contrast-rgb: 255, 255, 255;
101+
--ion-color-secondary-shade: #46b0e0;
102+
--ion-color-secondary-tint: #62ceff;
103+
104+
--ion-color-tertiary: #6a64ff;
105+
--ion-color-tertiary-rgb: 106, 100, 255;
106+
--ion-color-tertiary-contrast: #ffffff;
107+
--ion-color-tertiary-contrast-rgb: 255, 255, 255;
108+
--ion-color-tertiary-shade: #5d58e0;
109+
--ion-color-tertiary-tint: #7974ff;
110+
111+
--ion-color-success: #2fdf75;
112+
--ion-color-success-rgb: 47, 223, 117;
113+
--ion-color-success-contrast: #000000;
114+
--ion-color-success-contrast-rgb: 0, 0, 0;
115+
--ion-color-success-shade: #29c467;
116+
--ion-color-success-tint: #44e283;
117+
118+
--ion-color-warning: #ffd534;
119+
--ion-color-warning-rgb: 255, 213, 52;
120+
--ion-color-warning-contrast: #000000;
121+
--ion-color-warning-contrast-rgb: 0, 0, 0;
122+
--ion-color-warning-shade: #e0bb2e;
123+
--ion-color-warning-tint: #ffd948;
124+
125+
--ion-color-danger: #ff4961;
126+
--ion-color-danger-rgb: 255, 73, 97;
127+
--ion-color-danger-contrast: #ffffff;
128+
--ion-color-danger-contrast-rgb: 255, 255, 255;
129+
--ion-color-danger-shade: #e04055;
130+
--ion-color-danger-tint: #ff5b71;
131+
132+
--ion-color-dark: #f4f5f8;
133+
--ion-color-dark-rgb: 244, 245, 248;
134+
--ion-color-dark-contrast: #000000;
135+
--ion-color-dark-contrast-rgb: 0, 0, 0;
136+
--ion-color-dark-shade: #d7d8da;
137+
--ion-color-dark-tint: #f5f6f9;
138+
139+
--ion-color-medium: #989aa2;
140+
--ion-color-medium-rgb: 152, 154, 162;
141+
--ion-color-medium-contrast: #000000;
142+
--ion-color-medium-contrast-rgb: 0, 0, 0;
143+
--ion-color-medium-shade: #86888f;
144+
--ion-color-medium-tint: #a2a4ab;
145+
146+
--ion-color-light: #222428;
147+
--ion-color-light-rgb: 34, 36, 40;
148+
--ion-color-light-contrast: #ffffff;
149+
--ion-color-light-contrast-rgb: 255, 255, 255;
150+
--ion-color-light-shade: #1e2023;
151+
--ion-color-light-tint: #383a3e;
152+
}
153+
154+
/*
155+
* iOS Dark Theme
156+
* -------------------------------------------
157+
*/
158+
159+
.ios body {
160+
--ion-background-color: #000000;
161+
--ion-background-color-rgb: 0, 0, 0;
162+
163+
--ion-text-color: #ffffff;
164+
--ion-text-color-rgb: 255, 255, 255;
165+
166+
--ion-color-step-50: #0d0d0d;
167+
--ion-color-step-100: #1a1a1a;
168+
--ion-color-step-150: #262626;
169+
--ion-color-step-200: #333333;
170+
--ion-color-step-250: #404040;
171+
--ion-color-step-300: #4d4d4d;
172+
--ion-color-step-350: #595959;
173+
--ion-color-step-400: #666666;
174+
--ion-color-step-450: #737373;
175+
--ion-color-step-500: #808080;
176+
--ion-color-step-550: #8c8c8c;
177+
--ion-color-step-600: #999999;
178+
--ion-color-step-650: #a6a6a6;
179+
--ion-color-step-700: #b3b3b3;
180+
--ion-color-step-750: #bfbfbf;
181+
--ion-color-step-800: #cccccc;
182+
--ion-color-step-850: #d9d9d9;
183+
--ion-color-step-900: #e6e6e6;
184+
--ion-color-step-950: #f2f2f2;
185+
186+
--ion-item-background: #000000;
187+
188+
--ion-card-background: #1c1c1d;
189+
}
190+
191+
.ios ion-modal {
192+
--ion-background-color: var(--ion-color-step-100);
193+
--ion-toolbar-background: var(--ion-color-step-150);
194+
--ion-toolbar-border-color: var(--ion-color-step-250);
195+
}
196+
197+
/*
198+
* Material Design Dark Theme
199+
* -------------------------------------------
200+
*/
201+
202+
.md body {
203+
--ion-background-color: #121212;
204+
--ion-background-color-rgb: 18, 18, 18;
205+
206+
--ion-text-color: #ffffff;
207+
--ion-text-color-rgb: 255, 255, 255;
208+
209+
--ion-border-color: #222222;
210+
211+
--ion-color-step-50: #1e1e1e;
212+
--ion-color-step-100: #2a2a2a;
213+
--ion-color-step-150: #363636;
214+
--ion-color-step-200: #414141;
215+
--ion-color-step-250: #4d4d4d;
216+
--ion-color-step-300: #595959;
217+
--ion-color-step-350: #656565;
218+
--ion-color-step-400: #717171;
219+
--ion-color-step-450: #7d7d7d;
220+
--ion-color-step-500: #898989;
221+
--ion-color-step-550: #949494;
222+
--ion-color-step-600: #a0a0a0;
223+
--ion-color-step-650: #acacac;
224+
--ion-color-step-700: #b8b8b8;
225+
--ion-color-step-750: #c4c4c4;
226+
--ion-color-step-800: #d0d0d0;
227+
--ion-color-step-850: #dbdbdb;
228+
--ion-color-step-900: #e7e7e7;
229+
--ion-color-step-950: #f3f3f3;
230+
231+
--ion-item-background: #1e1e1e;
232+
233+
--ion-toolbar-background: #1f1f1f;
234+
235+
--ion-tab-bar-background: #1f1f1f;
236+
237+
--ion-card-background: #1e1e1e;
238+
}
239+
}
240+
241+
html {
242+
/*
243+
* For more information on dynamic font scaling, visit the documentation:
244+
* https://ionicframework.com/docs/layout/dynamic-font-scaling
245+
*/
246+
--ion-dynamic-font: var(--ion-default-dynamic-font);
247+
}

0 commit comments

Comments
 (0)