mirror of
https://github.com/iconify/iconify.git
synced 2025-01-22 14:48:24 +00:00
Update core package
This commit is contained in:
parent
ad29f6df20
commit
6d1ec83912
@ -1,10 +1,8 @@
|
|||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
import {
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
defaults,
|
import { mergeCustomisations } from '@iconify/utils/lib/customisations/merge';
|
||||||
mergeCustomisations,
|
import type { IconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
} from '@iconify/utils/lib/customisations';
|
|
||||||
import type { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
|
||||||
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
|
|
||||||
@ -32,9 +30,9 @@ export function buildIcon(
|
|||||||
customisations?: IconifyIconCustomisations
|
customisations?: IconifyIconCustomisations
|
||||||
): IconifyIconBuildResult {
|
): IconifyIconBuildResult {
|
||||||
return iconToSVG(
|
return iconToSVG(
|
||||||
fullIcon(icon),
|
{ ...defaultIconProps, ...icon },
|
||||||
customisations
|
customisations
|
||||||
? mergeCustomisations(defaults, customisations)
|
? mergeCustomisations(defaultIconCustomisations, customisations)
|
||||||
: defaults
|
: defaultIconCustomisations
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
import type { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { parseIconSet } from '@iconify/utils/lib/icon-set/parse';
|
import { parseIconSet } from '@iconify/utils/lib/icon-set/parse';
|
||||||
import { quicklyValidateIconSet } from '@iconify/utils/lib/icon-set/validate-basic';
|
import { quicklyValidateIconSet } from '@iconify/utils/lib/icon-set/validate-basic';
|
||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
import type { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { parseIconSet } from '@iconify/utils/lib/icon-set/parse';
|
import { parseIconSet } from '@iconify/utils/lib/icon-set/parse';
|
||||||
import { quicklyValidateIconSet } from '@iconify/utils/lib/icon-set/validate-basic';
|
import { quicklyValidateIconSet } from '@iconify/utils/lib/icon-set/validate-basic';
|
||||||
|
|
||||||
@ -84,7 +84,10 @@ export function addIconToStorage(
|
|||||||
try {
|
try {
|
||||||
if (typeof icon.body === 'string') {
|
if (typeof icon.body === 'string') {
|
||||||
// Freeze icon to make sure it will not be modified
|
// Freeze icon to make sure it will not be modified
|
||||||
storage.icons[name] = Object.freeze(fullIcon(icon));
|
storage.icons[name] = Object.freeze({
|
||||||
|
...defaultIconProps,
|
||||||
|
...icon,
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { addIconSet, getStorage, listIcons } from '../../lib/storage/storage';
|
import { addIconSet, getStorage, listIcons } from '../../lib/storage/storage';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconExists,
|
||||||
@ -42,9 +42,10 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
expect(iconExists(testName)).toBe(true);
|
expect(iconExists(testName)).toBe(true);
|
||||||
expect(listIcons(provider)).toEqual([testName]);
|
expect(listIcons(provider)).toEqual([testName]);
|
||||||
|
|
||||||
let expected = fullIcon({
|
let expected = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '<g />',
|
body: '<g />',
|
||||||
});
|
};
|
||||||
expect(getIconData(testName)).toEqual(expected);
|
expect(getIconData(testName)).toEqual(expected);
|
||||||
expect(getIcon(testName)).toEqual(expected);
|
expect(getIcon(testName)).toEqual(expected);
|
||||||
|
|
||||||
@ -63,9 +64,10 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
|
|
||||||
// Test 'home' icon
|
// Test 'home' icon
|
||||||
expect(iconExists(`${prefix}:home`)).toBe(true);
|
expect(iconExists(`${prefix}:home`)).toBe(true);
|
||||||
expected = fullIcon({
|
expected = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '<g id="home" />',
|
body: '<g id="home" />',
|
||||||
});
|
};
|
||||||
expect(getIconData(`${prefix}:home`)).toEqual(expected);
|
expect(getIconData(`${prefix}:home`)).toEqual(expected);
|
||||||
expect(getIcon(`${prefix}:home`)).toEqual(expected);
|
expect(getIcon(`${prefix}:home`)).toEqual(expected);
|
||||||
|
|
||||||
@ -161,9 +163,10 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
// Test 'test'
|
// Test 'test'
|
||||||
name = name1;
|
name = name1;
|
||||||
expect(iconExists(name)).toBe(true);
|
expect(iconExists(name)).toBe(true);
|
||||||
let expected = fullIcon({
|
let expected = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '<g data-icon="basic-icon" />',
|
body: '<g data-icon="basic-icon" />',
|
||||||
});
|
};
|
||||||
expect(getIcon(name)).toEqual(expected);
|
expect(getIcon(name)).toEqual(expected);
|
||||||
expect(getIconData(name)).toEqual(expected);
|
expect(getIconData(name)).toEqual(expected);
|
||||||
|
|
||||||
@ -171,18 +174,20 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
name = `${prefix2}:${name2}`;
|
name = `${prefix2}:${name2}`;
|
||||||
expect(listIcons('', prefix2)).toEqual([name]);
|
expect(listIcons('', prefix2)).toEqual([name]);
|
||||||
expect(iconExists(name)).toBe(true);
|
expect(iconExists(name)).toBe(true);
|
||||||
expected = fullIcon({
|
expected = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '<g data-icon="prefixed-icon" />',
|
body: '<g data-icon="prefixed-icon" />',
|
||||||
});
|
};
|
||||||
expect(getIcon(name)).toEqual(expected);
|
expect(getIcon(name)).toEqual(expected);
|
||||||
expect(getIconData(name)).toEqual(expected);
|
expect(getIconData(name)).toEqual(expected);
|
||||||
|
|
||||||
// Test prefixed icon, using '-' separator
|
// Test prefixed icon, using '-' separator
|
||||||
name = `${prefix2}-${name2}`;
|
name = `${prefix2}-${name2}`;
|
||||||
expect(iconExists(name)).toBe(true);
|
expect(iconExists(name)).toBe(true);
|
||||||
expected = fullIcon({
|
expected = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '<g data-icon="prefixed-icon" />',
|
body: '<g data-icon="prefixed-icon" />',
|
||||||
});
|
};
|
||||||
expect(getIcon(name)).toEqual(expected);
|
expect(getIcon(name)).toEqual(expected);
|
||||||
expect(getIconData(name)).toEqual(expected);
|
expect(getIconData(name)).toEqual(expected);
|
||||||
|
|
||||||
|
@ -7,7 +7,10 @@ import {
|
|||||||
getStorage,
|
getStorage,
|
||||||
listIcons,
|
listIcons,
|
||||||
} from '../../lib/storage/storage';
|
} from '../../lib/storage/storage';
|
||||||
import type { IconifyIcon, FullIconifyIcon } from '@iconify/utils/lib/icon';
|
import type {
|
||||||
|
IconifyIcon,
|
||||||
|
FullIconifyIcon,
|
||||||
|
} from '@iconify/utils/lib/icon/defaults';
|
||||||
|
|
||||||
describe('Testing storage', () => {
|
describe('Testing storage', () => {
|
||||||
it('Adding icon', () => {
|
it('Adding icon', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user