Compare commits

...
20 Commits
Author SHA1 Message Date
ionitron 35e276a33d v7.2.3 2024-03-20 13:15:02 +00:00
MasonVXandNico Tasche 077168dac9 fix(icon): icon names with numbers are correctly converted to kebab case (#1339)
resolves #1338

---------

Co-authored-by: Nico Tasche <nico.tasche@siemens.com>
2024-03-13 17:55:43 -04:00
Liam DeBeasi de8b11e892 chore(ci): package-lock is updated from separate job (#1308) 2024-01-02 12:44:33 -05:00
Liam DeBeasi 64bbbf997b chore: SVG optimization no longer breaks outline icons (#1313) 2023-12-18 20:26:32 +00:00
Liam DeBeasi c7f561ce41 test: refactor to use toHaveScreenshot (#1314) 2023-12-14 12:52:50 -08:00
Shawn Taylor 116d250255 chore(CODEOWNERS): remove codeowners (#1312) 2023-12-13 17:50:32 -05:00
Liam DeBeasi 49b727ca0d merge release-7.2.2
Release 7.2.2
2023-12-13 10:33:59 -05:00
Liam DeBeasi 811a814ef9 chore: clean up 2023-12-13 09:41:34 -05:00
ionitron 54d5a17c13 chore(): update package lock files 2023-12-13 14:40:09 +00:00
ionitron fccc260627 v7.2.2 2023-12-13 14:40:04 +00:00
Liam DeBeasi d582e6208e fix(icon): add better warning when loading icons (#1297) 2023-11-06 16:28:38 -05:00
Sean Perkins 625d54fdad merge release-7.2.1
v7.2.1
2023-10-10 13:37:32 -04:00
Liam DeBeasi 841fb96543 remove duplicate entry 2023-10-10 13:21:53 -04:00
ionitron 9dab13aef7 chore(): update package lock files 2023-10-10 17:10:51 +00:00
ionitron df6d6f8aeb v7.2.1 2023-10-10 17:10:45 +00:00
Sean Perkins 875bfd8300 fix(icon): font scales without host style (#1289) 2023-10-10 13:06:38 -04:00
Liam DeBeasi cb640b6208 chore(ci): ensure local version of lerna is used (#1288) 2023-10-10 10:42:07 -04:00
Liam DeBeasi 6a032e54cd merge release-7.2.0
Feature 7.2
2023-10-10 10:37:27 -04:00
Liam DeBeasi a3902ce3bb merge release-7.2.0
Release 7.2.0
2023-10-10 10:29:32 -04:00
Liam DeBeasi 8237f1ccaa chore: clean up 2023-10-10 10:23:57 -04:00
19 changed files with 136 additions and 98 deletions
-17
View File
@@ -1,17 +0,0 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.
# More details are here: https://help.github.com/articles/about-codeowners/
# The '*' pattern is global owners.
# Order is important. The last matching pattern has the most precedence.
# The folders are ordered as follows:
# In each subsection folders are ordered first by depth, then alphabetically.
# This should make it easy to add new rules without breaking existing ones.
# Global Owner
* @mapsandapps
+1 -1
View File
@@ -50,7 +50,7 @@ Please see our [Contributor Code of Conduct](./CODE_OF_CONDUCT.md) for informati
1. Run `npm start` from the root directory to start a local version of the icon test.
2. Modify the icon test as needed in the `index.html` file.
3. If you are modifying icons, you can run `npm run build.files` to re-run the SVG optimization script to verify there are no changes after optimizing the SVG.
<!-- #### Building Changes
@@ -55,10 +55,8 @@ runs:
npx playwright test --shard=${{ inputs.shard }}/${{ inputs.totalShards }} --update-snapshots
git add src/\*.png --force
mkdir updated-screenshots
echo 'made dir'
rsync -R --progress $(git diff --name-only --cached) updated-screenshots
echo 'copied images'
if [ -d updated-screenshots ]; then
if [ "$(ls -A updated-screenshots)" ]; then
echo "hasUpdatedScreenshots=$(echo 'true')" >> $GITHUB_OUTPUT
cd updated-screenshots
ls
+25 -11
View File
@@ -45,18 +45,32 @@ jobs:
git config user.name ionitron
git config user.email hi@ionicframework.com
shell: bash
# This ensures the local version of Lerna is installed
# and that we do not use the global Lerna version
- name: Install root dependencies
run: npm ci
shell: bash
- name: Create GitHub Release
run: lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github
run: npx lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
# Lerna does not automatically bump versions
# of Ionicons dependencies that have changed,
# so we do that here.
- name: Bump Package Lock
run: |
lerna exec "npm install --package-lock-only --legacy-peer-deps"
git add .
git commit -m "chore(): update package lock files"
git push
shell: bash
update-package-lock:
# This needs to run after finalize-release
# because we also push to the repo in that
# job. If these jobs ran in parallel then it is
# possible for them to push at the same time.
needs: [finalize-release]
runs-on: ubuntu-latest
steps:
# Lerna does not automatically bump versions
# of Ionicons dependencies that have changed,
# so we do that here.
- name: Bump Package Lock
run: |
npx lerna exec "npm install --package-lock-only --legacy-peer-deps"
git add .
git commit -m "chore(): update package lock files"
git push
shell: bash
+32 -6
View File
@@ -3,19 +3,45 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [7.2.0](https://github.com/ionic-team/ionicons/compare/v7.1.2...v7.2.0) (2023-10-10)
## [7.2.3](https://github.com/ionic-team/ionicons/compare/v7.2.2...v7.2.3) (2024-03-20)
### Bug Fixes
* **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))
* **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))
* **icon:** icon names with numbers are correctly converted to kebab case ([#1339](https://github.com/ionic-team/ionicons/issues/1339)) ([077168d](https://github.com/ionic-team/ionicons/commit/077168dac9347f25d2b8ce440bd0a3e8576f4cdf)), closes [#1338](https://github.com/ionic-team/ionicons/issues/1338)
### Features
* 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))
* **icon:** support for dynamic type ([#1246](https://github.com/ionic-team/ionicons/issues/1246)) ([45c04dd](https://github.com/ionic-team/ionicons/commit/45c04dda6c905e535083b171cead374b1c993afa))
## [7.2.3](https://github.com/ionic-team/ionicons/compare/v7.2.2...v7.2.3) (2024-03-20)
### Bug Fixes
* **icon:** icon names with numbers are correctly converted to kebab case ([#1339](https://github.com/ionic-team/ionicons/issues/1339)) ([077168d](https://github.com/ionic-team/ionicons/commit/077168dac9347f25d2b8ce440bd0a3e8576f4cdf)), closes [#1338](https://github.com/ionic-team/ionicons/issues/1338)
## [7.2.2](https://github.com/ionic-team/ionicons/compare/v7.2.1...v7.2.2) (2023-12-13)
### Bug Fixes
* **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))
## [7.2.1](https://github.com/ionic-team/ionicons/compare/v7.2.0...v7.2.1) (2023-10-10)
### Bug Fixes
* **icon:** font scales without host style ([#1289](https://github.com/ionic-team/ionicons/issues/1289)) ([875bfd8](https://github.com/ionic-team/ionicons/commit/875bfd8300144c62e55a5a76dc2cff8cf1f01bfe))
+1 -1
View File
@@ -2,5 +2,5 @@
"packages": [
"./"
],
"version": "7.2.0"
"version": "7.2.3"
}
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "ionicons",
"version": "7.2.0",
"version": "7.2.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "ionicons",
"version": "7.2.0",
"version": "7.2.3",
"license": "MIT",
"dependencies": {
"@stencil/core": "^4.0.3"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ionicons",
"version": "7.2.0",
"version": "7.2.3",
"description": "Premium icons for Ionic.",
"files": [
"components/",
+1 -8
View File
@@ -52,14 +52,7 @@ const config: PlaywrightTestConfig = {
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
toMatchSnapshot: {
/**
* Increases the maximum allowed pixel difference to account
* for slight browser rendering inconsistencies.
*/
maxDiffPixelRatio: 0.02
}
timeout: 5000
},
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
+12 -8
View File
@@ -51,6 +51,16 @@ async function optimizeSvgs(srcSvgData: SvgData[]) {
if (!Array.isArray(params.attrs)) {
params.attrs = [params.attrs];
}
/**
* All host SVG elements must have
* the ionicons class otherwise styles
* will not apply.
*/
if (item.elem === 'svg') {
item.class.add('ionicon');
}
if (item.isElem()) {
item.eachAttr((attr) => {
if (attr.name === 'fill') {
@@ -165,14 +175,8 @@ async function optimizeSvg(
const srcSvgContent = await fs.readFile(svgData.srcFilePath, 'utf8');
const optimizedSvg = await optimizePass.optimize(srcSvgContent, { path: svgData.srcFilePath });
const optimizedCode = optimizedSvg.data.replace(
/<svg (.*?)>/,
`<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">`,
);
const webComponentSvg = await webComponentPass.optimize(optimizedCode, { path: svgData.srcFilePath });
const sourceSvg = await sourcePass.optimize(optimizedCode, { path: svgData.srcFilePath });
const webComponentSvg = await webComponentPass.optimize(optimizedSvg.data, { path: svgData.srcFilePath });
const sourceSvg = await sourcePass.optimize(optimizedSvg.data, { path: svgData.srcFilePath });
svgData.optimizedSvgContent = webComponentSvg.data;
-1
View File
@@ -10,7 +10,6 @@
box-sizing: content-box !important;
font-size: 1rem;
}
:host .ionicon {
+1 -1
View File
@@ -8,7 +8,7 @@ test.describe('icon: basic', () => {
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot(`icon-diff.png`);
await expect(page).toHaveScreenshot(`icon-diff.png`, { fullPage: true });
});
test('some icons should flip when rtl', async ({ page }) => {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 KiB

After

Width:  |  Height:  |  Size: 89 KiB

+39 -29
View File
@@ -86,78 +86,88 @@ describe('getName', () => {
describe('addIcons', () => {
it('should add an svg to the icon cache', () => {
const testData = 'stubbed data';
expect(getIconMap().get('logo-ionic')).toEqual(undefined);
addIcons({ 'logo-ionic': 'stubbed data' });
expect(getIconMap().get('logo-ionic')).toEqual(testData);
});
it('should add kebab and camel case names to the icon cache', () => {
const logoIonitron = 'stubbed data';
expect(getIconMap().get('logo-ionitron')).toEqual(undefined);
expect(getIconMap().get('logoIonitron')).toEqual(undefined);
addIcons({ logoIonitron });
expect(getIconMap().get('logo-ionitron')).toEqual(logoIonitron);
expect(getIconMap().get('logoIonitron')).toEqual(logoIonitron);
const logoIonitron0 = 'stubbed data 0'
expect(getIconMap().get('logo-ionitron-0')).toEqual(undefined);
expect(getIconMap().get('logoIonitron0')).toEqual(undefined);
addIcons({ logoIonitron0 });
expect(getIconMap().get('logo-ionitron-0')).toEqual(logoIonitron0);
expect(getIconMap().get('logoIonitron0')).toEqual(logoIonitron0);
});
it('should map to a name that does not match the svg', () => {
const logoIonitron = 'stubbed data';
expect(getIconMap().get('my-fun-icon')).toEqual(undefined);
addIcons({ 'my-fun-icon': logoIonitron });
expect(getIconMap().get('my-fun-icon')).toEqual(logoIonitron);
});
it('should map to an explicit camel case name', () => {
const logoIonitron = 'stubbed data';
expect(getIconMap().get('myCoolIcon')).toEqual(undefined);
addIcons({ 'myCoolIcon': logoIonitron });
expect(getIconMap().get('myCoolIcon')).toEqual(logoIonitron);
});
it('should not warn when mapping the same icon twice', () => {
const spy = jest.spyOn(console, 'warn');
const myIcon = 'my-icon';
expect(spy).not.toHaveBeenCalled();
addIcons({ myIcon });
expect(spy).not.toHaveBeenCalled();
addIcons({ myIcon });
expect(spy).not.toHaveBeenCalled();
});
it('should not overwrite icons', () => {
const spy = jest.spyOn(console, 'warn');
const logoA = 'logo a';
const logoB = 'logo b';
expect(spy).not.toHaveBeenCalled();
expect(getIconMap().get('logo-a')).toEqual(undefined);
addIcons({ 'logo-a': logoB, logoA });
expect(getIconMap().get('logo-a')).toEqual(logoB);
expect(getIconMap().get('logoA')).toEqual(logoA);
expect(spy).toHaveBeenCalled();
});
});
+19 -8
View File
@@ -18,9 +18,9 @@ export const getIconMap = (): Map<string, string> => {
};
export const addIcons = (icons: { [name: string]: string; }) => {
Object.keys(icons).forEach(name => {
Object.keys(icons).forEach(name => {
addToIconMap(name, icons[name]);
/**
* Developers can also pass in the SVG object directly
* and Ionicons can map the object to a kebab case name.
@@ -31,7 +31,7 @@ export const addIcons = (icons: { [name: string]: string; }) => {
* Using name="addCircleOutline" is valid too, but the
* kebab case naming is preferred.
*/
const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, "$1-$2").toLowerCase();
if (name !== toKebabCase) {
addToIconMap(toKebabCase, icons[name]);
}
@@ -40,12 +40,12 @@ export const addIcons = (icons: { [name: string]: string; }) => {
const addToIconMap = (name: string, data: any) => {
const map = getIconMap();
const existingIcon = map.get(name);
if (existingIcon === undefined) {
map.set(name, data);
/**
* Importing and defining the same icon reference
* multiple times should not yield a warning.
@@ -64,7 +64,7 @@ export const getUrl = (i: Icon) => {
url = getName(i.name, i.icon, i.mode, i.ios, i.md);
if (url) {
return getNamedUrl(url);
return getNamedUrl(url, i);
}
if (i.icon) {
@@ -83,12 +83,23 @@ export const getUrl = (i: Icon) => {
};
const getNamedUrl = (iconName: string) => {
const getNamedUrl = (iconName: string, iconEl: Icon) => {
const url = getIconMap().get(iconName);
if (url) {
return url;
}
return getAssetPath(`svg/${iconName}.svg`);
try {
return getAssetPath(`svg/${iconName}.svg`);
} catch(e) {
/**
* In the custom elements build version of ionicons, referencing an icon
* by name will throw an invalid URL error because the asset path is not defined.
* This catches that error and logs something that is more developer-friendly.
* We also include a reference to the ion-icon element so developers can
* figure out which instance of ion-icon needs to be updated.
*/
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);
}
};
+1 -1
View File
@@ -13,7 +13,7 @@ test.describe('icon: dynamic type', () => {
const icons = page.locator('#icons');
expect(await icons.screenshot()).toMatchSnapshot(`icon-dynamic-type-diff.png`);
await expect(icons).toHaveScreenshot(`icon-dynamic-type-diff.png`);
});
});
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB