mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
fec607db81
Co-authored-by: Gillian97 <jinling.sunshine@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com>
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
'use client'
|
|
import type { FC, ReactNode } from 'react'
|
|
import React from 'react'
|
|
import cn from 'classnames'
|
|
import { useTranslation } from 'react-i18next'
|
|
import s from './style.module.css'
|
|
import { StarIcon } from '@/app/components/share/chatbot/welcome/massive-component'
|
|
import Button from '@/app/components/base/button'
|
|
|
|
export type ITemplateVarPanelProps = {
|
|
className?: string
|
|
header: ReactNode
|
|
children?: ReactNode | null
|
|
isFold: boolean
|
|
}
|
|
|
|
const TemplateVarPanel: FC<ITemplateVarPanelProps> = ({
|
|
className,
|
|
header,
|
|
children,
|
|
isFold,
|
|
}) => {
|
|
return (
|
|
<div className={cn(isFold ? 'border border-indigo-100' : s.boxShodow, className, 'rounded-xl ')}>
|
|
{/* header */}
|
|
<div
|
|
className={cn(isFold && 'rounded-b-xl', 'rounded-t-xl px-6 py-4 bg-indigo-25 text-xs')}
|
|
>
|
|
{header}
|
|
</div>
|
|
{/* body */}
|
|
{!isFold && children && (
|
|
<div className='rounded-b-xl p-6'>
|
|
{children}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const PanelTitle: FC<{ title: string; className?: string }> = ({
|
|
title,
|
|
className,
|
|
}) => {
|
|
return (
|
|
<div className={cn(className, 'flex items-center space-x-1 text-indigo-600')}>
|
|
<StarIcon />
|
|
<span className='text-xs'>{title}</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const VarOpBtnGroup: FC<{ className?: string; onConfirm: () => void; onCancel: () => void }> = ({
|
|
className,
|
|
onConfirm,
|
|
onCancel,
|
|
}) => {
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
|
<div className={cn(className, 'flex mt-3 space-x-2 mobile:ml-0 tablet:ml-[128px] text-sm')}>
|
|
<Button
|
|
className='text-sm'
|
|
type='primary'
|
|
onClick={onConfirm}
|
|
>
|
|
{t('common.operation.save')}
|
|
</Button>
|
|
<Button
|
|
className='text-sm'
|
|
onClick={onCancel}
|
|
>
|
|
{t('common.operation.cancel')}
|
|
</Button>
|
|
</div >
|
|
)
|
|
}
|
|
|
|
export default React.memo(TemplateVarPanel)
|