From 43ad883b2be2304b9a9f9e7f4ee99345a0f0e220 Mon Sep 17 00:00:00 2001 From: zho Date: Wed, 11 Sep 2024 11:33:40 +0200 Subject: [PATCH] chore: rm onMenuStateChange for menu component (#2326) * chore: rm onMenuStateChange for menu component * chore: rm all menu state change implementations * chore: rm shadow from sort proposal * chore: revert shadow on dropdown * chore: add shadow on share dropdown too --- .../components/Share/index.tsx | 223 ++++++++---------- .../components/Sort/index.tsx | 5 +- .../TokenSearchModal/ERC20/index.tsx | 21 +- .../components/TokenSearchModal/NFT/index.tsx | 21 +- .../components/ChainDropdown/index.tsx | 11 +- .../NftList/component/Nft/index.tsx | 7 +- .../components/NftList/index.tsx | 10 +- .../components/SearchInput/index.tsx | 11 +- .../_pages/Contest/Contest/index.tsx | 12 +- .../CreatePool/components/Dropdown/index.tsx | 4 - .../components/SortDropdown/index.tsx | 77 +++--- .../components/ProposalStatistics/index.tsx | 9 +- .../components/DefaultDropdown/index.tsx | 11 +- .../components/TemplateDropdown/index.tsx | 10 +- .../Metadata/components/Dropdown/index.tsx | 4 - .../Fields/components/Field/index.tsx | 8 +- .../SubmissionRequirements/index.tsx | 15 +- .../components/SubmissionPeriod/index.tsx | 8 +- .../components/VotingPeriod/index.tsx | 8 +- .../Create/pages/ContestUseTemplate/index.tsx | 6 +- .../components/VotingRequirements/index.tsx | 24 +- .../components/_pages/ListContests/index.tsx | 5 +- .../layouts/LayoutViewContest/index.tsx | 10 +- 23 files changed, 175 insertions(+), 345 deletions(-) diff --git a/packages/react-app-revamp/components/Share/index.tsx b/packages/react-app-revamp/components/Share/index.tsx index bc9fbabe6..32e2f80ba 100644 --- a/packages/react-app-revamp/components/Share/index.tsx +++ b/packages/react-app-revamp/components/Share/index.tsx @@ -18,10 +18,9 @@ interface ShareDropdownProps { contestName: string; contestAddress: string; chain: string; - onMenuStateChange?: (isOpen: boolean) => void; } -const ShareDropdown: FC = ({ contestName, contestAddress, chain, onMenuStateChange }) => { +const ShareDropdown: FC = ({ contestName, contestAddress, chain }) => { const [isCopied, setIsCopied] = useState(false); useEffect(() => { @@ -41,124 +40,110 @@ const ShareDropdown: FC = ({ contestName, contestAddress, ch return ( - {({ open }) => { - onMenuStateChange?.(open); + + + share + + + + + Share share + + - return ( - <> - - - share - - - - - Share share - - - - - - - {({ focus, close }) => ( - - Lens - share on Lens - - )} - - - {({ focus, close }) => ( - - Twitter - share on Twitter - - )} - - - {({ focus, close }) => ( - - Twitter - share on farcaster - - )} - - - {({ focus }) => ( - - {isCopied ? ( - - ) : ( - - )} - copy link - - )} - - - - - ); - }} + + + + {({ focus, close }) => ( + + Lens + share on Lens + + )} + + + {({ focus, close }) => ( + + Twitter + share on Twitter + + )} + + + {({ focus, close }) => ( + + Twitter + share on farcaster + + )} + + + {({ focus }) => ( + + {isCopied ? ( + + ) : ( + + )} + copy link + + )} + + + ); }; diff --git a/packages/react-app-revamp/components/Sort/index.tsx b/packages/react-app-revamp/components/Sort/index.tsx index c5f921a8c..3b30d43ab 100644 --- a/packages/react-app-revamp/components/Sort/index.tsx +++ b/packages/react-app-revamp/components/Sort/index.tsx @@ -16,10 +16,9 @@ export type SortOption = { export interface SortProps { sortOptions: SortOption[]; onSortChange?: (sortBy: string) => void; - onMenuStateChange?: (isOpen: boolean) => void; } -const Sort: FC = ({ sortOptions, onSortChange, onMenuStateChange }) => { +const Sort: FC = ({ sortOptions, onSortChange }) => { const [selectedOption, setSelectedOption] = useState(null); const [label, setLabel] = useState(null); const query = useSearchParams(); @@ -79,8 +78,6 @@ const Sort: FC = ({ sortOptions, onSortChange, onMenuStateChange }) = return ( {({ open }) => { - onMenuStateChange?.(open); - return ( <>
= ({ chains: erc20Ch const [searchValue, setSearchValue] = useState(""); const chainId = chains.find(chain => chain.name === erc20SelectedChain)?.id || 1; const isChainSupportedBySearch = TOKENLISTOOOR_SUPPORTED_CHAIN_IDS.includes(chainId); - const [isChainDropdownOpen, setIsChainDropdownOpen] = useState(false); return (
@@ -28,29 +27,15 @@ const TokenSearchModalERC20: FC = ({ chains: erc20Ch defaultOption={erc20Chains[0]} options={erc20Chains} onChange={option => setErc20SelectedChain(option)} - onMenuStateChange={isOpen => setIsChainDropdownOpen(isOpen)} />
) : null} {!hideChains ?
: null} - setSearchValue(value)} - isChainDropdownOpen={isChainDropdownOpen} - chainId={chainId} - /> + setSearchValue(value)} chainId={chainId} /> {searchValue ? ( - + ) : isChainSupportedBySearch ? ( - + ) : (
diff --git a/packages/react-app-revamp/components/TokenSearchModal/NFT/index.tsx b/packages/react-app-revamp/components/TokenSearchModal/NFT/index.tsx index fc0636ba3..e5ceacc6c 100644 --- a/packages/react-app-revamp/components/TokenSearchModal/NFT/index.tsx +++ b/packages/react-app-revamp/components/TokenSearchModal/NFT/index.tsx @@ -14,7 +14,6 @@ interface TokenSearchModalNftProps { const TokenSearchModalNft: FC = ({ chains, onSelectNft, onSelectChain }) => { const [selectedChain, setSelectedChain] = useState(chains[0].value); const [searchValue, setSearchValue] = useState(""); - const [isChainDropdownOpen, setIsChainDropdownOpen] = useState(false); const chainId = wagmiChains.find(chain => chain.name.toLowerCase() === selectedChain.toLowerCase())?.id || 1; const onNftChainChange = (chain: string) => { @@ -26,26 +25,12 @@ const TokenSearchModalNft: FC = ({ chains, onSelectNft

chain:

- setIsChainDropdownOpen(isOpen)} - /> +
- setSearchValue(value)} - isChainDropdownOpen={isChainDropdownOpen} - chainId={chainId} - /> + setSearchValue(value)} chainId={chainId} /> {searchValue ? ( - + ) : null}
); diff --git a/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx b/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx index 4f7926a72..6cb04ce53 100644 --- a/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx +++ b/packages/react-app-revamp/components/TokenSearchModal/components/ChainDropdown/index.tsx @@ -14,16 +14,9 @@ interface ChainDropdownProps { defaultOption: Option; className?: string; onChange?: (option: string) => void; - onMenuStateChange?: (isOpen: boolean) => void; } -const TokenSearchModalChainDropdown: FC = ({ - options, - defaultOption, - className, - onChange, - onMenuStateChange, -}) => { +const TokenSearchModalChainDropdown: FC = ({ options, defaultOption, className, onChange }) => { const [selectedOption, setSelectedOption] = useState