index.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. 'use client'
  2. import type { FC, ReactNode } from 'react'
  3. import React from 'react'
  4. import cn from 'classnames'
  5. import { useTranslation } from 'react-i18next'
  6. import s from './style.module.css'
  7. import { StarIcon } from '@/app/components/share/chatbot/welcome/massive-component'
  8. import Button from '@/app/components/base/button'
  9. export type ITemplateVarPanelProps = {
  10. className?: string
  11. header: ReactNode
  12. children?: ReactNode | null
  13. isFold: boolean
  14. }
  15. const TemplateVarPanel: FC<ITemplateVarPanelProps> = ({
  16. className,
  17. header,
  18. children,
  19. isFold,
  20. }) => {
  21. return (
  22. <div className={cn(isFold ? 'border border-indigo-100' : s.boxShodow, className, 'rounded-xl ')}>
  23. {/* header */}
  24. <div
  25. className={cn(isFold && 'rounded-b-xl', 'rounded-t-xl px-6 py-4 bg-indigo-25 text-xs')}
  26. >
  27. {header}
  28. </div>
  29. {/* body */}
  30. {!isFold && children && (
  31. <div className='rounded-b-xl p-6'>
  32. {children}
  33. </div>
  34. )}
  35. </div>
  36. )
  37. }
  38. export const PanelTitle: FC<{ title: string; className?: string }> = ({
  39. title,
  40. className,
  41. }) => {
  42. return (
  43. <div className={cn(className, 'flex items-center space-x-1 text-indigo-600')}>
  44. <StarIcon />
  45. <span className='text-xs'>{title}</span>
  46. </div>
  47. )
  48. }
  49. export const VarOpBtnGroup: FC<{ className?: string; onConfirm: () => void; onCancel: () => void }> = ({
  50. className,
  51. onConfirm,
  52. onCancel,
  53. }) => {
  54. const { t } = useTranslation()
  55. return (
  56. <div className={cn(className, 'flex mt-3 space-x-2 mobile:ml-0 tablet:ml-[128px] text-sm')}>
  57. <Button
  58. className='text-sm'
  59. type='primary'
  60. onClick={onConfirm}
  61. >
  62. {t('common.operation.save')}
  63. </Button>
  64. <Button
  65. className='text-sm'
  66. onClick={onCancel}
  67. >
  68. {t('common.operation.cancel')}
  69. </Button>
  70. </div >
  71. )
  72. }
  73. export default React.memo(TemplateVarPanel)