Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/ui / src / components / atoms / Icons / Icons.tsx
Size: Mime:
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