-
Notifications
You must be signed in to change notification settings - Fork 13.3k
feat(angular): add enhanced icon support with addIcons #28009
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4d11d01
chore(angular): generate standalone component wrappers
sean-perkins 155cbc6
chore: manually generate ion-icon standalone proxy
sean-perkins 71e8770
chore: prettier
sean-perkins 5b1c9c6
chore: use v0.8.0
sean-perkins 8e354d1
chore: manually wrap back button and nav
sean-perkins b3ecc3c
test(angular): render ion-app, dedicated button path
sean-perkins 28f2793
test(angular): add icon tests
liamdebeasi b5a21d2
use addIcons
liamdebeasi 68f1277
use simplified icon syntax
liamdebeasi 3560f81
use temp dev build
liamdebeasi fef6475
temp re-add package lock
liamdebeasi 1270390
sync
liamdebeasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/angular/test/base/e2e/src/standalone/icon.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| describe('Icons', () => { | ||
| it('should render an icon', () => { | ||
| cy.visit('/standalone/icon'); | ||
|
|
||
| cy.get('ion-icon#icon-string').shadow().find('svg').should('exist'); | ||
| cy.get('ion-icon#icon-binding').shadow().find('svg').should('exist'); | ||
| }); | ||
|
|
||
| it('should render an icon on iOS mode', () => { | ||
| cy.visit('/standalone/icon?ionic:mode=ios'); | ||
|
|
||
| cy.get('ion-icon#icon-mode').shadow().find('svg').should('exist'); | ||
| }); | ||
|
|
||
| it('should render an icon on MD mode', () => { | ||
| cy.visit('/standalone/icon?ionic:mode=md'); | ||
|
|
||
| cy.get('ion-icon#icon-mode').shadow().find('svg').should('exist'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/angular/test/base/src/app/standalone/icon/icon.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <div> | ||
| Icon Name: <ion-icon id="icon-string" name="logo-ionic"></ion-icon><br /> | ||
| Icon Name Binding: <ion-icon id="icon-binding" [name]="iconName"></ion-icon> <button id="change-icon" (click)="changeIcon()">Change Icon Binding</button><br /> | ||
| iOS/MD: <ion-icon id="icon-mode" ios="logo-apple" md="logo-android"></ion-icon><br /> | ||
| iOS/MD Binding: <ion-icon id="icon-mode-binding" [ios]="iosIcon" [md]="mdIcon"></ion-icon> <button id="change-mode-icon" (click)="changeModeIcon()">Change Icon Binding</button><br /> | ||
| </div> |
27 changes: 27 additions & 0 deletions
27
packages/angular/test/base/src/app/standalone/icon/icon.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { IonIcon } from '@ionic/angular/standalone'; | ||
| import { logoIonic, logoIonitron, logoApple, logoAndroid } from 'ionicons/icons'; | ||
| import { addIcons } from 'ionicons'; | ||
|
|
||
| addIcons({ logoIonic, logoIonitron, logoApple, logoAndroid }); | ||
|
|
||
| @Component({ | ||
| selector: 'app-icon', | ||
| templateUrl: './icon.component.html', | ||
| standalone: true, | ||
| imports: [IonIcon], | ||
| }) | ||
| export class IconComponent { | ||
| iconName: string = 'logo-ionic'; | ||
| iosIcon: string = 'logo-apple'; | ||
| mdIcon: string = 'logo-android'; | ||
|
|
||
| changeIcon() { | ||
| this.iconName = this.iconName === 'logo-ionic' ? 'logo-apple' : 'logo-ionic'; | ||
| } | ||
|
|
||
| changeModeIcon() { | ||
| this.iosIcon = this.iosIcon === 'logo-apple' ? 'logo-ionic' : 'logo-apple'; | ||
| this.mdIcon = this.mdIcon === 'logo-android' ? 'logo-ionitron' : 'logo-android'; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Played with this locally, everything looks/works good 👍
It seems to work consistently if you have this outside the class or within the constructor. Does not work (too late in the execution cycle, after
connectedCallbackfires) if you try to add icons in thengOnInitlifecycle.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! We'll want to note this in the docs