mirror of
https://github.com/iconify/iconify.git
synced 2025-01-07 07:34:22 +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
|
* Get icon data with all properties
|
||||||
*/
|
*/
|
||||||
getIcon: (name: string) => IconifyIcon | null;
|
getIcon: (name: string) => Required<IconifyIcon> | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all available icons
|
* List all available icons
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
} from '@iconify/core/lib/customisations';
|
} from '@iconify/core/lib/customisations';
|
||||||
import {
|
import {
|
||||||
getStorage,
|
getStorage,
|
||||||
getIcon,
|
getIcon as _getIcon,
|
||||||
addIcon as addIconToStorage,
|
addIcon as addIconToStorage,
|
||||||
addIconSet,
|
addIconSet,
|
||||||
listIcons,
|
listIcons,
|
||||||
@ -169,10 +169,10 @@ function _getIconName(name: string): IconifyIconName | null {
|
|||||||
* Get icon data
|
* Get icon data
|
||||||
*/
|
*/
|
||||||
function _getIconData(icon: IconifyIconName): FullIconifyIcon | null {
|
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);
|
const icon = _getIconName(name);
|
||||||
return icon ? _getIconData(icon) : null;
|
return icon ? _getIconData(icon) : null;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ function getIconData(name: string): FullIconifyIcon | null {
|
|||||||
* Check if icon exists
|
* Check if icon exists
|
||||||
*/
|
*/
|
||||||
export function iconExists(name: string): boolean {
|
export function iconExists(name: string): boolean {
|
||||||
return getIconData(name) !== null;
|
return getIcon(name) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user