-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tangle-dapp): Restake New Design (#2436)
- Loading branch information
Showing
79 changed files
with
1,803 additions
and
1,359 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,35 @@ | ||
import { TokenListCard } from '@webb-tools/webb-ui-components/components/ListCard/TokenListCard'; | ||
import type { TokenListCardProps } from '@webb-tools/webb-ui-components/components/ListCard/types'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
const AssetList = ({ | ||
className, | ||
title = 'Select an asset', | ||
popularTokens = [], | ||
unavailableTokens = [], | ||
selectTokens = [], | ||
...props | ||
}: Partial<TokenListCardProps>) => { | ||
return ( | ||
<TokenListCard | ||
type="asset" | ||
overrideTitleProps={{ | ||
variant: 'h4', | ||
}} | ||
{...props} | ||
selectTokens={selectTokens} | ||
popularTokens={popularTokens} | ||
unavailableTokens={unavailableTokens} | ||
title={title} | ||
className={twMerge( | ||
'h-full mx-auto dark:bg-[var(--restake-card-bg-dark)]', | ||
className, | ||
)} | ||
overrideInputProps={{ | ||
placeholder: 'Search for an asset', | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default AssetList; |
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { type ComponentProps, forwardRef } from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
const Form = forwardRef<HTMLFormElement, ComponentProps<'form'>>( | ||
({ className, ...props }, ref) => { | ||
return ( | ||
<form | ||
{...props} | ||
className={twMerge( | ||
'w-full max-w-lg mx-auto overflow-hidden', | ||
className, | ||
)} | ||
ref={ref} | ||
/> | ||
); | ||
}, | ||
); | ||
|
||
Form.displayName = 'Form'; | ||
|
||
export default Form; |
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,37 @@ | ||
import { | ||
ModalContent as ModalContentCmp, | ||
ModalDescription, | ||
ModalTitle, | ||
} from '@webb-tools/webb-ui-components/components/Modal'; | ||
import { ComponentProps } from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
const ModalContent = ({ | ||
children, | ||
className, | ||
title, | ||
description, | ||
...props | ||
}: ComponentProps<typeof ModalContentCmp> & { | ||
title: string; | ||
description: string; | ||
}) => { | ||
return ( | ||
<ModalContentCmp | ||
isCenter | ||
{...props} | ||
className={twMerge( | ||
'w-full h-full p-4 max-w-xl max-h-[var(--restake-modal-max-height)]', | ||
className, | ||
)} | ||
> | ||
<ModalTitle className="sr-only">{title}</ModalTitle> | ||
|
||
<ModalDescription className="sr-only">{description}</ModalDescription> | ||
|
||
{children} | ||
</ModalContentCmp> | ||
); | ||
}; | ||
|
||
export default ModalContent; |
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,157 @@ | ||
'use client'; | ||
|
||
import { Cross1Icon } from '@radix-ui/react-icons'; | ||
import { Search } from '@webb-tools/icons/Search'; | ||
import Button from '@webb-tools/webb-ui-components/components/buttons/Button'; | ||
import { Input } from '@webb-tools/webb-ui-components/components/Input'; | ||
import { KeyValueWithButton } from '@webb-tools/webb-ui-components/components/KeyValueWithButton'; | ||
import { ListCardWrapper } from '@webb-tools/webb-ui-components/components/ListCard/ListCardWrapper'; | ||
import { ListItem } from '@webb-tools/webb-ui-components/components/ListCard/ListItem'; | ||
import { ScrollArea } from '@webb-tools/webb-ui-components/components/ScrollArea'; | ||
import { Typography } from '@webb-tools/webb-ui-components/typography/Typography'; | ||
import { shortenString } from '@webb-tools/webb-ui-components/utils/shortenString'; | ||
import isFunction from 'lodash/isFunction'; | ||
import keys from 'lodash/keys'; | ||
import omitBy from 'lodash/omitBy'; | ||
import pick from 'lodash/pick'; | ||
import { type ComponentProps, forwardRef, useMemo, useState } from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
import type { OperatorMap } from '../../types/restake'; | ||
import type { IdentityType } from '../../utils/polkadot'; | ||
import AvatarWithText from './AvatarWithText'; | ||
|
||
type Props = Partial<ComponentProps<typeof ListCardWrapper>> & { | ||
operatorMap: OperatorMap; | ||
operatorIdentities?: Record<string, IdentityType | null> | null; | ||
selectedOperatorAccountId: string; | ||
onOperatorAccountIdChange?: (accountId: string) => void; | ||
onResetSelection?: () => void; | ||
}; | ||
|
||
const OperatorList = forwardRef<HTMLDivElement, Props>( | ||
( | ||
{ | ||
onClose, | ||
overrideTitleProps, | ||
operatorMap: operatorMapProp, | ||
operatorIdentities, | ||
selectedOperatorAccountId, | ||
onOperatorAccountIdChange, | ||
onResetSelection, | ||
...props | ||
}, | ||
ref, | ||
) => { | ||
const [searchText, setSearchText] = useState(''); | ||
|
||
// Only show active operators | ||
const activeOperator = useMemo( | ||
() => omitBy(operatorMapProp, (operator) => operator.status !== 'Active'), | ||
[operatorMapProp], | ||
); | ||
|
||
const isEmpty = Object.keys(activeOperator).length === 0; | ||
|
||
const filteredOperator = useMemo(() => { | ||
if (searchText === '') return activeOperator; | ||
|
||
const pickedOperators = keys(activeOperator).filter((operator) => { | ||
const identity = operatorIdentities?.[operator]?.name; | ||
if (!identity) return operator.includes(searchText); | ||
|
||
return ( | ||
identity.toLowerCase().includes(searchText.toLowerCase()) || | ||
operator.includes(searchText) | ||
); | ||
}); | ||
|
||
return pick(activeOperator, pickedOperators); | ||
}, [activeOperator, operatorIdentities, searchText]); | ||
|
||
return ( | ||
<ListCardWrapper | ||
{...props} | ||
title="Select Operator" | ||
onClose={onClose} | ||
ref={ref} | ||
> | ||
{!isEmpty && ( | ||
<> | ||
<div className="py-4"> | ||
<Input | ||
id="token" | ||
rightIcon={<Search />} | ||
placeholder="Search Operator" | ||
isControlled | ||
value={searchText} | ||
onChange={(val) => setSearchText(val.toString())} | ||
/> | ||
</div> | ||
|
||
<ScrollArea className={twMerge('h-full py-2')}> | ||
<ul> | ||
{keys(filteredOperator).map((current) => ( | ||
<ListItem | ||
key={current} | ||
className="px-4 cursor-pointer max-w-none dark:bg-transparent" | ||
onClick={() => onOperatorAccountIdChange?.(current)} | ||
> | ||
<AvatarWithText | ||
accountAddress={current} | ||
overrideAvatarProps={{ size: 'lg' }} | ||
overrideTypographyProps={{ variant: 'h5' }} | ||
identityName={ | ||
operatorIdentities?.[current]?.name || '<Unknown>' | ||
} | ||
description={ | ||
<KeyValueWithButton | ||
size="sm" | ||
keyValue={current} | ||
shortenFn={shortenString} | ||
/> | ||
} | ||
/> | ||
</ListItem> | ||
))} | ||
</ul> | ||
</ScrollArea> | ||
|
||
{isFunction(onResetSelection) && ( | ||
<Button | ||
isDisabled={!selectedOperatorAccountId} | ||
className="mt-auto" | ||
leftIcon={<Cross1Icon />} | ||
isFullWidth | ||
onClick={onResetSelection} | ||
> | ||
Clear Selection | ||
</Button> | ||
)} | ||
</> | ||
)} | ||
|
||
{isEmpty && ( | ||
<div className="flex flex-col items-center justify-center space-y-4 grow"> | ||
<Typography variant="h5" fw="bold" ta="center"> | ||
No Operator Found. | ||
</Typography> | ||
|
||
<Typography | ||
variant="body1" | ||
fw="semibold" | ||
className="max-w-xs mt-1 text-mono-100 dark:text-mono-80" | ||
ta="center" | ||
> | ||
You can comeback later or add apply to become a operator. | ||
</Typography> | ||
</div> | ||
)} | ||
</ListCardWrapper> | ||
); | ||
}, | ||
); | ||
|
||
OperatorList.displayName = 'OperatorList'; | ||
|
||
export default OperatorList; |
Oops, something went wrong.