packageDocumentation module import "./IconComponent.scss" ; import * as React from "react" ; import classnames from "classnames" ; import { ConditionalStringValue , IconSpecUtilities } from "@itwin/appui-abstract" ; import { SvgSprite } from "./SvgSprite" ; import { CommonProps } from "../utils/Props" ; public export type IconSpec = string | ConditionalStringValue | React . ReactNode ; public export interface IconProps extends CommonProps { /** CSS class name or SvgSprite/SvgPath for icon. This is optional because it is improperly
     * used to extend other interfaces and changing it would break existing API.
     */ iconSpec ? : IconSpec ; } public export function Icon ( props ) { if ( ! props . iconSpec ) return null ; const iconString = ( typeof props . iconSpec === "string" || props . iconSpec instanceof ConditionalStringValue ) ? ConditionalStringValue . getValue ( props . iconSpec ) : undefined ; if ( iconString ) { const svgSource = IconSpecUtilities . getSvgSource ( iconString ) ; if ( svgSource !== undefined ) return ( < i className = { classnames ( "icon" , "core-svg-icon" , props . className ) } style = { props . style } > < SvgSprite src = { svgSource } /> < /i>); return ( < i className = { classnames ( "icon" , iconString , props . className ) } style = { props . style } / > ) ; } return ( < i className = { classnames ( "icon" , "core-svg-icon" , props . className ) } style = { props . style } > { props . iconSpec } < /i>); }