/********************************************************************* * © Copyright IBM Corp. 2024 *********************************************************************/ import React from 'react' import PropTypes from 'prop-types' import {IconsGeneralColor} from '@targetprocess/css-variables' export const Sizes = { DEFAULT: 'default', BIG: 'big' } as const export const Types = { DEFAULT: 'default', CROSSOUT: 'crossout' } as const const sizeToParams = { [Sizes.DEFAULT]: {numericSize: 16}, [Sizes.BIG]: {numericSize: 48} } export const TeamIcon = ({ size = Sizes.DEFAULT as typeof Sizes[keyof typeof Sizes], type = Types.DEFAULT as typeof Types[keyof typeof Types], color = IconsGeneralColor }) => { const {numericSize} = sizeToParams.hasOwnProperty(size) ? // hasOwnProperty explicitly checked here // eslint-disable-next-line security/detect-object-injection sizeToParams[size] : sizeToParams[Sizes.DEFAULT] return ( {type === Types.DEFAULT && ( )} {type === Types.CROSSOUT && ( )} ) } TeamIcon.category = 'Entity' TeamIcon.propTypes = { color: PropTypes.string, // Object.keys used here // eslint-disable-next-line security/detect-object-injection size: PropTypes.oneOf(Object.keys(Sizes).map(key => Sizes[key])) } TeamIcon.Sizes = Sizes TeamIcon.Types = Types