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.

index.tsx 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use client'
  2. import cn from 'classnames'
  3. import { useTranslation } from 'react-i18next'
  4. import { App } from '@/models/explore'
  5. import AppModeLabel from '@/app/(commonLayout)/apps/AppModeLabel'
  6. import AppIcon from '@/app/components/base/app-icon'
  7. import { PlusIcon } from '@heroicons/react/20/solid'
  8. import Button from '../../base/button'
  9. import s from './style.module.css'
  10. const CustomizeBtn = (
  11. <svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">
  12. <path d="M7.5 2.33366C6.69458 2.33366 6.04167 2.98658 6.04167 3.79199C6.04167 4.59741 6.69458 5.25033 7.5 5.25033C8.30542 5.25033 8.95833 4.59741 8.95833 3.79199C8.95833 2.98658 8.30542 2.33366 7.5 2.33366ZM7.5 2.33366V1.16699M12.75 8.71385C11.4673 10.1671 9.59071 11.0837 7.5 11.0837C5.40929 11.0837 3.53265 10.1671 2.25 8.71385M6.76782 5.05298L2.25 12.8337M8.23218 5.05298L12.75 12.8337" stroke="#344054" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
  13. </svg>
  14. )
  15. export type AppCardProps = {
  16. app: App,
  17. canCreate: boolean,
  18. onCreate: () => void,
  19. onAddToWorkspace: (appId: string) => void,
  20. }
  21. const AppCard = ({
  22. app,
  23. canCreate,
  24. onCreate,
  25. onAddToWorkspace,
  26. }: AppCardProps) => {
  27. const { t } = useTranslation()
  28. const {app: appBasicInfo} = app
  29. return (
  30. <div className={s.wrap}>
  31. <div className='col-span-1 bg-white border-2 border-solid border-transparent rounded-lg shadow-sm min-h-[160px] flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg'>
  32. <div className='flex pt-[14px] px-[14px] pb-3 h-[66px] items-center gap-3 grow-0 shrink-0'>
  33. <AppIcon size='small' icon={app.app.icon} background={app.app.icon_background} />
  34. <div className='relative h-8 text-sm font-medium leading-8 grow'>
  35. <div className='absolute top-0 left-0 w-full h-full overflow-hidden text-ellipsis whitespace-nowrap'>{appBasicInfo.name}</div>
  36. </div>
  37. </div>
  38. <div className='mb-3 px-[14px] h-9 text-xs leading-normal text-gray-500 line-clamp-2'>{app.description}</div>
  39. <div className='flex items-center flex-wrap min-h-[42px] px-[14px] pt-2 pb-[10px]'>
  40. <div className={s.mode}>
  41. <AppModeLabel mode={appBasicInfo.mode} />
  42. </div>
  43. <div className={cn(s.opWrap, 'flex items-center w-full space-x-2')}>
  44. <Button type='primary' className='grow flex items-center !h-7' onClick={() => onAddToWorkspace(appBasicInfo.id)}>
  45. <PlusIcon className='w-4 h-4 mr-1' />
  46. <span className='text-xs'>{t('explore.appCard.addToWorkspace')}</span>
  47. </Button>
  48. {canCreate && (
  49. <Button className='grow flex items-center !h-7 space-x-1' onClick={onCreate}>
  50. {CustomizeBtn}
  51. <span className='text-xs'>{t('explore.appCard.customize')}</span>
  52. </Button>
  53. )}
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. )
  59. }
  60. export default AppCard