-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dw): add receiver account search field
- Loading branch information
Showing
25 changed files
with
1,063 additions
and
400 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useLayout } from '@kadena/kode-ui/patterns'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export function useRightAside() { | ||
const [expanded, setExpanded] = useState(false); | ||
const { isRightAsideExpanded, setIsRightAsideExpanded } = useLayout(); | ||
|
||
useEffect(() => { | ||
if (!isRightAsideExpanded && expanded) { | ||
setExpanded(false); | ||
} | ||
}, [isRightAsideExpanded, expanded]); | ||
|
||
return [ | ||
expanded, | ||
() => { | ||
if (isRightAsideExpanded && !expanded) { | ||
throw new Error('Right aside is already open with a different panel'); | ||
} | ||
setIsRightAsideExpanded(true); | ||
setExpanded(true); | ||
}, | ||
() => { | ||
if (expanded) { | ||
setIsRightAsideExpanded(false); | ||
setExpanded(false); | ||
} | ||
}, | ||
] as [isExpanded: boolean, expand: () => void, close: () => void]; | ||
} |
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
100 changes: 100 additions & 0 deletions
100
packages/apps/dev-wallet/src/Components/AccountInput/DiscoverdAccounts.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,100 @@ | ||
import { Keyset } from '@/pages/transfer-v2/Components/keyset'; | ||
import { IReceiverAccount } from '@/pages/transfer-v2/utils'; | ||
import { MonoAttachMoney, MonoLink } from '@kadena/kode-icons/system'; | ||
import { | ||
Button, | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
Stack, | ||
Text, | ||
} from '@kadena/kode-ui'; | ||
import { FC, ReactNode } from 'react'; | ||
import { discoverdAccountClass } from './style.css'; | ||
|
||
export const DiscoverdAccounts: FC<{ | ||
accounts: IReceiverAccount[]; | ||
onSelect: (selected: IReceiverAccount) => void; | ||
onClosed: () => void; | ||
inline?: boolean; | ||
}> = ({ accounts, onSelect, onClosed, inline }) => { | ||
const Wrapper = ({ children }: { children: ReactNode }) => { | ||
if (inline) { | ||
return <Stack gap={'sm'}>{children}</Stack>; | ||
} | ||
return ( | ||
<Dialog | ||
size="sm" | ||
isOpen={accounts.length > 0} | ||
onOpenChange={(isOpen) => { | ||
if (!isOpen) { | ||
onClosed(); | ||
} | ||
}} | ||
> | ||
{children} | ||
</Dialog> | ||
); | ||
}; | ||
|
||
return ( | ||
<Wrapper> | ||
{!inline && <DialogHeader>Select the receiver account</DialogHeader>} | ||
<DialogContent> | ||
<Stack flexDirection={'column'} gap={'sm'}> | ||
<Text> | ||
There are {accounts.length} accounts associated with the same | ||
address on the Blockchain. Please select the account you want to | ||
use. | ||
</Text> | ||
<Text>Address: {accounts[0].address}</Text> | ||
<Stack flexDirection={'column'}> | ||
{accounts.map((account) => ( | ||
<Stack | ||
gap={'sm'} | ||
alignItems={'center'} | ||
className={discoverdAccountClass} | ||
justifyContent={'space-between'} | ||
> | ||
<Stack | ||
gap={inline ? undefined : 'sm'} | ||
flexDirection={inline ? 'column' : 'row'} | ||
flex={1} | ||
> | ||
<Text size="smallest" color="emphasize"> | ||
<Stack gap={'xs'} alignItems={'center'}> | ||
<MonoAttachMoney /> | ||
{account.overallBalance} | ||
</Stack> | ||
</Text> | ||
<Text size="smallest" color="emphasize"> | ||
<Stack gap={'xs'} alignItems={'center'}> | ||
<MonoLink /> ( | ||
{account.chains.map(({ chainId }) => chainId).join(',')}) | ||
</Stack> | ||
</Text> | ||
</Stack> | ||
<Stack | ||
gap={'sm'} | ||
justifyContent={'flex-end'} | ||
alignItems={'center'} | ||
> | ||
<Keyset guard={account.keyset.guard} /> | ||
<Stack> | ||
<Button | ||
isCompact | ||
variant="outlined" | ||
onPress={() => onSelect(account)} | ||
> | ||
Select | ||
</Button> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
))} | ||
</Stack> | ||
</Stack> | ||
</DialogContent> | ||
</Wrapper> | ||
); | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/apps/dev-wallet/src/Components/AccountInput/style.css.ts
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,16 @@ | ||
import { atoms, vars } from '@kadena/kode-ui/styles'; | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const discoverdAccountClass = style([ | ||
{ | ||
backgroundColor: vars.colors.$layoutSurfaceCard, | ||
selectors: { | ||
'&:nth-child(odd)': { | ||
backgroundColor: vars.colors.$layoutSurfaceDefault, | ||
}, | ||
}, | ||
}, | ||
atoms({ | ||
padding: 'sm', | ||
}), | ||
]); |
Oops, something went wrong.