-
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.
Fix: Multisig single chain view (#2649)
- Loading branch information
Showing
24 changed files
with
641 additions
and
387 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
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
66 changes: 43 additions & 23 deletions
66
src/renderer/entities/wallet/ui/ContactItem/ContactItem.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 |
---|---|---|
@@ -1,67 +1,87 @@ | ||
import { type MouseEvent } from 'react'; | ||
import { type PropsWithChildren } from 'react'; | ||
|
||
import { type AccountId, type Address, type KeyType } from '@/shared/core'; | ||
import { cnTw, toAddress } from '@/shared/lib/utils'; | ||
import { BodyText, HelpText, Icon, IconButton, Identicon } from '@/shared/ui'; | ||
import { cnTw, nonNullable, toAddress } from '@/shared/lib/utils'; | ||
import { BodyText, HelpText, Icon, Identicon } from '@/shared/ui'; | ||
import { Hash } from '@/shared/ui-entities'; | ||
import { KeyIcon } from '../../lib/constants'; | ||
|
||
type Props = { | ||
type Props = PropsWithChildren<{ | ||
name?: string; | ||
address: Address | AccountId; | ||
addressPrefix?: number; | ||
keyType?: KeyType; | ||
size?: number; | ||
iconSize?: number; | ||
className?: string; | ||
hideAddress?: boolean; | ||
onInfoClick?: () => void; | ||
}; | ||
}>; | ||
|
||
export const ContactItem = ({ | ||
name, | ||
address, | ||
addressPrefix, | ||
size = 20, | ||
iconSize = 20, | ||
hideAddress = false, | ||
keyType, | ||
className, | ||
onInfoClick, | ||
children, | ||
}: Props) => { | ||
const formattedAddress = toAddress(address, { prefix: addressPrefix }); | ||
|
||
const handleClick = (event: MouseEvent<HTMLDivElement>) => { | ||
event.stopPropagation(); | ||
}; | ||
|
||
return ( | ||
<div className={cnTw('group flex w-full items-center gap-x-2', className)}> | ||
<div className="flex w-full items-center gap-x-2 overflow-hidden py-[3px]" onClick={handleClick}> | ||
<div | ||
className={cnTw( | ||
'group relative flex w-full items-center rounded transition-colors', | ||
'focus-within:bg-action-background-hover hover:bg-action-background-hover', | ||
)} | ||
> | ||
<div className={cnTw('flex w-full items-center gap-x-2 overflow-hidden py-1.5 pl-2', children ? 'pr-9' : 'pr-3')}> | ||
<div className="flex"> | ||
<Identicon address={formattedAddress} size={size} background={false} /> | ||
<Identicon address={formattedAddress} size={iconSize} background={false} /> | ||
|
||
{keyType && ( | ||
<Icon | ||
className="z-10 -ml-2.5 rounded-full border bg-white text-text-secondary" | ||
size={size} | ||
size={iconSize} | ||
name={KeyIcon[keyType]} | ||
/> | ||
)} | ||
</div> | ||
|
||
<div className="flex flex-col"> | ||
{name && ( | ||
<div className="flex flex-col overflow-hidden"> | ||
{name ? ( | ||
<BodyText | ||
className={cnTw( | ||
'truncate text-text-secondary transition-colors', | ||
'group-hover:text-text-primary group-focus:text-text-primary', | ||
'group-focus-within:text-text-primary group-hover:text-text-primary', | ||
)} | ||
> | ||
{name} | ||
</BodyText> | ||
) : ( | ||
<BodyText | ||
className={cnTw( | ||
'text-text-secondary transition-colors', | ||
'group-focus-within:text-text-primary group-hover:text-text-primary', | ||
)} | ||
> | ||
<Hash value={formattedAddress} variant="truncate" /> | ||
</BodyText> | ||
)} | ||
|
||
{nonNullable(name) && !hideAddress && ( | ||
<HelpText className="truncate text-text-tertiary">{formattedAddress}</HelpText> | ||
)} | ||
{!hideAddress && <HelpText className="truncate text-text-tertiary">{formattedAddress}</HelpText>} | ||
</div> | ||
</div> | ||
|
||
<IconButton name="details" className="mx-1.5" onClick={onInfoClick} /> | ||
<div | ||
className={cnTw( | ||
'absolute right-2 top-1/2 flex -translate-y-1/2 opacity-0 transition-opacity', | ||
'focus:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100', | ||
)} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
}; |
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
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.