From 1602ef92c885c7d8ccbd786fd47ea7a5803021cd Mon Sep 17 00:00:00 2001 From: HeesungB Date: Tue, 13 Dec 2022 22:10:31 +0900 Subject: [PATCH] Add search input --- components/search-input/index.tsx | 83 +++++++++++++++++++++++++++++++ pages/verification/index.tsx | 28 +++++------ public/images/svg/search-icon.svg | 3 ++ 3 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 components/search-input/index.tsx create mode 100644 public/images/svg/search-icon.svg diff --git a/components/search-input/index.tsx b/components/search-input/index.tsx new file mode 100644 index 0000000..f535cbb --- /dev/null +++ b/components/search-input/index.tsx @@ -0,0 +1,83 @@ +import { + Dispatch, + FunctionComponent, + SetStateAction, + useRef, + useState, +} from "react"; + +import Image from "next/image"; + +import styled from "styled-components"; +import color from "../../styles/color"; + +import SearchIcon from "../../public/images/svg/search-icon.svg"; + +interface Props { + searchValue: string; + setSearchValue: Dispatch>; +} + +export const SearchInput: FunctionComponent = (props) => { + const { searchValue, setSearchValue } = props; + + return ( + + + search icon + + + { + setSearchValue(event.target.value); + }} + /> + + ); +}; + +const SearchContainer = styled.div` + display: flex; + align-items: center; + gap: 0.625rem; + + min-width: 10rem; + height: 2rem; + + padding: 0.5rem 1.3rem; + + border-radius: 3rem; + background-color: ${color.grey["700"]}; +`; + +const SearchIconContainer = styled.div` + position: relative; + + width: 1.3rem; + height: 1.3rem; +`; + +const SearchText = styled.input` + border: none; + + color: ${color.white}; + background-color: ${color.grey["700"]}; + + font-family: "Inter", serif; + font-style: normal; + font-weight: 500; + font-size: 1rem; + line-height: 1.2rem; + + ::placeholder, + ::-webkit-input-placeholder { + color: ${color.grey["400"]}; + } + + &:focus { + outline: none; + } +`; diff --git a/pages/verification/index.tsx b/pages/verification/index.tsx index a5cc2b0..8e79ab8 100644 --- a/pages/verification/index.tsx +++ b/pages/verification/index.tsx @@ -27,6 +27,7 @@ import { ChainIdHelper } from "@keplr-wallet/cosmos"; import AllChainsIcon from "../../public/images/svg/all-chains-icon.svg"; import { AllChainsItem } from "../../components/chain-list/all-chains-item"; +import { SearchInput } from "../../components/search-input"; export default function VerificationPage() { const router = useRouter(); @@ -40,6 +41,7 @@ export default function VerificationPage() { const [chainList, setChainList] = useState([]); const [checkedItems, setCheckedItems] = useState(new Set()); const [allChecked, setAllChecked] = useState(false); + const [searchValue, setSearchValue] = useState(""); useEffect(() => { const handleVerification = async () => { @@ -182,10 +184,13 @@ export default function VerificationPage() { Chain List - Search + - {allChains ? ( + {allChains && !searchValue ? ( + chain.chainId.includes(searchValue) || + chain.address.includes(searchValue) || + chain.prefix.includes(searchValue), + )} checkedItems={checkedItems} setCheckedItems={setCheckedItems} /> @@ -264,15 +274,3 @@ const ChainListTitle = styled.div` color: ${color.white}; `; - -const SearchContainer = styled.div` - display: flex; - align-items: center; - - border-radius: 3rem; - - min-width: 10rem; - height: 2rem; - - background-color: ${color.grey["700"]}; -`; diff --git a/public/images/svg/search-icon.svg b/public/images/svg/search-icon.svg new file mode 100644 index 0000000..f1406e1 --- /dev/null +++ b/public/images/svg/search-icon.svg @@ -0,0 +1,3 @@ + + +