From b5edc64b2ab718ebbd6251b74fb117e87753067b Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Wed, 9 Oct 2024 15:06:09 +0800 Subject: [PATCH] plugin type switch --- web/app/(commonLayout)/plugins/Container.tsx | 38 +++++++---- .../components/plugins/marketplace/index.tsx | 54 ++++++++------- .../marketplace/plugin-type-switch.tsx | 67 +++++++++++++++++++ .../plugins/marketplace/search-box/index.tsx | 10 ++- 4 files changed, 128 insertions(+), 41 deletions(-) create mode 100644 web/app/components/plugins/marketplace/plugin-type-switch.tsx diff --git a/web/app/(commonLayout)/plugins/Container.tsx b/web/app/(commonLayout)/plugins/Container.tsx index 58d996e7de..7adf0405b3 100644 --- a/web/app/(commonLayout)/plugins/Container.tsx +++ b/web/app/(commonLayout)/plugins/Container.tsx @@ -16,6 +16,7 @@ import Button from '@/app/components/base/button' import TabSlider from '@/app/components/base/tab-slider' import ActionButton from '@/app/components/base/action-button' import Tooltip from '@/app/components/base/tooltip' +import Marketplace from '@/app/components/plugins/marketplace' const Container = () => { const { t } = useTranslation() @@ -99,19 +100,30 @@ const Container = () => { -
-
-
- {/* Filter goes here */} -
-
-
- {/* Plugin cards go here */} -
- {activeTab === 'plugins' &&
- - Drop plugin package here to install -
} + { + activeTab === 'plugins' && ( + <> +
+
+
+ {/* Filter goes here */} +
+
+
+ {/* Plugin cards go here */} +
+
+ + Drop plugin package here to install +
+ + ) + } + { + activeTab === 'discover' && ( + + ) + } ) } diff --git a/web/app/components/plugins/marketplace/index.tsx b/web/app/components/plugins/marketplace/index.tsx index f35f455618..a9a45159a8 100644 --- a/web/app/components/plugins/marketplace/index.tsx +++ b/web/app/components/plugins/marketplace/index.tsx @@ -1,32 +1,36 @@ import SearchBox from './search-box' +import PluginTypeSwitch from './plugin-type-switch' const Marketplace = () => { return ( -
-

- Empower your AI development -

-

- Discover - - models - - , - - tools - - , - - extensions - - and - - bundles - - in Dify Marketplace -

-
- {}} /> +
+
+

+ Empower your AI development +

+

+ Discover + + models + + , + + tools + + , + + extensions + + and + + bundles + + in Dify Marketplace +

+
+ {}} /> +
+ {}} />
) diff --git a/web/app/components/plugins/marketplace/plugin-type-switch.tsx b/web/app/components/plugins/marketplace/plugin-type-switch.tsx new file mode 100644 index 0000000000..3793e463f7 --- /dev/null +++ b/web/app/components/plugins/marketplace/plugin-type-switch.tsx @@ -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: , + }, + { + value: 'extensions', + text: 'Extensions', + icon: , + }, + { + value: 'bundles', + text: 'Bundles', + icon: null, + }, +] +const PluginTypeSwitch = ({ + onChange, +}: PluginTypeSwitchProps) => { + const [activeType, setActiveType] = useState('all') + + return ( +
+ { + options.map(option => ( +
{ + setActiveType(option.value) + onChange(option.value) + }} + > + {option.icon} + {option.text} +
+ )) + } +
+ ) +} + +export default PluginTypeSwitch diff --git a/web/app/components/plugins/marketplace/search-box/index.tsx b/web/app/components/plugins/marketplace/search-box/index.tsx index e29256b555..1addb4cdd5 100644 --- a/web/app/components/plugins/marketplace/search-box/index.tsx +++ b/web/app/components/plugins/marketplace/search-box/index.tsx @@ -38,9 +38,13 @@ const SearchBox = ({ onChange(e.target.value, selectedTags) }} /> - setSearchText('')}> - - + { + searchText && ( + setSearchText('')}> + + + ) + }