2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 21:57:50 +00:00

Consistent implementation of getIcon: fix return type in SVG framework, add function to React component

This commit is contained in:
Vjacheslav Trushkin 2020-11-21 13:00:15 +02:00
parent a29b2bb493
commit 012942fed0
2 changed files with 5 additions and 5 deletions

View File

@ -150,7 +150,7 @@ export interface IconifyGlobal {
/**
* Get icon data with all properties
*/
getIcon: (name: string) => IconifyIcon | null;
getIcon: (name: string) => Required<IconifyIcon> | null;
/**
* List all available icons

View File

@ -22,7 +22,7 @@ import {
} from '@iconify/core/lib/customisations';
import {
getStorage,
getIcon,
getIcon as _getIcon,
addIcon as addIconToStorage,
addIconSet,
listIcons,
@ -169,10 +169,10 @@ function _getIconName(name: string): IconifyIconName | null {
* Get icon data
*/
function _getIconData(icon: IconifyIconName): FullIconifyIcon | null {
return getIcon(getStorage(icon.provider, icon.prefix), icon.name);
return _getIcon(getStorage(icon.provider, icon.prefix), icon.name);
}
function getIconData(name: string): FullIconifyIcon | null {
export function getIcon(name: string): Required<IconifyIcon> | null {
const icon = _getIconName(name);
return icon ? _getIconData(icon) : null;
}
@ -181,7 +181,7 @@ function getIconData(name: string): FullIconifyIcon | null {
* Check if icon exists
*/
export function iconExists(name: string): boolean {
return getIconData(name) !== null;
return getIcon(name) !== null;
}
/**