Skip to content

Commit ad5e3bd

Browse files
authored
Merge branch 'main' into icon-binocs
2 parents e0b16f5 + 116d250 commit ad5e3bd

File tree

12 files changed

+125
-34
lines changed

12 files changed

+125
-34
lines changed

.github/workflows/actions/publish-npm/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
steps:
1818
- uses: actions/setup-node@v3
1919
with:
20-
node-version: 16.x
20+
node-version: 18.x
2121
- name: Install latest npm
2222
run: npm install -g npm@latest
2323
shell: bash

.github/workflows/release.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ jobs:
4545
git config user.name ionitron
4646
git config user.email [email protected]
4747
shell: bash
48+
# This ensures the local version of Lerna is installed
49+
# and that we do not use the global Lerna version
50+
- name: Install root dependencies
51+
run: npm ci
52+
shell: bash
4853
- name: Create GitHub Release
49-
run: lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github
54+
run: npx lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github
5055
env:
5156
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5257
shell: bash
@@ -55,7 +60,7 @@ jobs:
5560
# so we do that here.
5661
- name: Bump Package Lock
5762
run: |
58-
lerna exec "npm install --package-lock-only --legacy-peer-deps"
63+
npx lerna exec "npm install --package-lock-only --legacy-peer-deps"
5964
git add .
6065
git commit -m "chore(): update package lock files"
6166
git push

CHANGELOG.md

+40
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,46 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [7.2.2](https://github.com/ionic-team/ionicons/compare/v7.2.1...v7.2.2) (2023-12-13)
7+
8+
9+
### Bug Fixes
10+
11+
* **icon:** add better warning when loading icons ([#1297](https://github.com/ionic-team/ionicons/issues/1297)) ([d582e62](https://github.com/ionic-team/ionicons/commit/d582e6208e626722e4350426a509a6870e90a0bc))
12+
13+
14+
15+
16+
17+
## [7.2.1](https://github.com/ionic-team/ionicons/compare/v7.2.0...v7.2.1) (2023-10-10)
18+
19+
20+
### Bug Fixes
21+
22+
* **icon:** font scales without host style ([#1289](https://github.com/ionic-team/ionicons/issues/1289)) ([875bfd8](https://github.com/ionic-team/ionicons/commit/875bfd8300144c62e55a5a76dc2cff8cf1f01bfe))
23+
24+
25+
26+
27+
28+
# [7.2.0](https://github.com/ionic-team/ionicons/compare/v7.1.2...v7.2.0) (2023-10-10)
29+
30+
31+
### Bug Fixes
32+
33+
* **icon:** mapping same icon does not warn ([#1279](https://github.com/ionic-team/ionicons/issues/1279)) ([8297018](https://github.com/ionic-team/ionicons/commit/8297018cb591f5e33a815ceb9e4e765271ecf5ad))
34+
* **icon:** verify the icon loads in the lifecycle ([#1278](https://github.com/ionic-team/ionicons/issues/1278)) ([7f7f346](https://github.com/ionic-team/ionicons/commit/7f7f346af47f45531046e1d2f1a88f53acee77fa))
35+
36+
37+
### Features
38+
39+
* allow passing in only icon SVG data to addIcons ([#1256](https://github.com/ionic-team/ionicons/issues/1256)) ([1e33313](https://github.com/ionic-team/ionicons/commit/1e3331347328c11a8b4c58c9200059bfd76b0e59))
40+
* **icon:** support for dynamic type ([#1246](https://github.com/ionic-team/ionicons/issues/1246)) ([45c04dd](https://github.com/ionic-team/ionicons/commit/45c04dda6c905e535083b171cead374b1c993afa))
41+
42+
43+
44+
45+
646
## [7.1.2](https://github.com/ionic-team/ionicons/compare/v7.1.1...v7.1.2) (2023-05-30)
747

848

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"./"
44
],
5-
"version": "7.1.2"
5+
"version": "7.2.2"
66
}

package-lock.json

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ionicons",
3-
"version": "7.1.2",
3+
"version": "7.2.2",
44
"description": "Premium icons for Ionic.",
55
"files": [
66
"components/",
@@ -23,7 +23,7 @@
2323
"test.spec": "stencil test --spec"
2424
},
2525
"dependencies": {
26-
"@stencil/core": "^2.18.0"
26+
"@stencil/core": "^4.0.3"
2727
},
2828
"devDependencies": {
2929
"@playwright/test": "^1.33.0",

src/components/icon/icon.css

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
box-sizing: content-box !important;
1212

13-
font-size: 1rem;
1413
}
1514

1615
:host .ionicon {

src/components/icon/icon.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class Icon {
1212
private io?: IntersectionObserver;
1313
private iconName: string | null = null;
1414
private inheritedAttributes: { [k: string]: any } = {};
15+
private didLoadIcon = false;
1516

1617
@Element() el!: HTMLElement;
1718

@@ -94,6 +95,18 @@ export class Icon {
9495
});
9596
}
9697

98+
componentDidLoad() {
99+
/**
100+
* Addresses an Angular issue where property values are assigned after the 'connectedCallback' but prior to the registration of watchers.
101+
* This enhancement ensures the loading of an icon when the component has finished rendering and the icon has yet to apply the SVG data.
102+
* This modification pertains to the usage of Angular's binding syntax:
103+
* `<ion-icon [name]="myIconName"></ion-icon>`
104+
*/
105+
if (!this.didLoadIcon) {
106+
this.loadIcon();
107+
}
108+
}
109+
97110
disconnectedCallback() {
98111
if (this.io) {
99112
this.io.disconnect();
@@ -138,6 +151,7 @@ export class Icon {
138151
// async if it hasn't been loaded
139152
getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(url)));
140153
}
154+
this.didLoadIcon = true;
141155
}
142156
}
143157

src/components/icon/test/utils.spec.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -126,27 +126,38 @@ describe('addIcons', () => {
126126
expect(getIconMap().get('myCoolIcon')).toEqual(logoIonitron);
127127
});
128128

129+
it('should not warn when mapping the same icon twice', () => {
130+
const spy = jest.spyOn(console, 'warn');
131+
132+
const myIcon = 'my-icon';
133+
134+
expect(spy).not.toHaveBeenCalled();
135+
136+
addIcons({ myIcon });
137+
138+
expect(spy).not.toHaveBeenCalled();
139+
140+
addIcons({ myIcon });
141+
142+
expect(spy).not.toHaveBeenCalled();
143+
});
144+
129145
it('should not overwrite icons', () => {
146+
const spy = jest.spyOn(console, 'warn');
147+
130148
const logoA = 'logo a';
131149
const logoB = 'logo b';
132150

151+
expect(spy).not.toHaveBeenCalled();
152+
133153
expect(getIconMap().get('logo-a')).toEqual(undefined);
134154

135155
addIcons({ 'logo-a': logoB, logoA });
136156

137157
expect(getIconMap().get('logo-a')).toEqual(logoB);
138158
expect(getIconMap().get('logoA')).toEqual(logoA);
139-
});
140-
141-
it('passing kebab case key should not generate a camel case key', () => {
142-
const logoIonitron = 'stubbed data';
143-
144-
expect(getIconMap().get('kebab-key')).toEqual(undefined);
145-
expect(getIconMap().get('kebabKey')).toEqual(undefined);
146-
147-
addIcons({ 'kebab-key': logoIonitron });
148159

149-
expect(getIconMap().get('kebab-key')).toEqual(logoIonitron);
150-
expect(getIconMap().get('kebabKey')).toEqual(undefined);
160+
expect(spy).toHaveBeenCalled();
151161
});
162+
152163
});

src/components/icon/utils.ts

+23-5
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ export const addIcons = (icons: { [name: string]: string; }) => {
4040

4141
const addToIconMap = (name: string, data: any) => {
4242
const map = getIconMap();
43+
44+
const existingIcon = map.get(name);
4345

44-
if (map.get(name) === undefined) {
46+
if (existingIcon === undefined) {
4547
map.set(name, data);
46-
} else {
48+
49+
/**
50+
* Importing and defining the same icon reference
51+
* multiple times should not yield a warning.
52+
*/
53+
} else if (existingIcon !== data) {
4754
console.warn(`[Ionicons Warning]: Multiple icons were mapped to name "${name}". Ensure that multiple icons are not mapped to the same icon name.`)
4855
}
4956
}
@@ -57,7 +64,7 @@ export const getUrl = (i: Icon) => {
5764

5865
url = getName(i.name, i.icon, i.mode, i.ios, i.md);
5966
if (url) {
60-
return getNamedUrl(url);
67+
return getNamedUrl(url, i);
6168
}
6269

6370
if (i.icon) {
@@ -76,12 +83,23 @@ export const getUrl = (i: Icon) => {
7683
};
7784

7885

79-
const getNamedUrl = (iconName: string) => {
86+
const getNamedUrl = (iconName: string, iconEl: Icon) => {
8087
const url = getIconMap().get(iconName);
8188
if (url) {
8289
return url;
8390
}
84-
return getAssetPath(`svg/${iconName}.svg`);
91+
try {
92+
return getAssetPath(`svg/${iconName}.svg`);
93+
} catch(e) {
94+
/**
95+
* In the custom elements build version of ionicons, referencing an icon
96+
* by name will throw an invalid URL error because the asset path is not defined.
97+
* This catches that error and logs something that is more developer-friendly.
98+
* We also include a reference to the ion-icon element so developers can
99+
* figure out which instance of ion-icon needs to be updated.
100+
*/
101+
console.warn(`[Ionicons Warning]: Could not load icon with name "${iconName}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`, iconEl);
102+
}
85103
};
86104

87105

src/data.json

+3
Original file line numberDiff line numberDiff line change
@@ -8476,19 +8476,22 @@
84768476
{
84778477
"name": "print",
84788478
"tags": [
8479+
"fax",
84798480
"print"
84808481
]
84818482
},
84828483
{
84838484
"name": "print-outline",
84848485
"tags": [
8486+
"fax",
84858487
"outline",
84868488
"print"
84878489
]
84888490
},
84898491
{
84908492
"name": "print-sharp",
84918493
"tags": [
8494+
"fax",
84928495
"print",
84938496
"sharp"
84948497
]

stencil.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Config } from '@stencil/core';
33
export const config: Config = {
44
namespace: 'ionicons',
55
buildEs5: 'prod',
6+
sourceMap: false,
67
outputTargets: [
78
{
89
type: 'dist',

0 commit comments

Comments
 (0)