2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 13:47:49 +00:00

Update web component

This commit is contained in:
Vjacheslav Trushkin 2022-06-19 17:47:45 +03:00
parent 6d1ec83912
commit c892879e90
10 changed files with 28 additions and 36 deletions

View File

@ -1,5 +1,5 @@
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
import { defaults } from '@iconify/utils/lib/customisations';
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
import type { IconifyIconSVGAttributes } from './types';
@ -7,16 +7,11 @@ import type { IconifyIconSVGAttributes } from './types';
/**
* Customisations that affect rendering
*/
export type RenderedIconCustomisations = Omit<
FullIconCustomisations,
'inline'
> &
export type RenderedIconCustomisations = FullIconCustomisations &
IconifyIconSVGAttributes;
// Remove 'inline' from defaults
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { inline, ...defaultCustomisations } = {
...defaults,
const defaultCustomisations = {
...defaultIconCustomisations,
preserveAspectRatio: '',
} as IconifyIconSVGAttributes & FullIconCustomisations;
export { defaultCustomisations };

View File

@ -1,5 +1,5 @@
import type { IconifyIcon } from '@iconify/types';
import { iconDefaults } from '@iconify/utils/lib/icon';
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
/**
* Test icon string
@ -11,7 +11,7 @@ export function testIconObject(
const obj = typeof value === 'string' ? JSON.parse(value) : value;
if (typeof obj.body === 'string') {
return {
...iconDefaults,
...defaultIconProps,
...obj,
};
}

View File

@ -5,7 +5,7 @@ import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
import type {
IconifyIconSize,
IconifyIconCustomisations,
} from '@iconify/utils/lib/customisations';
} from '@iconify/utils/lib/customisations/defaults';
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';

View File

@ -11,10 +11,7 @@ export function renderIcon(parent: Element | ShadowRoot, state: RenderedState) {
const customisations = state.customisations;
// Render icon
const renderData = iconToSVG(iconData, {
...customisations,
inline: state.inline,
});
const renderData = iconToSVG(iconData, customisations);
if (customisations.preserveAspectRatio) {
renderData.attributes['preserveAspectRatio'] =
customisations.preserveAspectRatio;

View File

@ -1,4 +1,4 @@
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
import type { FullIconifyIcon } from '@iconify/utils/lib/icon/defaults';
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
import { iconToHTML } from '@iconify/utils/lib/svg/html';
import { svgToURL } from '@iconify/utils/lib/svg/url';

View File

@ -1,5 +1,5 @@
import { fakeAPI, nextPrefix, mockAPIData } from './helpers';
import { iconDefaults } from '@iconify/utils/lib/icon';
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
import { addCollection } from '@iconify/core/lib/storage/functions';
import { parseIconValue } from '../src/attributes/icon/index';
@ -41,7 +41,7 @@ describe('Testing parseIconValue with API', () => {
name,
});
expect(data).toEqual({
...iconDefaults,
...defaultIconProps,
body: '<g />',
});
@ -111,7 +111,7 @@ describe('Testing parseIconValue with API', () => {
name,
},
data: {
...iconDefaults,
...defaultIconProps,
body: '<g id="test" />',
},
});

View File

@ -1,5 +1,5 @@
import { parseIconValue } from '../src/attributes/icon/index';
import { iconDefaults } from '@iconify/utils/lib/icon';
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
describe('Testing parseIconValue without API', () => {
it('Instantly loading object', () => {
@ -12,7 +12,7 @@ describe('Testing parseIconValue without API', () => {
expect(result).toEqual({
value,
data: {
...iconDefaults,
...defaultIconProps,
...value,
},
});
@ -29,7 +29,7 @@ describe('Testing parseIconValue without API', () => {
expect(result).toEqual({
value,
data: {
...iconDefaults,
...defaultIconProps,
body: '<g />',
},
});

View File

@ -1,5 +1,5 @@
import { testIconObject } from '../src/attributes/icon/object';
import { iconDefaults } from '@iconify/utils/lib/icon';
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
describe('Testing testIconObject', () => {
it('Objects', () => {
@ -8,7 +8,7 @@ describe('Testing testIconObject', () => {
body: '<g />',
})
).toEqual({
...iconDefaults,
...defaultIconProps,
body: '<g />',
});
@ -19,7 +19,7 @@ describe('Testing testIconObject', () => {
height: '32',
})
).toEqual({
...iconDefaults,
...defaultIconProps,
body: '<g />',
width: 24,
// Validation is simple, this will fail during render
@ -50,7 +50,7 @@ describe('Testing testIconObject', () => {
})
)
).toEqual({
...iconDefaults,
...defaultIconProps,
body: '<g />',
});

View File

@ -1,6 +1,6 @@
import { iconExists } from '@iconify/core/lib/storage/functions';
import { loadIcon } from '@iconify/core/lib/api/icons';
import { iconDefaults } from '@iconify/utils/lib/icon';
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
import { fakeAPI, nextPrefix, mockAPIData } from './helpers';
describe('Testing mock API', () => {
@ -34,7 +34,7 @@ describe('Testing mock API', () => {
// Load icon
const data = await loadIcon(iconName);
expect(data).toEqual({
...iconDefaults,
...defaultIconProps,
body: '<g />',
});
});

View File

@ -1,4 +1,4 @@
import { iconDefaults } from '@iconify/utils/lib/icon';
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
import {
cleanupGlobals,
expectedBlock,
@ -26,7 +26,7 @@ describe('Testing rendering loaded icon', () => {
icon: {
value: 'whatever',
data: {
...iconDefaults,
...defaultIconProps,
body: '<g />',
},
},
@ -48,7 +48,7 @@ describe('Testing rendering loaded icon', () => {
icon: {
value: 'whatever',
data: {
...iconDefaults,
...defaultIconProps,
width: 24,
height: 24,
body: '<g><path d="" /></g>',
@ -83,7 +83,7 @@ describe('Testing rendering loaded icon', () => {
icon: {
value: 'whatever',
data: {
...iconDefaults,
...defaultIconProps,
body: '<g />',
},
},
@ -115,7 +115,7 @@ describe('Testing rendering loaded icon', () => {
icon: {
value: 'whatever',
data: {
...iconDefaults,
...defaultIconProps,
body: '<g />',
},
},
@ -137,7 +137,7 @@ describe('Testing rendering loaded icon', () => {
icon: {
value: 'whatever',
data: {
...iconDefaults,
...defaultIconProps,
body: '<g />',
},
},