diff --git a/src/components/common/chip/ChipDropdown.tsx b/src/components/common/chip/ChipDropdown.tsx index 36f836b9..672756cb 100644 --- a/src/components/common/chip/ChipDropdown.tsx +++ b/src/components/common/chip/ChipDropdown.tsx @@ -26,11 +26,24 @@ function ChipDropdown(props: ChipProps) { const color = isMoreSelected ? 'dark-700' : 'white'; const [icon, setIcon] = useState(NETWORK_ICON_MAP[selectedNetwork]); + const [searchTerm, setSearchTerm] = useState(''); + const [filteredNetworks, setFilteredNetworks] = useState(props.dropdownNetworkList); useEffect(() => { setIcon(NETWORK_ICON_MAP[selectedNetwork]); },[selectedNetwork]); + // Filtering networks based on search term + useEffect(() => { + if (searchTerm.trim() === '') { + setFilteredNetworks(dropdownNetworkList); + } else { + const filtered = dropdownNetworkList.filter(network => + network.name.toLowerCase().includes(searchTerm.toLowerCase()) + ); + setFilteredNetworks(filtered); + } + }, [searchTerm, dropdownNetworkList]); return (
@@ -61,35 +74,46 @@ function ChipDropdown(props: ChipProps) { leaveFrom="transform opacity-100 scale-100" leaveTo="transform opacity-0 scale-95" > - + + diff --git a/src/components/global/searchblock/Options.tsx b/src/components/global/searchblock/Options.tsx index f22a72d4..4ed215bf 100644 --- a/src/components/global/searchblock/Options.tsx +++ b/src/components/global/searchblock/Options.tsx @@ -1,15 +1,34 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { NETWORK_LIST } from '@/components/common/constants'; function Options({ networkValue, setNetworkValue }: { networkValue: number; setNetworkValue: (value: number) => void }) { const [open, setOpen] = useState(false); const toggler = () => setOpen((v) => !v); + const [searchTerm, setSearchTerm] = useState(''); + const [filteredNetworks, setFilteredNetworks] = useState(NETWORK_LIST); // Initialized with full list + // console.log(networkValue,setNetworkValue) const handleValue = (index: number) => { setNetworkValue(index); - toggler(); + // toggler(); + setOpen(false); // Close dropdown after selection + }; + // Filter networks based on search term + useEffect(() => { + if (searchTerm.trim() === '') { + setFilteredNetworks(NETWORK_LIST); // Reset to full list when search term is empty + } else { + const filtered = NETWORK_LIST.filter((network) => + network.name.toLowerCase().includes(searchTerm.toLowerCase()) + ); + setFilteredNetworks(filtered); + } + }, [searchTerm]); + const handleSearchChange = (e: React.ChangeEvent) => { + setSearchTerm(e.target.value); + }; return (
@@ -22,29 +41,30 @@ function Options({ networkValue, setNetworkValue }: { networkValue: number; setN {open && (
-
+
-
handleValue(-1)} - className="flex items-center whitespace-no-wrap gap-2 py-2 px-3 hover:bg-dark-600/10 text-md" - role="button" - - > - - Quick search -
- {NETWORK_LIST.map(({ name, key, iconPath, iconPathInverted }, index) => ( -
handleValue(index)} - className="flex items-center whitespace-no-wrap gap-2 py-2 px-3 hover:bg-dark-600/10 text-md" - role="button" - key={index} - > - - {name} +
+
- ))} - +
+ {filteredNetworks.map(({ name, iconPath }, index) => ( +
handleValue(index)} + className="flex items-center whitespace-no-wrap gap-2 py-2 px-3 hover:bg-dark-600/10 text-md" + role="button" + key={index} + > + + {name} +
+ ))} +
diff --git a/src/styles/main.sass b/src/styles/main.sass index f5c5edfc..e2dd83c5 100644 --- a/src/styles/main.sass +++ b/src/styles/main.sass @@ -54,7 +54,14 @@ body &:hover background: #555 +.no-scrollbar + scrollbar-width: none + -ms-overflow-style: none + overflow-y: scroll +.no-scrollbar::-webkit-scrollbar + display: none + .wordbrack word-break: break-all word-break: break-word