mirror of
https://github.com/iconify/iconify.git
synced 2025-01-07 15:44:05 +00:00
Update components
This commit is contained in:
parent
9ad23abd6a
commit
ce135b6cf5
@ -5,8 +5,8 @@ import { tracked } from '@glimmer/tracking';
|
|||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||||
import { getIconData } from '@iconify/core/lib/storage/functions';
|
import { getIconData } from '@iconify/core/lib/storage/functions';
|
||||||
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';
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import { loadIcon } from '@iconify/core/lib/api/icons';
|
import { loadIcon } from '@iconify/core/lib/api/icons';
|
||||||
@ -68,7 +68,7 @@ export class IconifyIconComponent extends Component<IconifyIconProps> {
|
|||||||
this._icon = null;
|
this._icon = null;
|
||||||
|
|
||||||
// Render object
|
// Render object
|
||||||
return render(fullIcon(icon), this.args, '');
|
return render({ ...defaultIconProps, ...icon }, this.args, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already loaded
|
// Already loaded
|
||||||
|
@ -2,7 +2,7 @@ import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
|||||||
|
|
||||||
// Core
|
// Core
|
||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconExists,
|
||||||
@ -64,7 +64,6 @@ import type {
|
|||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
import type {
|
import type {
|
||||||
RawIconCustomisations,
|
|
||||||
IconifyIconOnLoad,
|
IconifyIconOnLoad,
|
||||||
IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
IconifyIconProps,
|
IconifyIconProps,
|
||||||
@ -111,7 +110,7 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Builder functions
|
// Builder functions
|
||||||
export { RawIconCustomisations, IconifyIconBuildResult };
|
export { IconifyIconBuildResult };
|
||||||
|
|
||||||
/* Browser cache */
|
/* Browser cache */
|
||||||
export { IconifyBrowserCacheType };
|
export { IconifyBrowserCacheType };
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
|
||||||
export { RawIconCustomisations };
|
|
||||||
|
|
||||||
// Allow rotation to be string
|
|
||||||
/**
|
/**
|
||||||
* Icon customisations
|
* Icon customisations
|
||||||
*/
|
*/
|
||||||
export type IconifyIconCustomisations = RawIconCustomisations & {
|
export type IconifyIconCustomisations = RawIconifyIconCustomisations & {
|
||||||
|
// Allow rotation to be string
|
||||||
rotate?: string | number;
|
rotate?: string | number;
|
||||||
|
|
||||||
|
// Inline mode
|
||||||
|
inline?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultExtendedIconCustomisations = {
|
||||||
|
...defaultIconCustomisations,
|
||||||
|
inline: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { htmlSafe } from '@ember/template';
|
import { htmlSafe } from '@ember/template';
|
||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
import { mergeCustomisations } from '@iconify/utils/lib/customisations/merge';
|
||||||
import {
|
|
||||||
defaults,
|
|
||||||
mergeCustomisations,
|
|
||||||
} from '@iconify/utils/lib/customisations';
|
|
||||||
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
||||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||||
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import type { IconifyIconCustomisations, IconifyIconProps } from './props';
|
import type { IconifyIconCustomisations, IconifyIconProps } from './props';
|
||||||
|
import { defaultExtendedIconCustomisations } from './props';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render result
|
* Render result
|
||||||
@ -39,9 +36,9 @@ export const render = (
|
|||||||
): RenderResult => {
|
): RenderResult => {
|
||||||
// Get all customisations
|
// Get all customisations
|
||||||
const customisations = mergeCustomisations(
|
const customisations = mergeCustomisations(
|
||||||
defaults,
|
defaultExtendedIconCustomisations,
|
||||||
props as IconifyIconCustomisations
|
props as IconifyIconCustomisations
|
||||||
) as FullIconCustomisations;
|
);
|
||||||
|
|
||||||
// Create empty style
|
// Create empty style
|
||||||
let style = '';
|
let style = '';
|
||||||
@ -109,7 +106,7 @@ export const render = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Add inline
|
// Add inline
|
||||||
if (item.inline) {
|
if (customisations.inline) {
|
||||||
style += 'vertical-align: -0.125em;';
|
style += 'vertical-align: -0.125em;';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
|||||||
// Core
|
// Core
|
||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconExists,
|
||||||
@ -20,7 +20,7 @@ import { buildIcon } from '@iconify/core/lib/builder/functions';
|
|||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import type {
|
import type {
|
||||||
@ -68,7 +68,6 @@ import type {
|
|||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
import type {
|
import type {
|
||||||
RawIconCustomisations,
|
|
||||||
IconifyIconOnLoad,
|
IconifyIconOnLoad,
|
||||||
IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
IconifyIconProps,
|
IconifyIconProps,
|
||||||
@ -120,7 +119,7 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Builder functions
|
// Builder functions
|
||||||
export { RawIconCustomisations, IconifyIconBuildResult };
|
export { IconifyIconBuildResult };
|
||||||
|
|
||||||
/* Browser cache */
|
/* Browser cache */
|
||||||
export { IconifyBrowserCacheType };
|
export { IconifyBrowserCacheType };
|
||||||
@ -293,7 +292,7 @@ class IconComponent extends React.Component<
|
|||||||
if (changed || state.icon === null) {
|
if (changed || state.icon === null) {
|
||||||
// Set data if it was changed
|
// Set data if it was changed
|
||||||
this._setData({
|
this._setData({
|
||||||
data: fullIcon(icon),
|
data: { ...defaultIconProps, ...icon },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/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';
|
||||||
import type {
|
import type {
|
||||||
@ -41,7 +41,7 @@ function component(
|
|||||||
typeof props.icon === 'string'
|
typeof props.icon === 'string'
|
||||||
? storage[props.icon]
|
? storage[props.icon]
|
||||||
: typeof props.icon === 'object'
|
: typeof props.icon === 'object'
|
||||||
? fullIcon(props.icon)
|
? { ...defaultIconProps, ...props.icon }
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Validate icon object
|
// Validate icon object
|
||||||
@ -89,7 +89,7 @@ export const InlineIcon = React.forwardRef<IconRef, IconProps>(
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function addIcon(name: string, data: IconifyIcon): void {
|
export function addIcon(name: string, data: IconifyIcon): void {
|
||||||
storage[name] = fullIcon(data);
|
storage[name] = { ...defaultIconProps, ...data };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import type { SVGProps, RefAttributes } from 'react';
|
import type { SVGProps, RefAttributes } from 'react';
|
||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
export { RawIconCustomisations };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icon render mode
|
* Icon render mode
|
||||||
@ -14,15 +13,20 @@ export { RawIconCustomisations };
|
|||||||
*/
|
*/
|
||||||
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
||||||
|
|
||||||
// Allow rotation to be string
|
|
||||||
/**
|
/**
|
||||||
* Icon customisations
|
* Icon customisations
|
||||||
*/
|
*/
|
||||||
export type IconifyIconCustomisations = Omit<
|
export type IconifyIconCustomisations = RawIconifyIconCustomisations & {
|
||||||
RawIconCustomisations,
|
// Allow rotation to be string
|
||||||
'rotate'
|
|
||||||
> & {
|
|
||||||
rotate?: string | number;
|
rotate?: string | number;
|
||||||
|
|
||||||
|
// Inline mode
|
||||||
|
inline?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultExtendedIconCustomisations = {
|
||||||
|
...defaultIconCustomisations,
|
||||||
|
inline: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { SVGProps } from 'react';
|
import type { SVGProps } from 'react';
|
||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
import { mergeCustomisations } from '@iconify/utils/lib/customisations/merge';
|
||||||
import {
|
|
||||||
defaults,
|
|
||||||
mergeCustomisations,
|
|
||||||
} from '@iconify/utils/lib/customisations';
|
|
||||||
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
||||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||||
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import { iconToHTML } from '@iconify/utils/lib/svg/html';
|
import { iconToHTML } from '@iconify/utils/lib/svg/html';
|
||||||
import { svgToURL } from '@iconify/utils/lib/svg/url';
|
import { svgToURL } from '@iconify/utils/lib/svg/url';
|
||||||
import type { IconifyRenderMode, IconProps, IconRef } from './props';
|
import type {
|
||||||
|
IconifyIconCustomisations,
|
||||||
|
IconifyRenderMode,
|
||||||
|
IconProps,
|
||||||
|
IconRef,
|
||||||
|
} from './props';
|
||||||
|
import { defaultExtendedIconCustomisations } from './props';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default SVG attributes
|
* Default SVG attributes
|
||||||
@ -60,7 +62,10 @@ for (const prefix in propsToAddTo) {
|
|||||||
/**
|
/**
|
||||||
* Default values for customisations for inline icon
|
* Default values for customisations for inline icon
|
||||||
*/
|
*/
|
||||||
const inlineDefaults: FullIconCustomisations = { ...defaults, inline: true };
|
const inlineDefaults: Required<IconifyIconCustomisations> = {
|
||||||
|
...defaultExtendedIconCustomisations,
|
||||||
|
inline: true,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix size: add 'px' to numbers
|
* Fix size: add 'px' to numbers
|
||||||
@ -86,13 +91,12 @@ export const render = (
|
|||||||
ref?: IconRef
|
ref?: IconRef
|
||||||
): JSX.Element => {
|
): JSX.Element => {
|
||||||
// Get default properties
|
// Get default properties
|
||||||
const defaultProps = inline ? inlineDefaults : defaults;
|
const defaultProps = inline
|
||||||
|
? inlineDefaults
|
||||||
|
: defaultExtendedIconCustomisations;
|
||||||
|
|
||||||
// Get all customisations
|
// Get all customisations
|
||||||
const customisations = mergeCustomisations(
|
const customisations = mergeCustomisations(defaultProps, props);
|
||||||
defaultProps,
|
|
||||||
props as FullIconCustomisations
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check mode
|
// Check mode
|
||||||
const mode: IconifyRenderMode = props.mode || 'svg';
|
const mode: IconifyRenderMode = props.mode || 'svg';
|
||||||
@ -174,7 +178,7 @@ export const render = (
|
|||||||
const renderAttribs = item.attributes;
|
const renderAttribs = item.attributes;
|
||||||
|
|
||||||
// Inline display
|
// Inline display
|
||||||
if (item.inline) {
|
if (customisations.inline) {
|
||||||
style.verticalAlign = '-0.125em';
|
style.verticalAlign = '-0.125em';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
|||||||
// Core
|
// Core
|
||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconExists,
|
||||||
@ -19,7 +19,7 @@ import { buildIcon } from '@iconify/core/lib/builder/functions';
|
|||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import type {
|
import type {
|
||||||
@ -67,7 +67,6 @@ import type {
|
|||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
import type {
|
import type {
|
||||||
RawIconCustomisations,
|
|
||||||
IconProps,
|
IconProps,
|
||||||
IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
IconifyIconProps,
|
IconifyIconProps,
|
||||||
@ -117,7 +116,7 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Builder functions
|
// Builder functions
|
||||||
export { RawIconCustomisations, IconifyIconBuildResult };
|
export { IconifyIconBuildResult };
|
||||||
|
|
||||||
/* Browser cache */
|
/* Browser cache */
|
||||||
export { IconifyBrowserCacheType };
|
export { IconifyBrowserCacheType };
|
||||||
@ -275,7 +274,7 @@ export function checkIconState(
|
|||||||
// Stop loading
|
// Stop loading
|
||||||
state.name = '';
|
state.name = '';
|
||||||
abortLoading();
|
abortLoading();
|
||||||
return { data: fullIcon(icon) };
|
return { data: { ...defaultIconProps, ...icon } };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid icon?
|
// Invalid icon?
|
||||||
|
@ -37,7 +37,7 @@ export {
|
|||||||
} from './functions';
|
} from './functions';
|
||||||
|
|
||||||
// Builder functions
|
// Builder functions
|
||||||
export { RawIconCustomisations, IconifyIconBuildResult } from './functions';
|
export { IconifyIconBuildResult } from './functions';
|
||||||
|
|
||||||
// Browser cache
|
// Browser cache
|
||||||
export { IconifyBrowserCacheType } from './functions';
|
export { IconifyBrowserCacheType } from './functions';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
||||||
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';
|
||||||
import { render } from './render';
|
import { render } from './render';
|
||||||
@ -20,7 +20,7 @@ export function generateIcon(props: IconProps): RenderResult | null {
|
|||||||
typeof props.icon === 'string'
|
typeof props.icon === 'string'
|
||||||
? storage[props.icon]
|
? storage[props.icon]
|
||||||
: typeof props.icon === 'object'
|
: typeof props.icon === 'object'
|
||||||
? fullIcon(props.icon)
|
? { ...defaultIconProps, ...props.icon }
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Validate icon object
|
// Validate icon object
|
||||||
@ -42,7 +42,7 @@ export function generateIcon(props: IconProps): RenderResult | null {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function addIcon(name: string, data: IconifyIcon): void {
|
export function addIcon(name: string, data: IconifyIcon): void {
|
||||||
storage[name] = fullIcon(data);
|
storage[name] = { ...defaultIconProps, ...data };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Types
|
// Types
|
||||||
export type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
export type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||||
export type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
export type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
|
||||||
// Types from props.ts
|
// Types from props.ts
|
||||||
export type {
|
export type {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
export { RawIconCustomisations };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icon render mode
|
* Icon render mode
|
||||||
@ -13,12 +12,20 @@ export { RawIconCustomisations };
|
|||||||
*/
|
*/
|
||||||
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
||||||
|
|
||||||
// Allow rotation to be string
|
|
||||||
/**
|
/**
|
||||||
* Icon customisations
|
* Icon customisations
|
||||||
*/
|
*/
|
||||||
export type IconifyIconCustomisations = RawIconCustomisations & {
|
export type IconifyIconCustomisations = RawIconifyIconCustomisations & {
|
||||||
|
// Allow rotation to be string
|
||||||
rotate?: string | number;
|
rotate?: string | number;
|
||||||
|
|
||||||
|
// Inline mode
|
||||||
|
inline?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultExtendedIconCustomisations = {
|
||||||
|
...defaultIconCustomisations,
|
||||||
|
inline: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import {
|
import { mergeCustomisations } from '@iconify/utils/lib/customisations/merge';
|
||||||
defaults,
|
|
||||||
mergeCustomisations,
|
|
||||||
} from '@iconify/utils/lib/customisations';
|
|
||||||
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
||||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||||
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
||||||
@ -10,6 +7,7 @@ import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
|||||||
import { iconToHTML } from '@iconify/utils/lib/svg/html';
|
import { iconToHTML } from '@iconify/utils/lib/svg/html';
|
||||||
import { svgToURL } from '@iconify/utils/lib/svg/url';
|
import { svgToURL } from '@iconify/utils/lib/svg/url';
|
||||||
import type { IconProps, IconifyRenderMode } from './props';
|
import type { IconProps, IconifyRenderMode } from './props';
|
||||||
|
import { defaultExtendedIconCustomisations } from './props';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default SVG attributes
|
* Default SVG attributes
|
||||||
@ -85,8 +83,8 @@ export function render(
|
|||||||
props: IconProps
|
props: IconProps
|
||||||
): RenderResult {
|
): RenderResult {
|
||||||
const customisations = mergeCustomisations(
|
const customisations = mergeCustomisations(
|
||||||
defaults,
|
defaultExtendedIconCustomisations,
|
||||||
props as typeof defaults
|
props
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check mode
|
// Check mode
|
||||||
@ -163,7 +161,14 @@ export function render(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Copy missing property if it does not exist in customisations
|
// Copy missing property if it does not exist in customisations
|
||||||
if ((defaults as Record<string, unknown>)[key] === void 0) {
|
if (
|
||||||
|
(
|
||||||
|
defaultExtendedIconCustomisations as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
>
|
||||||
|
)[key] === void 0
|
||||||
|
) {
|
||||||
componentProps[key] = value;
|
componentProps[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +179,7 @@ export function render(
|
|||||||
const renderAttribs = item.attributes;
|
const renderAttribs = item.attributes;
|
||||||
|
|
||||||
// Inline display
|
// Inline display
|
||||||
if (item.inline) {
|
if (customisations.inline) {
|
||||||
// Style overrides it
|
// Style overrides it
|
||||||
style = 'vertical-align: -0.125em; ' + style;
|
style = 'vertical-align: -0.125em; ' + style;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ import {
|
|||||||
} from './observer/index';
|
} from './observer/index';
|
||||||
import type {
|
import type {
|
||||||
IconifyRenderMode,
|
IconifyRenderMode,
|
||||||
ExtendedIconifyIconCustomisations as IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
} from './scanner/config';
|
} from './scanner/config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ import {
|
|||||||
} from './observer/index';
|
} from './observer/index';
|
||||||
import type {
|
import type {
|
||||||
IconifyRenderMode,
|
IconifyRenderMode,
|
||||||
ExtendedIconifyIconCustomisations as IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
} from './scanner/config';
|
} from './scanner/config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import {
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
defaultIconCustomisations,
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
IconifyIconCustomisations,
|
|
||||||
} from '@iconify/utils/lib/customisations/defaults';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add inline to customisations
|
* Add inline to customisations
|
||||||
*/
|
*/
|
||||||
export interface ExtendedIconifyIconCustomisations
|
export interface IconifyIconCustomisations
|
||||||
extends IconifyIconCustomisations {
|
extends RawIconifyIconCustomisations {
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +42,7 @@ export interface IconifyElementProps {
|
|||||||
icon: IconifyIconName;
|
icon: IconifyIconName;
|
||||||
|
|
||||||
// Customisations
|
// Customisations
|
||||||
customisations: Required<ExtendedIconifyIconCustomisations>;
|
customisations: Required<IconifyIconCustomisations>;
|
||||||
|
|
||||||
// Render mode
|
// Render mode
|
||||||
mode?: IconifyRenderMode;
|
mode?: IconifyRenderMode;
|
||||||
|
@ -6,23 +6,17 @@ import {
|
|||||||
IconifyRenderMode,
|
IconifyRenderMode,
|
||||||
inlineClass,
|
inlineClass,
|
||||||
} from './config';
|
} from './config';
|
||||||
import type {
|
import type { IconifyElementProps, IconifyIconCustomisations } from './config';
|
||||||
IconifyElementProps,
|
|
||||||
ExtendedIconifyIconCustomisations,
|
|
||||||
} from './config';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Size attributes
|
* Size attributes
|
||||||
*/
|
*/
|
||||||
const sizeAttributes: (keyof ExtendedIconifyIconCustomisations)[] = [
|
const sizeAttributes: (keyof IconifyIconCustomisations)[] = ['width', 'height'];
|
||||||
'width',
|
|
||||||
'height',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean attributes
|
* Boolean attributes
|
||||||
*/
|
*/
|
||||||
const booleanAttributes: (keyof ExtendedIconifyIconCustomisations)[] = [
|
const booleanAttributes: (keyof IconifyIconCustomisations)[] = [
|
||||||
'inline',
|
'inline',
|
||||||
'hFlip',
|
'hFlip',
|
||||||
'vFlip',
|
'vFlip',
|
||||||
|
@ -13,7 +13,7 @@ import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
|||||||
// Core
|
// Core
|
||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconExists,
|
||||||
@ -29,7 +29,7 @@ import { buildIcon } from '@iconify/core/lib/builder/functions';
|
|||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import type {
|
import type {
|
||||||
@ -77,7 +77,6 @@ import type {
|
|||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
import type {
|
import type {
|
||||||
RawIconCustomisations,
|
|
||||||
IconifyIconOnLoad,
|
IconifyIconOnLoad,
|
||||||
IconProps,
|
IconProps,
|
||||||
IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
@ -128,7 +127,7 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Builder functions
|
// Builder functions
|
||||||
export { RawIconCustomisations, IconifyIconBuildResult };
|
export { IconifyIconBuildResult };
|
||||||
|
|
||||||
/* Browser cache */
|
/* Browser cache */
|
||||||
export { IconifyBrowserCacheType };
|
export { IconifyBrowserCacheType };
|
||||||
@ -226,9 +225,10 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
/**
|
/**
|
||||||
* Empty icon data, rendered when icon is not available
|
* Empty icon data, rendered when icon is not available
|
||||||
*/
|
*/
|
||||||
const emptyIcon = fullIcon({
|
const emptyIcon = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '',
|
body: '',
|
||||||
});
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component
|
* Component
|
||||||
@ -291,7 +291,7 @@ export const Icon = defineComponent({
|
|||||||
this._name = '';
|
this._name = '';
|
||||||
this.abortLoading();
|
this.abortLoading();
|
||||||
return {
|
return {
|
||||||
data: fullIcon(icon),
|
data: { ...defaultIconProps, ...icon },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ import type {
|
|||||||
ComponentCustomProps,
|
ComponentCustomProps,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/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';
|
||||||
import type {
|
import type {
|
||||||
@ -43,7 +43,7 @@ const storage: Record<string, Required<IconifyIcon>> = Object.create(null);
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function addIcon(name: string, data: IconifyIcon): void {
|
export function addIcon(name: string, data: IconifyIcon): void {
|
||||||
storage[name] = fullIcon(data);
|
storage[name] = { ...defaultIconProps, ...data };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +86,7 @@ export const Icon = defineComponent({
|
|||||||
typeof props.icon === 'string'
|
typeof props.icon === 'string'
|
||||||
? storage[props.icon]
|
? storage[props.icon]
|
||||||
: typeof props.icon === 'object'
|
: typeof props.icon === 'object'
|
||||||
? fullIcon(props.icon)
|
? { ...defaultIconProps, ...props.icon }
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Validate icon object
|
// Validate icon object
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
export { RawIconCustomisations };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Icon render mode
|
* Icon render mode
|
||||||
@ -13,12 +12,20 @@ export { RawIconCustomisations };
|
|||||||
*/
|
*/
|
||||||
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
||||||
|
|
||||||
// Allow rotation to be string
|
|
||||||
/**
|
/**
|
||||||
* Icon customisations
|
* Icon customisations
|
||||||
*/
|
*/
|
||||||
export type IconifyIconCustomisations = RawIconCustomisations & {
|
export type IconifyIconCustomisations = RawIconifyIconCustomisations & {
|
||||||
|
// Allow rotation to be string
|
||||||
rotate?: string | number;
|
rotate?: string | number;
|
||||||
|
|
||||||
|
// Inline mode
|
||||||
|
inline?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultExtendedIconCustomisations = {
|
||||||
|
...defaultIconCustomisations,
|
||||||
|
inline: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import { h } from 'vue';
|
import { h } from 'vue';
|
||||||
import type { VNode } from 'vue';
|
import type { VNode } from 'vue';
|
||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
import { mergeCustomisations } from '@iconify/utils/lib/customisations/merge';
|
||||||
import {
|
|
||||||
defaults,
|
|
||||||
mergeCustomisations,
|
|
||||||
} from '@iconify/utils/lib/customisations';
|
|
||||||
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
||||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||||
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
||||||
@ -17,6 +13,7 @@ import type {
|
|||||||
IconifyRenderMode,
|
IconifyRenderMode,
|
||||||
IconProps,
|
IconProps,
|
||||||
} from './props';
|
} from './props';
|
||||||
|
import { defaultExtendedIconCustomisations } from './props';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default SVG attributes
|
* Default SVG attributes
|
||||||
@ -102,9 +99,9 @@ export const render = (
|
|||||||
): VNode => {
|
): VNode => {
|
||||||
// Split properties
|
// Split properties
|
||||||
const customisations = mergeCustomisations(
|
const customisations = mergeCustomisations(
|
||||||
defaults,
|
defaultExtendedIconCustomisations,
|
||||||
props as IconifyIconCustomisations
|
props
|
||||||
) as FullIconCustomisations;
|
);
|
||||||
const componentProps = { ...svgDefaults };
|
const componentProps = { ...svgDefaults };
|
||||||
|
|
||||||
// Check mode
|
// Check mode
|
||||||
@ -177,7 +174,7 @@ export const render = (
|
|||||||
if (value === true || value === 'true' || value === 1) {
|
if (value === true || value === 'true' || value === 1) {
|
||||||
customisations[alias] = true;
|
customisations[alias] = true;
|
||||||
}
|
}
|
||||||
} else if (defaults[key] === void 0) {
|
} else if (defaultExtendedIconCustomisations[key] === void 0) {
|
||||||
// Copy missing property if it does not exist in customisations
|
// Copy missing property if it does not exist in customisations
|
||||||
componentProps[key] = value;
|
componentProps[key] = value;
|
||||||
}
|
}
|
||||||
@ -190,7 +187,7 @@ export const render = (
|
|||||||
const renderAttribs = item.attributes;
|
const renderAttribs = item.attributes;
|
||||||
|
|
||||||
// Inline display
|
// Inline display
|
||||||
if (item.inline) {
|
if (customisations.inline) {
|
||||||
style.verticalAlign = '-0.125em';
|
style.verticalAlign = '-0.125em';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
|||||||
// Core
|
// Core
|
||||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconExists,
|
||||||
@ -22,7 +22,7 @@ import { buildIcon } from '@iconify/core/lib/builder/functions';
|
|||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
|
|
||||||
// API
|
// API
|
||||||
import type {
|
import type {
|
||||||
@ -66,7 +66,6 @@ import type {
|
|||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
import type {
|
import type {
|
||||||
RawIconCustomisations,
|
|
||||||
IconifyIconOnLoad,
|
IconifyIconOnLoad,
|
||||||
IconProps,
|
IconProps,
|
||||||
IconifyIconCustomisations,
|
IconifyIconCustomisations,
|
||||||
@ -115,7 +114,7 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Builder functions
|
// Builder functions
|
||||||
export { RawIconCustomisations, IconifyIconBuildResult };
|
export { IconifyIconBuildResult };
|
||||||
|
|
||||||
/* Browser cache */
|
/* Browser cache */
|
||||||
export { IconifyBrowserCacheType };
|
export { IconifyBrowserCacheType };
|
||||||
@ -213,9 +212,10 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|||||||
/**
|
/**
|
||||||
* Empty icon data, rendered when icon is not available
|
* Empty icon data, rendered when icon is not available
|
||||||
*/
|
*/
|
||||||
const emptyIcon = fullIcon({
|
const emptyIcon = {
|
||||||
|
...defaultIconProps,
|
||||||
body: '',
|
body: '',
|
||||||
});
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component
|
* Component
|
||||||
@ -275,7 +275,7 @@ export const Icon = Vue.extend({
|
|||||||
this._name = '';
|
this._name = '';
|
||||||
this.abortLoading();
|
this.abortLoading();
|
||||||
return {
|
return {
|
||||||
data: fullIcon(icon),
|
data: {...defaultIconProps, ...icon},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ import Vue from 'vue';
|
|||||||
import type { CreateElement, VNode } from 'vue';
|
import type { CreateElement, VNode } from 'vue';
|
||||||
import type { ExtendedVue } from 'vue/types/vue';
|
import type { ExtendedVue } from 'vue/types/vue';
|
||||||
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/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';
|
||||||
import type {
|
import type {
|
||||||
@ -39,7 +39,7 @@ const storage: Record<string, Required<IconifyIcon>> = Object.create(null);
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function addIcon(name: string, data: IconifyIcon): void {
|
export function addIcon(name: string, data: IconifyIcon): void {
|
||||||
storage[name] = fullIcon(data);
|
storage[name] = {...defaultIconProps, ...data};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,7 @@ export const Icon = Vue.extend({
|
|||||||
typeof props.icon === 'string'
|
typeof props.icon === 'string'
|
||||||
? storage[props.icon]
|
? storage[props.icon]
|
||||||
: typeof props.icon === 'object'
|
: typeof props.icon === 'object'
|
||||||
? fullIcon(props.icon)
|
? {...defaultIconProps, ...props.icon}
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Validate icon object
|
// Validate icon object
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
||||||
|
|
||||||
export { RawIconCustomisations };
|
|
||||||
|
|
||||||
// Allow rotation to be string
|
|
||||||
/**
|
/**
|
||||||
* Icon customisations
|
* Icon customisations
|
||||||
*/
|
*/
|
||||||
export type IconifyIconCustomisations = RawIconCustomisations & {
|
export type IconifyIconCustomisations = RawIconifyIconCustomisations & {
|
||||||
|
// Allow rotation to be string
|
||||||
rotate?: string | number;
|
rotate?: string | number;
|
||||||
|
|
||||||
|
// Inline mode
|
||||||
|
inline?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultExtendedIconCustomisations = {
|
||||||
|
...defaultIconCustomisations,
|
||||||
|
inline: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
import type _Vue from 'vue';
|
import type _Vue from 'vue';
|
||||||
import type { VNode, VNodeData, RenderContext } from 'vue';
|
import type { VNode, VNodeData, RenderContext } from 'vue';
|
||||||
import type { IconifyIcon } from '@iconify/types';
|
import type { IconifyIcon } from '@iconify/types';
|
||||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
|
||||||
import {
|
import {
|
||||||
defaults,
|
|
||||||
mergeCustomisations,
|
mergeCustomisations,
|
||||||
} from '@iconify/utils/lib/customisations';
|
} from '@iconify/utils/lib/customisations/merge';
|
||||||
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
import { flipFromString } from '@iconify/utils/lib/customisations/flip';
|
||||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||||
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
||||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||||
import type { IconifyIconCustomisations, IconProps } from './props';
|
import type { IconifyIconCustomisations, IconProps } from './props';
|
||||||
|
import { defaultExtendedIconCustomisations } from './props';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default SVG attributes
|
* Default SVG attributes
|
||||||
@ -56,9 +55,9 @@ export const render = (
|
|||||||
): VNode => {
|
): VNode => {
|
||||||
// Split properties
|
// Split properties
|
||||||
const customisations = mergeCustomisations(
|
const customisations = mergeCustomisations(
|
||||||
defaults,
|
defaultExtendedIconCustomisations,
|
||||||
props as IconifyIconCustomisations
|
props
|
||||||
) as FullIconCustomisations;
|
);
|
||||||
const componentProps = { ...svgDefaults };
|
const componentProps = { ...svgDefaults };
|
||||||
|
|
||||||
// Style in Vue 2 components is always passed to rendered component, so no point in parsing it
|
// Style in Vue 2 components is always passed to rendered component, so no point in parsing it
|
||||||
@ -122,7 +121,7 @@ export const render = (
|
|||||||
if (value === true || value === 'true' || value === 1) {
|
if (value === true || value === 'true' || value === 1) {
|
||||||
customisations[alias] = true;
|
customisations[alias] = true;
|
||||||
}
|
}
|
||||||
} else if (defaults[key] === void 0) {
|
} else if (defaultExtendedIconCustomisations[key] === void 0) {
|
||||||
// Copy missing property if it does not exist in customisations
|
// Copy missing property if it does not exist in customisations
|
||||||
componentProps[key] = value;
|
componentProps[key] = value;
|
||||||
}
|
}
|
||||||
@ -137,7 +136,7 @@ export const render = (
|
|||||||
componentProps[key] = item.attributes[key];
|
componentProps[key] = item.attributes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.inline) {
|
if (customisations.inline) {
|
||||||
style.verticalAlign = '-0.125em';
|
style.verticalAlign = '-0.125em';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user