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:
parent
a29b2bb493
commit
012942fed0
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user