Просмотр исходного кода

feat: feature support UI preview (#269)

tags/0.3.2
Joel 2 лет назад
Родитель
Сommit
554570dc22
Аккаунт пользователя с таким Email не найден

+ 14
- 4
web/app/components/app/configuration/config/feature/choose-feature/feature-item/index.tsx Просмотреть файл

'use client' 'use client'
import React, { FC } from 'react'
import type { FC } from 'react'
import React from 'react'
import cn from 'classnames'
import s from './style.module.css'
import Switch from '@/app/components/base/switch' import Switch from '@/app/components/base/switch'


export interface IFeatureItemProps {
export type IFeatureItemProps = {
icon: React.ReactNode icon: React.ReactNode
previewImgClassName?: string
title: string title: string
description: string description: string
value: boolean value: boolean


const FeatureItem: FC<IFeatureItemProps> = ({ const FeatureItem: FC<IFeatureItemProps> = ({
icon, icon,
previewImgClassName,
title, title,
description, description,
value, value,
onChange
onChange,
}) => { }) => {
return ( return (
<div className='flex justify-between p-3 rounded-xl border border-transparent bg-gray-50 hover:border-gray-200 cursor-pointer'>
<div className={cn(s.wrap, 'relative flex justify-between p-3 rounded-xl border border-transparent bg-gray-50 hover:border-gray-200 cursor-pointer')}>
<div className='flex space-x-3 mr-2'> <div className='flex space-x-3 mr-2'>
{/* icon */} {/* icon */}
<div <div
</div> </div>


<Switch onChange={onChange} defaultValue={value} /> <Switch onChange={onChange} defaultValue={value} />
{
previewImgClassName && (
<div className={cn(s.preview, s[previewImgClassName])}>
</div>)
}
</div> </div>
) )
} }

+ 188
- 0
web/app/components/app/configuration/config/feature/choose-feature/feature-item/preview-imgs/more-like-this.svg
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 144
- 0
web/app/components/app/configuration/config/feature/choose-feature/feature-item/preview-imgs/opening-statement.svg
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 163
- 0
web/app/components/app/configuration/config/feature/choose-feature/feature-item/preview-imgs/suggested-questions-after-answer.svg
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 25
- 0
web/app/components/app/configuration/config/feature/choose-feature/feature-item/style.module.css Просмотреть файл

.preview {
display: none;
position: fixed;
transform: translate(410px, -54px);
width: 280px;
height: 360px;
background: center center no-repeat;
background-size: contain;
}

.wrap:hover .preview {
display: block;
}

.openingStatementPreview {
background-image: url(./preview-imgs/opening-statement.svg);
}

.suggestedQuestionsAfterAnswerPreview {
background-image: url(./preview-imgs/suggested-questions-after-answer.svg);
}

.moreLikeThisPreview {
background-image: url(./preview-imgs/more-like-this.svg);
}

+ 14
- 10
web/app/components/app/configuration/config/feature/choose-feature/index.tsx Просмотреть файл

'use client' 'use client'
import React, { FC } from 'react'
import type { FC } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Modal from '@/app/components/base/modal'
import FeatureItem from './feature-item'
import FeatureGroup from '../feature-group' import FeatureGroup from '../feature-group'
import MoreLikeThisIcon from '../../../base/icons/more-like-this-icon' import MoreLikeThisIcon from '../../../base/icons/more-like-this-icon'
import FeatureItem from './feature-item'
import Modal from '@/app/components/base/modal'
import SuggestedQuestionsAfterAnswerIcon from '@/app/components/app/configuration/base/icons/suggested-questions-after-answer-icon' import SuggestedQuestionsAfterAnswerIcon from '@/app/components/app/configuration/base/icons/suggested-questions-after-answer-icon'

interface IConfig {
type IConfig = {
openingStatement: boolean openingStatement: boolean
moreLikeThis: boolean moreLikeThis: boolean
suggestedQuestionsAfterAnswer: boolean suggestedQuestionsAfterAnswer: boolean
} }


export interface IChooseFeatureProps {
export type IChooseFeatureProps = {
isShow: boolean isShow: boolean
onClose: () => void onClose: () => void
config: IConfig config: IConfig
onClose, onClose,
isChatApp, isChatApp,
config, config,
onChange
onChange,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()


className='w-[400px]' className='w-[400px]'
title={t('appDebug.operation.addFeature')} title={t('appDebug.operation.addFeature')}
closable closable
overflowVisible
> >
<div className='pt-5 pb-10'> <div className='pt-5 pb-10'>
{/* Chat Feature */} {/* Chat Feature */}
<> <>
<FeatureItem <FeatureItem
icon={OpeningStatementIcon} icon={OpeningStatementIcon}
previewImgClassName='openingStatementPreview'
title={t('appDebug.feature.conversationOpener.title')} title={t('appDebug.feature.conversationOpener.title')}
description={t('appDebug.feature.conversationOpener.description')} description={t('appDebug.feature.conversationOpener.description')}
value={config.openingStatement} value={config.openingStatement}
onChange={(value) => onChange('openingStatement', value)}
onChange={value => onChange('openingStatement', value)}
/> />
<FeatureItem <FeatureItem
icon={<SuggestedQuestionsAfterAnswerIcon />} icon={<SuggestedQuestionsAfterAnswerIcon />}
previewImgClassName='suggestedQuestionsAfterAnswerPreview'
title={t('appDebug.feature.suggestedQuestionsAfterAnswer.title')} title={t('appDebug.feature.suggestedQuestionsAfterAnswer.title')}
description={t('appDebug.feature.suggestedQuestionsAfterAnswer.description')} description={t('appDebug.feature.suggestedQuestionsAfterAnswer.description')}
value={config.suggestedQuestionsAfterAnswer} value={config.suggestedQuestionsAfterAnswer}
onChange={(value) => onChange('suggestedQuestionsAfterAnswer', value)}
onChange={value => onChange('suggestedQuestionsAfterAnswer', value)}
/> />
</> </>
</FeatureGroup> </FeatureGroup>
<> <>
<FeatureItem <FeatureItem
icon={<MoreLikeThisIcon />} icon={<MoreLikeThisIcon />}
previewImgClassName='moreLikeThisPreview'
title={t('appDebug.feature.moreLikeThis.title')} title={t('appDebug.feature.moreLikeThis.title')}
description={t('appDebug.feature.moreLikeThis.description')} description={t('appDebug.feature.moreLikeThis.description')}
value={config.moreLikeThis} value={config.moreLikeThis}
onChange={(value) => onChange('moreLikeThis', value)}
onChange={value => onChange('moreLikeThis', value)}
/> />
</> </>
</FeatureGroup> </FeatureGroup>

+ 3
- 1
web/app/components/base/modal/index.tsx Просмотреть файл

description?: React.ReactNode description?: React.ReactNode
children: React.ReactNode children: React.ReactNode
closable?: boolean closable?: boolean
overflowVisible?: boolean
} }


export default function Modal({ export default function Modal({
description, description,
children, children,
closable = false, closable = false,
overflowVisible = false,
}: IModal) { }: IModal) {
return ( return (
<Transition appear show={isShow} as={Fragment}> <Transition appear show={isShow} as={Fragment}>
leaveFrom="opacity-100 scale-100" leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95" leaveTo="opacity-0 scale-95"
> >
<Dialog.Panel className={`w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all ${className}`}>
<Dialog.Panel className={`w-full max-w-md transform ${overflowVisible ? 'overflow-visible' : 'overflow-hidden'} rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all ${className}`}>
{title && <Dialog.Title {title && <Dialog.Title
as="h3" as="h3"
className="text-lg font-medium leading-6 text-gray-900" className="text-lg font-medium leading-6 text-gray-900"

Загрузка…
Отмена
Сохранить