index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. variant='primary'
  59. onClick={onConfirm}
  60. >
  61. {t('common.operation.save')}
  62. </Button>
  63. <Button
  64. onClick={onCancel}
  65. >
  66. {t('common.operation.cancel')}
  67. </Button>
  68. </div >
  69. )
  70. }
  71. export default React.memo(TemplateVarPanel)