import React from "react"; import { CarbonIconProps, CarbonIconType } from "@carbon/react/icons"; import { IntentTypes } from "../../common/Intent"; import { CLASSPREFIX as eccgui } from "../../configuration/constants"; import Tooltip, { TooltipProps } from "./../Tooltip/Tooltip"; export interface BaseIconProps extends Omit { /** * Carbon icon component that is used. */ iconComponent: CarbonIconType; /** * Add tooltip text to icon */ tooltipText?: string; /** * Intent state of icon. * Currently only `success`, `info`, `warning` and `danger` are implemented for icons, even there are more states available. */ intent?: IntentTypes; /** * Display large icon version. */ large?: boolean; /** * Display small icon version. */ small?: boolean; /** * Additional CSS classes. */ className?: string; /** * Additonal tooltip properties, e.g. `hoverOpenDelay`. */ tooltipProps?: Partial>; } /** * The base icon provides the basic functionality that is necessary to wrap the Carbon icon component. */ function BaseIcon({ iconComponent, className = "", large = false, small = false, tooltipText, tooltipProps, intent, tabIndex, ...restProps }: BaseIconProps) { let sizeConfig = { height: 20, width: 20, size: 20 }; if (small) sizeConfig = { height: 16, width: 16, size: 16 }; if (large) sizeConfig = { height: 32, width: 32, size: 32 }; const CarbonIconNamed = iconComponent; const icon = ( ); return tooltipText ? ( {icon} ) : ( icon ); } export default BaseIcon;