2021-08-16 07:55:28 +00:00
|
|
|
import type { SVGProps, RefAttributes } from 'react';
|
2021-04-23 15:06:49 +00:00
|
|
|
import type { IconifyIcon } from '@iconify/types';
|
2022-06-19 16:16:11 +00:00
|
|
|
import type { IconifyIconCustomisations as RawIconifyIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
|
|
|
import { defaultIconCustomisations } from '@iconify/utils/lib/customisations/defaults';
|
2021-04-23 15:06:49 +00:00
|
|
|
|
2022-04-13 06:55:07 +00:00
|
|
|
/**
|
|
|
|
* Icon render mode
|
|
|
|
*
|
|
|
|
* 'style' = 'bg' or 'mask', depending on icon content
|
2022-04-30 15:23:38 +00:00
|
|
|
* 'bg' = <span> with style using `background`
|
|
|
|
* 'mask' = <span> with style using `mask`
|
|
|
|
* 'svg' = <svg>
|
2022-04-13 06:55:07 +00:00
|
|
|
*/
|
2022-04-30 15:23:38 +00:00
|
|
|
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
|
2022-04-13 06:55:07 +00:00
|
|
|
|
2021-04-23 15:06:49 +00:00
|
|
|
/**
|
|
|
|
* Icon customisations
|
|
|
|
*/
|
2022-06-19 16:16:11 +00:00
|
|
|
export type IconifyIconCustomisations = RawIconifyIconCustomisations & {
|
|
|
|
// Allow rotation to be string
|
2021-04-23 15:06:49 +00:00
|
|
|
rotate?: string | number;
|
2022-06-19 16:16:11 +00:00
|
|
|
|
|
|
|
// Inline mode
|
|
|
|
inline?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const defaultExtendedIconCustomisations = {
|
|
|
|
...defaultIconCustomisations,
|
|
|
|
inline: false,
|
2021-04-23 15:06:49 +00:00
|
|
|
};
|
|
|
|
|
2021-05-11 20:27:13 +00:00
|
|
|
/**
|
|
|
|
* Callback for when icon has been loaded (only triggered for icons loaded from API)
|
|
|
|
*/
|
|
|
|
export type IconifyIconOnLoad = (name: string) => void;
|
|
|
|
|
2021-04-23 15:06:49 +00:00
|
|
|
/**
|
|
|
|
* Icon properties
|
|
|
|
*/
|
|
|
|
export interface IconifyIconProps extends IconifyIconCustomisations {
|
|
|
|
// Icon object or icon name (must be added to storage using addIcon for offline package)
|
|
|
|
icon: IconifyIcon | string;
|
|
|
|
|
2022-04-13 06:55:07 +00:00
|
|
|
// Render mode
|
|
|
|
mode?: IconifyRenderMode;
|
|
|
|
|
2021-04-23 15:06:49 +00:00
|
|
|
// Style
|
|
|
|
color?: string;
|
|
|
|
|
2022-04-30 20:12:34 +00:00
|
|
|
// Flip shorthand
|
2021-04-23 15:06:49 +00:00
|
|
|
flip?: string;
|
|
|
|
|
|
|
|
// Unique id, used as base for ids for shapes. Use it to get consistent ids for server side rendering
|
|
|
|
id?: string;
|
2021-05-11 20:27:13 +00:00
|
|
|
|
|
|
|
// Callback to call when icon data has been loaded. Used only for icons loaded from API
|
|
|
|
onLoad?: IconifyIconOnLoad;
|
2021-04-23 15:06:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component properties: generic element for Icon component, SVG for generated component
|
|
|
|
*/
|
2021-08-16 07:55:28 +00:00
|
|
|
type IconifyElementProps = SVGProps<SVGSVGElement>;
|
2021-04-23 15:06:49 +00:00
|
|
|
|
2021-08-16 02:04:15 +00:00
|
|
|
export type IconRef = RefAttributes<SVGSVGElement>;
|
2021-04-23 15:06:49 +00:00
|
|
|
|
|
|
|
export interface ReactRefProp {
|
|
|
|
ref?: IconRef;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-16 02:04:15 +00:00
|
|
|
* Mix of icon properties and SVGSVGElement properties
|
2021-04-23 15:06:49 +00:00
|
|
|
*/
|
|
|
|
export type IconProps = IconifyElementProps & IconifyIconProps & ReactRefProp;
|