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.

tool-item.tsx 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import type { PluginDetail } from '@/app/components/plugins/types'
  5. import Icon from '@/app/components/plugins/card/base/card-icon'
  6. import { renderI18nObject } from '@/i18n-config'
  7. import { useGetLanguage } from '@/context/i18n'
  8. import { MARKETPLACE_API_PREFIX } from '@/config'
  9. import Checkbox from '@/app/components/base/checkbox'
  10. type Props = {
  11. payload: PluginDetail
  12. isChecked?: boolean
  13. onCheckChange: () => void
  14. }
  15. const ToolItem: FC<Props> = ({
  16. payload,
  17. isChecked,
  18. onCheckChange,
  19. }) => {
  20. const language = useGetLanguage()
  21. const { plugin_id, declaration } = payload
  22. const { label, author: org } = declaration
  23. return (
  24. <div className='p-1'>
  25. <div
  26. className='flex w-full select-none items-center rounded-lg pr-2 hover:bg-state-base-hover'
  27. >
  28. <div className='flex h-8 grow items-center space-x-2 pl-3 pr-2'>
  29. <Icon size='tiny' src={`${MARKETPLACE_API_PREFIX}/plugins/${plugin_id}/icon`} />
  30. <div className='system-sm-medium max-w-[150px] shrink-0 truncate text-text-primary'>{renderI18nObject(label, language)}</div>
  31. <div className='system-xs-regular max-w-[150px] shrink-0 truncate text-text-quaternary'>{org}</div>
  32. </div>
  33. <Checkbox
  34. checked={isChecked}
  35. onCheck={onCheckChange}
  36. className='shrink-0'
  37. />
  38. </div>
  39. </div>
  40. )
  41. }
  42. export default React.memo(ToolItem)