You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IconCard.tsx 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React, { useCallback } from 'react'
  2. import { Typography } from 'antd';
  3. import { BankFilled, WalletFilled } from '@ant-design/icons';
  4. const { Text } = Typography
  5. type IconCardProps = {
  6. active: boolean;
  7. iconName: string;
  8. text: string;
  9. handleClick: () => void
  10. }
  11. const IconCard: React.FC<IconCardProps> = ({ active, iconName, text, handleClick }: IconCardProps) => {
  12. const renderIcon = useCallback((nameId: string) => {
  13. if (nameId === "card") return <WalletFilled className='!text-white !text-xl' />
  14. else if (nameId === "bank") return <BankFilled className='!text-white !text-xl' />
  15. else return <></>
  16. }, [])
  17. return (
  18. <div
  19. onClick={handleClick}
  20. className={`
  21. ${active ? 'bg-blue-950' : 'bg-gray-400'}
  22. hover:bg-blue-950 transition-all ease-in-out
  23. rounded-lg p-4 max-w-[160px] cursor-pointer
  24. `}
  25. >
  26. {renderIcon(iconName)}
  27. <Text className='!text-xs !text-white !block'>{text}</Text>
  28. </div>
  29. )
  30. }
  31. export default IconCard