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.

datasource-icon.tsx 873B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { FC } from 'react'
  2. import { memo } from 'react'
  3. import cn from '@/utils/classnames'
  4. type DatasourceIconProps = {
  5. size?: string
  6. className?: string
  7. iconUrl: string
  8. }
  9. const ICON_CONTAINER_CLASSNAME_SIZE_MAP: Record<string, string> = {
  10. xs: 'w-4 h-4 rounded-[5px] shadow-xs',
  11. sm: 'w-5 h-5 rounded-md shadow-xs',
  12. md: 'w-6 h-6 rounded-lg shadow-md',
  13. }
  14. const DatasourceIcon: FC<DatasourceIconProps> = ({
  15. size = 'sm',
  16. className,
  17. iconUrl,
  18. }) => {
  19. return (
  20. <div className={
  21. cn(
  22. 'flex items-center justify-center shadow-none',
  23. ICON_CONTAINER_CLASSNAME_SIZE_MAP[size],
  24. className,
  25. )}
  26. >
  27. <div
  28. className='h-full w-full shrink-0 rounded-md bg-cover bg-center'
  29. style={{
  30. backgroundImage: `url(${iconUrl})`,
  31. }}
  32. />
  33. </div>
  34. )
  35. }
  36. export default memo(DatasourceIcon)