From 197f1b39573606b53c8bdff0ed5f231717bed67b Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Fri, 1 Nov 2024 11:26:36 +0800 Subject: [PATCH] feat: search box --- .../plugins/marketplace/search-box/index.tsx | 24 +++++++++++-------- .../search-box/search-box-wrapper.tsx | 6 ++++- .../marketplace/search-box/tags-filter.tsx | 10 ++++++-- .../workflow/block-selector/tool-picker.tsx | 10 +++++++- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/web/app/components/plugins/marketplace/search-box/index.tsx b/web/app/components/plugins/marketplace/search-box/index.tsx index 12682bd725..7ca9ce17e0 100644 --- a/web/app/components/plugins/marketplace/search-box/index.tsx +++ b/web/app/components/plugins/marketplace/search-box/index.tsx @@ -1,6 +1,5 @@ 'use client' import { RiCloseLine } from '@remixicon/react' -import { useMarketplaceContext } from '../context' import TagsFilter from './tags-filter' import ActionButton from '@/app/components/base/action-button' import cn from '@/utils/classnames' @@ -11,6 +10,8 @@ type SearchBoxProps = { inputClassName?: string tags: string[] onTagsChange: (tags: string[]) => void + size?: 'small' | 'large' + placeholder?: string } const SearchBox = ({ search, @@ -18,36 +19,39 @@ const SearchBox = ({ inputClassName, tags, onTagsChange, + size = 'small', + placeholder = 'Search tools...', }: SearchBoxProps) => { - const intersected = useMarketplaceContext(v => v.intersected) - const searchPluginText = useMarketplaceContext(v => v.searchPluginText) - const handleSearchPluginTextChange = useMarketplaceContext(v => v.handleSearchPluginTextChange) - return (
{ onSearchChange(e.target.value) }} + placeholder={placeholder} /> { - searchPluginText && ( - handleSearchPluginTextChange('')}> + search && ( + onSearchChange('')}> ) diff --git a/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx b/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx index 0758d7785b..a124d93eb4 100644 --- a/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx +++ b/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx @@ -12,11 +12,15 @@ const SearchBoxWrapper = () => { return ( ) } diff --git a/web/app/components/plugins/marketplace/search-box/tags-filter.tsx b/web/app/components/plugins/marketplace/search-box/tags-filter.tsx index 51746fddb4..5114765544 100644 --- a/web/app/components/plugins/marketplace/search-box/tags-filter.tsx +++ b/web/app/components/plugins/marketplace/search-box/tags-filter.tsx @@ -18,10 +18,12 @@ import Input from '@/app/components/base/input' type TagsFilterProps = { tags: string[] onTagsChange: (tags: string[]) => void + size: 'small' | 'large' } const TagsFilter = ({ tags, onTagsChange, + size, }: TagsFilterProps) => { const [open, setOpen] = useState(false) const [searchText, setSearchText] = useState('') @@ -56,7 +58,9 @@ const TagsFilter = ({ > setOpen(v => !v)}>
@@ -65,6 +69,8 @@ const TagsFilter = ({
{ !selectedTagsLength && 'All Tags' @@ -95,7 +101,7 @@ const TagsFilter = ({ }
- +
= ({
- setSearchText(e.target.value)} /> + {}} + size='small' + placeholder='Search tools...' + />