2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-07 15:44:05 +00:00

Split defaultIconData in utils in 2 objects

This commit is contained in:
Vjacheslav Trushkin 2022-06-18 21:58:26 +03:00
parent b18e9b7f52
commit 99ddeeae47
3 changed files with 33 additions and 10 deletions

View File

@ -1,4 +1,9 @@
import type { IconifyOptional, IconifyIcon } from '@iconify/types'; import type {
IconifyDimenisons,
IconifyTransformations,
IconifyOptional,
IconifyIcon,
} from '@iconify/types';
// Export icon and full icon types // Export icon and full icon types
export { IconifyIcon }; export { IconifyIcon };
@ -9,17 +14,34 @@ export type FullIconifyIcon = Required<IconifyIcon>;
*/ */
export const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/; export const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
/**
* Default values for dimensions
*/
export const defaultIconDimensions: Required<IconifyDimenisons> = Object.freeze(
{
left: 0,
top: 0,
width: 16,
height: 16,
}
);
/**
* Default values for transformations
*/
export const defaultIconTransformations: Required<IconifyTransformations> =
Object.freeze({
rotate: 0,
vFlip: false,
hFlip: false,
});
/** /**
* Default values for all optional IconifyIcon properties * Default values for all optional IconifyIcon properties
*/ */
export const iconDefaults: Required<IconifyOptional> = Object.freeze({ export const iconDefaults: Required<IconifyOptional> = Object.freeze({
left: 0, ...defaultIconDimensions,
top: 0, ...defaultIconTransformations,
width: 16,
height: 16,
rotate: 0,
vFlip: false,
hFlip: false,
}); });
/** /**

View File

@ -1,11 +1,10 @@
import type { IconifyOptional } from '@iconify/types'; import type { IconifyOptional } from '@iconify/types';
import type { FullIconifyIcon, IconifyIcon } from './index';
import { iconDefaults } from './index'; import { iconDefaults } from './index';
/** /**
* Merge icon and alias * Merge icon and alias
*/ */
export function mergeIconData<T extends IconifyIcon | FullIconifyIcon>( export function mergeIconData<T extends IconifyOptional>(
icon: T, icon: T,
alias: IconifyOptional alias: IconifyOptional
): T { ): T {

View File

@ -19,6 +19,8 @@ export { mergeIconData } from './icon/merge';
export { export {
iconDefaults as defaultIconData, iconDefaults as defaultIconData,
fullIcon as fullIconData, fullIcon as fullIconData,
defaultIconDimensions,
defaultIconTransformations,
} from './icon/index'; } from './icon/index';
// Icon set functions // Icon set functions