Repository URL to install this package:
|
Version:
3.0.10 ▾
|
import React from 'react'
import { MaterialIcon } from 'atoms/MaterialIcon'
import BarcodeIcon from './BarcodeIcon'
import FlagIcon from './FlagIcon'
import LogoIcon from './LogoIcon'
import PasswordIcon from './PasswordIcon'
import PaymentsCardIcon from './PaymentsCardIcon'
import PlusMinusIcon from './PlusMinusIcon'
import SocialIcon from './SocialIcon'
import SwitchIcon from './SwitchIcon'
// Main component properties
interface Props {
breedType: string
}
// main component states
interface States {}
class ErrorAtom extends React.PureComponent {
render() {
return '@@missing'
}
}
// returning breed based on the breedType
function fromBreedToComponent(breedType: string) {
switch (breedType) {
case 'barcode':
return BarcodeIcon
case 'flag':
return FlagIcon
case 'logo':
return LogoIcon
case 'password':
return PasswordIcon
case 'payments-card':
return PaymentsCardIcon
case 'social-icon':
return SocialIcon
case 'switch':
return SwitchIcon
default:
console.log('-- breedType: ', breedType)
return undefined
}
}
// main component class object
class Icons extends React.PureComponent<Props, States> {
static defaultProps = {
breedType: '',
}
render() {
const { breedType, ...remainingProps } = this.props
const Component = fromBreedToComponent(breedType)
return Component ? (
<Component {...remainingProps} />
) : (
<MaterialIcon type={breedType} />
)
}
}
export {
Icons,
FlagIcon,
LogoIcon,
PasswordIcon,
PaymentsCardIcon,
SocialIcon,
SwitchIcon,
PlusMinusIcon,
}
export default Icons