-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7329f9a
commit e8445e2
Showing
19 changed files
with
443 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 0 additions & 92 deletions
92
libs/webb-ui-components/src/components/GovernanceForm/GovernanceForm.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
libs/webb-ui-components/src/components/GovernanceForm/index.ts
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
libs/webb-ui-components/src/components/GovernanceForm/types.ts
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
libs/webb-ui-components/src/components/GovernanceForm/utils.ts
This file was deleted.
Oops, something went wrong.
114 changes: 114 additions & 0 deletions
114
libs/webb-ui-components/src/components/ListCard/ContractListCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { useState, useMemo, forwardRef } from 'react'; | ||
import { ExternalLinkLine, Search } from '@webb-tools/icons'; | ||
import { ScrollArea } from '../ScrollArea'; | ||
import { Typography } from '../../typography'; | ||
import SkeletonLoader from '../SkeletonLoader'; | ||
import { Input } from '../Input'; | ||
import { ListItem } from './ListItem'; | ||
import { ListCardWrapper } from './ListCardWrapper'; | ||
import { isHex } from 'viem'; | ||
|
||
import { ContractListCardProps } from './types'; | ||
import { shortenHex, shortenString } from '../../utils'; | ||
|
||
const ContractListCard = forwardRef<HTMLDivElement, ContractListCardProps>( | ||
({ isLoading, selectContractItems, ...props }, ref) => { | ||
const [searchText, setSearchText] = useState(''); | ||
|
||
const filterList = useMemo( | ||
() => | ||
selectContractItems.filter((item) => { | ||
return ( | ||
item.name.toLowerCase().includes(searchText.toLowerCase()) || | ||
item.address.toLowerCase().includes(searchText.toLowerCase()) || | ||
item.blockExplorerUrl | ||
?.toLowerCase() | ||
.includes(searchText.toLowerCase()) | ||
); | ||
}), | ||
[selectContractItems, searchText] | ||
); | ||
|
||
return ( | ||
<ListCardWrapper | ||
title="Select Contract" | ||
hideCloseButton | ||
{...props} | ||
ref={ref} | ||
> | ||
{/** The search input */} | ||
<div className="py-4"> | ||
<Input | ||
id="contract" | ||
rightIcon={<Search />} | ||
placeholder="Search contracts" | ||
value={searchText} | ||
onChange={(val) => setSearchText(val.toString())} | ||
isDisabled={isLoading || selectContractItems.length === 0} | ||
/> | ||
</div> | ||
|
||
<ScrollArea className="lg:min-w-[350px] h-[376px]"> | ||
{isLoading && ( | ||
<div className="space-y-2"> | ||
<SkeletonLoader size="xl" /> | ||
<SkeletonLoader size="xl" /> | ||
</div> | ||
)} | ||
{!isLoading && ( | ||
<ul className="py-2"> | ||
{filterList.map((item, idx) => { | ||
const { name, address, blockExplorerUrl, onSelectContract } = | ||
item; | ||
return ( | ||
<ListItem | ||
key={idx} | ||
className="flex justify-between" | ||
onClick={() => { | ||
onSelectContract && onSelectContract(); | ||
}} | ||
> | ||
<div> | ||
<Typography | ||
component="span" | ||
variant="h5" | ||
fw="bold" | ||
className="block cursor-default" | ||
> | ||
{name} | ||
</Typography> | ||
<Typography | ||
component="span" | ||
variant="body1" | ||
fw="bold" | ||
className="cursor-default text-mono-100 dark:text-mono-80" | ||
> | ||
{isHex(address) | ||
? shortenHex(address) | ||
: shortenString(address)} | ||
</Typography> | ||
</div> | ||
|
||
{typeof blockExplorerUrl === 'string' && ( | ||
<a | ||
href={blockExplorerUrl} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
className="!text-inherit" | ||
onClick={(event) => event.stopPropagation()} | ||
> | ||
<ExternalLinkLine className="inline-block !fill-current" /> | ||
</a> | ||
)} | ||
</ListItem> | ||
); | ||
})} | ||
</ul> | ||
)} | ||
</ScrollArea> | ||
</ListCardWrapper> | ||
); | ||
} | ||
); | ||
|
||
export default ContractListCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.