index.tsx 1.9 KB

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