2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-04 18:23:17 +00:00

chore(utils): fix scale for non-square icons

This commit is contained in:
Vjacheslav Trushkin 2024-07-29 11:34:08 +03:00
parent 7b33339367
commit e633a41e55
4 changed files with 25 additions and 3 deletions

View File

@ -3,7 +3,7 @@
"type": "module", "type": "module",
"description": "Common functions for working with Iconify icon sets used by various packages.", "description": "Common functions for working with Iconify icon sets used by various packages.",
"author": "Vjacheslav Trushkin", "author": "Vjacheslav Trushkin",
"version": "2.1.26", "version": "2.1.28",
"license": "MIT", "license": "MIT",
"bugs": "https://github.com/iconify/iconify/issues", "bugs": "https://github.com/iconify/iconify/issues",
"homepage": "https://iconify.design/docs/libraries/utils/", "homepage": "https://iconify.design/docs/libraries/utils/",
@ -427,6 +427,7 @@
"mlly": "^1.7.1" "mlly": "^1.7.1"
}, },
"devDependencies": { "devDependencies": {
"@iconify-json/fa6-regular": "^1.1.21",
"@iconify-json/flat-color-icons": "^1.1.10", "@iconify-json/flat-color-icons": "^1.1.10",
"@types/debug": "^4.1.12", "@types/debug": "^4.1.12",
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",

View File

@ -21,7 +21,9 @@ export async function searchForIcon(
iconData = getIconData(iconSet, id); iconData = getIconData(iconSet, id);
if (iconData) { if (iconData) {
debug(`${collection}:${id}`); debug(`${collection}:${id}`);
let defaultCustomizations = { ...defaultIconCustomisations }; let defaultCustomizations: typeof defaultIconCustomisations = {
...defaultIconCustomisations,
};
if (typeof customize === 'function') { if (typeof customize === 'function') {
// Clone icon data to make it mutable // Clone icon data to make it mutable
iconData = Object.assign({}, iconData); iconData = Object.assign({}, iconData);

View File

@ -1,6 +1,6 @@
import { loadNodeIcon } from '../lib/loader/node-loader'; import { loadNodeIcon } from '../lib/loader/node-loader';
describe('Testing loadIcon with @iconify-json/flat-color-icons>', () => { describe('Testing loadNodeIcon', () => {
test('loadIcon works', async () => { test('loadIcon works', async () => {
const result = await loadNodeIcon('flat-color-icons', 'up-right'); const result = await loadNodeIcon('flat-color-icons', 'up-right');
expect(result).toBeTruthy(); expect(result).toBeTruthy();
@ -174,4 +174,20 @@ describe('Testing loadIcon with @iconify-json/flat-color-icons>', () => {
}); });
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
test('loadIcon with non-square icon', async () => {
const result = await loadNodeIcon('fa6-regular', 'bookmark');
expect(result).toBeTruthy();
expect(result && result.includes('width="0.75em"')).toBeTruthy();
expect(result && result.includes('height="1em"')).toBeTruthy();
});
test('loadIcon with non-square icon with scale', async () => {
const result = await loadNodeIcon('fa6-regular', 'bookmark', {
scale: 1,
});
expect(result).toBeTruthy();
expect(result && result.includes('width="0.75em"')).toBeTruthy();
expect(result && result.includes('height="1em"')).toBeTruthy();
});
}); });

View File

@ -793,6 +793,9 @@ importers:
specifier: ^1.7.1 specifier: ^1.7.1
version: 1.7.1 version: 1.7.1
devDependencies: devDependencies:
'@iconify-json/fa6-regular':
specifier: ^1.1.21
version: 1.1.21
'@iconify-json/flat-color-icons': '@iconify-json/flat-color-icons':
specifier: ^1.1.10 specifier: ^1.1.10
version: 1.1.10 version: 1.1.10