plugin type switch

This commit is contained in:
StyleZhang 2024-10-09 15:06:09 +08:00
parent d00b2724cc
commit b5edc64b2a
4 changed files with 128 additions and 41 deletions

View File

@ -16,6 +16,7 @@ import Button from '@/app/components/base/button'
import TabSlider from '@/app/components/base/tab-slider' import TabSlider from '@/app/components/base/tab-slider'
import ActionButton from '@/app/components/base/action-button' import ActionButton from '@/app/components/base/action-button'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import Marketplace from '@/app/components/plugins/marketplace'
const Container = () => { const Container = () => {
const { t } = useTranslation() const { t } = useTranslation()
@ -99,19 +100,30 @@ const Container = () => {
</div> </div>
</div> </div>
</div> </div>
<div className='flex flex-col pt-1 pb-3 px-12 justify-center items-start gap-3 self-stretch'> {
<div className='h-px self-stretch bg-divider-subtle'></div> activeTab === 'plugins' && (
<div className='flex items-center gap-2 self-stretch'> <>
{/* Filter goes here */} <div className='flex flex-col pt-1 pb-3 px-12 justify-center items-start gap-3 self-stretch'>
</div> <div className='h-px self-stretch bg-divider-subtle'></div>
</div> <div className='flex items-center gap-2 self-stretch'>
<div className='flex px-12 items-start content-start gap-2 flex-grow self-stretch flex-wrap'> {/* Filter goes here */}
{/* Plugin cards go here */} </div>
</div> </div>
{activeTab === 'plugins' && <div className='flex items-center justify-center py-4 gap-2 text-text-quaternary'> <div className='flex px-12 items-start content-start gap-2 flex-grow self-stretch flex-wrap'>
<RiDragDropLine className='w-4 h-4' /> {/* Plugin cards go here */}
<span className='system-xs-regular'>Drop plugin package here to install</span> </div>
</div>} <div className='flex items-center justify-center py-4 gap-2 text-text-quaternary'>
<RiDragDropLine className='w-4 h-4' />
<span className='system-xs-regular'>Drop plugin package here to install</span>
</div>
</>
)
}
{
activeTab === 'discover' && (
<Marketplace />
)
}
</div> </div>
) )
} }

View File

@ -1,32 +1,36 @@
import SearchBox from './search-box' import SearchBox from './search-box'
import PluginTypeSwitch from './plugin-type-switch'
const Marketplace = () => { const Marketplace = () => {
return ( return (
<div className='w-full'> <div className='w-full bg-background-body'>
<h1 className='mb-2 text-center title-4xl-semibold text-text-primary'> <div className='py-10 bg-background-body'>
Empower your AI development <h1 className='mb-2 text-center title-4xl-semibold text-text-primary'>
</h1> Empower your AI development
<h2 className='flex justify-center items-center mb-4 text-center body-md-regular text-text-tertiary'> </h1>
Discover <h2 className='flex justify-center items-center mb-4 text-center body-md-regular text-text-tertiary'>
<span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected"> Discover
models <span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
</span> models
, </span>
<span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected"> ,
tools <span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
</span> tools
, </span>
<span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected"> ,
extensions <span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
</span> extensions
and </span>
<span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected"> and
bundles <span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
</span> bundles
in Dify Marketplace </span>
</h2> in Dify Marketplace
<div className='flex items-center justify-center'> </h2>
<SearchBox onChange={() => {}} /> <div className='flex items-center justify-center mb-4'>
<SearchBox onChange={() => {}} />
</div>
<PluginTypeSwitch onChange={() => {}} />
</div> </div>
</div> </div>
) )

View File

@ -0,0 +1,67 @@
import { useState } from 'react'
import {
RiHammerLine,
RiPuzzle2Line,
} from '@remixicon/react'
import cn from '@/utils/classnames'
type PluginTypeSwitchProps = {
onChange: (type: string) => void
}
const options = [
{
value: 'all',
text: 'All',
icon: null,
},
{
value: 'models',
text: 'Models',
icon: null,
},
{
value: 'tools',
text: 'Tools',
icon: <RiHammerLine className='mr-1.5 w-4 h-4' />,
},
{
value: 'extensions',
text: 'Extensions',
icon: <RiPuzzle2Line className='mr-1.5 w-4 h-4' />,
},
{
value: 'bundles',
text: 'Bundles',
icon: null,
},
]
const PluginTypeSwitch = ({
onChange,
}: PluginTypeSwitchProps) => {
const [activeType, setActiveType] = useState('all')
return (
<div className='flex items-center justify-center space-x-2'>
{
options.map(option => (
<div
key={option.value}
className={cn(
'flex items-center px-3 h-8 border border-transparent rounded-xl cursor-pointer hover:bg-state-base-hover hover:text-text-secondary system-md-medium text-text-tertiary',
activeType === option.value && 'border-components-main-nav-nav-button-border !bg-components-main-nav-nav-button-bg-active !text-components-main-nav-nav-button-text-active shadow-xs',
)}
onClick={() => {
setActiveType(option.value)
onChange(option.value)
}}
>
{option.icon}
{option.text}
</div>
))
}
</div>
)
}
export default PluginTypeSwitch

View File

@ -38,9 +38,13 @@ const SearchBox = ({
onChange(e.target.value, selectedTags) onChange(e.target.value, selectedTags)
}} }}
/> />
<ActionButton onClick={() => setSearchText('')}> {
<RiCloseLine className='w-4 h-4' /> searchText && (
</ActionButton> <ActionButton onClick={() => setSearchText('')}>
<RiCloseLine className='w-4 h-4' />
</ActionButton>
)
}
</div> </div>
</div> </div>
</div> </div>