index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use client'
  2. import cn from 'classnames'
  3. import { useTranslation } from 'react-i18next'
  4. import { PlusIcon } from '@heroicons/react/20/solid'
  5. import Button from '../../base/button'
  6. import s from './style.module.css'
  7. import type { App } from '@/models/explore'
  8. import AppModeLabel from '@/app/(commonLayout)/apps/AppModeLabel'
  9. import AppIcon from '@/app/components/base/app-icon'
  10. export type AppCardProps = {
  11. app: App
  12. canCreate: boolean
  13. onCreate: () => void
  14. }
  15. const AppCard = ({
  16. app,
  17. canCreate,
  18. onCreate,
  19. }: AppCardProps) => {
  20. const { t } = useTranslation()
  21. const { app: appBasicInfo, is_agent } = app
  22. return (
  23. <div className={cn(s.wrap, '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')}>
  24. <div className='flex pt-[14px] px-[14px] pb-3 h-[66px] items-center gap-3 grow-0 shrink-0'>
  25. <AppIcon size='small' icon={app.app.icon} background={app.app.icon_background} />
  26. <div className='relative h-8 text-sm font-medium leading-8 grow'>
  27. <div className='absolute top-0 left-0 w-full h-full overflow-hidden text-ellipsis whitespace-nowrap'>{appBasicInfo.name}</div>
  28. </div>
  29. </div>
  30. <div className='mb-3 px-[14px] h-9 text-xs leading-normal text-gray-500 line-clamp-2'>{app.description}</div>
  31. <div className='flex items-center flex-wrap min-h-[42px] px-[14px] pt-2 pb-[10px]'>
  32. <div className={s.mode}>
  33. <AppModeLabel mode={appBasicInfo.mode} isAgent={is_agent} />
  34. </div>
  35. {
  36. canCreate && (
  37. <div className={cn(s.opWrap, 'flex items-center w-full space-x-2')}>
  38. <Button type='primary' className='grow flex items-center !h-7' onClick={() => onCreate()}>
  39. <PlusIcon className='w-4 h-4 mr-1' />
  40. <span className='text-xs'>{t('explore.appCard.addToWorkspace')}</span>
  41. </Button>
  42. </div>
  43. )
  44. }
  45. </div>
  46. </div>
  47. )
  48. }
  49. export default AppCard