-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dashboard/current-season-card
- Loading branch information
Showing
8 changed files
with
217 additions
and
16 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
53 changes: 53 additions & 0 deletions
53
dapp/src/components/shared/ActivitiesList/ActivitiesList.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,53 @@ | ||
import React from "react" | ||
import { List, ListItem, ListProps } from "@chakra-ui/react" | ||
import { AnimatePresence, Variants, motion } from "framer-motion" | ||
import { useActivitiesNEW as useActivities } from "#/hooks" | ||
import ActivitiesListItem from "./ActivitiesListItem" | ||
|
||
const MotionList = motion(List) | ||
const MotionListItem = motion(ListItem) | ||
|
||
const listItemVariants: Variants = { | ||
mounted: { opacity: 1, x: 0 }, | ||
dismissed: { opacity: 0, x: -48 }, | ||
} | ||
|
||
function ActivitiesList(props: ListProps) { | ||
const activities = useActivities() | ||
|
||
const [dismissedActivities, setDismissedActivities] = React.useState< | ||
string[] | ||
>([]) | ||
|
||
const handleItemDismiss = (txHash: string) => { | ||
setDismissedActivities((prev) => [...prev, txHash]) | ||
} | ||
|
||
return ( | ||
<MotionList pos="relative" {...props}> | ||
{activities.map((item) => ( | ||
<AnimatePresence mode="popLayout"> | ||
{!dismissedActivities.includes(item.txHash) && ( | ||
<MotionListItem | ||
layout="position" | ||
key={item.txHash} | ||
variants={listItemVariants} | ||
initial={false} | ||
animate="mounted" | ||
exit="dismissed" | ||
pb={2} | ||
_last={{ pb: 0 }} | ||
> | ||
<ActivitiesListItem | ||
{...item} | ||
handleDismiss={() => handleItemDismiss(item.txHash)} | ||
/> | ||
</MotionListItem> | ||
)} | ||
</AnimatePresence> | ||
))} | ||
</MotionList> | ||
) | ||
} | ||
|
||
export default ActivitiesList |
93 changes: 93 additions & 0 deletions
93
dapp/src/components/shared/ActivitiesList/ActivitiesListItem.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,93 @@ | ||
import React from "react" | ||
import { ArrowUpRight, LoadingSpinnerSuccessIcon } from "#/assets/icons" | ||
import { Activity as ActivityType } from "#/types" | ||
import { | ||
Alert, | ||
AlertDescription, | ||
AlertIcon, | ||
AlertProps, | ||
AlertTitle, | ||
Button, | ||
HStack, | ||
Text, | ||
VStack, | ||
VisuallyHidden, | ||
} from "@chakra-ui/react" | ||
import { CurrencyBalance } from "../CurrencyBalance" | ||
import Spinner from "../Spinner" | ||
import BlockExplorerLink from "../BlockExplorerLink" | ||
|
||
type ActivitiesListItemProps = Omit<AlertProps, "status"> & | ||
ActivityType & { | ||
handleDismiss?: () => void | ||
} | ||
|
||
function ActivitiesListItem(props: ActivitiesListItemProps) { | ||
const { amount, status, txHash, type, handleDismiss, ...restProps } = props | ||
|
||
return ( | ||
<Alert as={HStack} variant="process" {...restProps}> | ||
<AlertIcon | ||
color="brand.400" | ||
as={status === "completed" ? LoadingSpinnerSuccessIcon : Spinner} | ||
/> | ||
|
||
<VStack flex={1} spacing={0} align="stretch"> | ||
<HStack justify="space-between" as={AlertTitle}> | ||
<Text as="span"> | ||
{status === "completed" | ||
? `${type === "withdraw" ? "Unstaking" : "Staking"} completed` | ||
: `${type === "withdraw" ? "Unstaking" : "Staking"}...`} | ||
</Text> | ||
|
||
<CurrencyBalance amount={amount} currency="bitcoin" /> | ||
</HStack> | ||
<HStack justify="space-between" as={AlertDescription}> | ||
{status === "completed" ? ( | ||
<Button | ||
variant="link" | ||
fontSize="sm" | ||
lineHeight={5} | ||
onClick={handleDismiss} | ||
> | ||
Ok, dismiss | ||
</Button> | ||
) : ( | ||
// TODO: To implement. Estimated activity time is not in scope of MVP. | ||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
<> | ||
{/* <Text as="span">Est. time remaining</Text> | ||
<Text as="span" fontWeight="bold"> | ||
{new Date(estimatedTime).getHours()}h | ||
</Text> */} | ||
</> | ||
)} | ||
</HStack> | ||
</VStack> | ||
|
||
{txHash && ( | ||
<BlockExplorerLink | ||
id={txHash} | ||
chain="bitcoin" | ||
type="transaction" | ||
display="flex" | ||
my={-4} | ||
ml={6} | ||
mr={-6} | ||
h="auto" | ||
alignSelf="stretch" | ||
borderLeftWidth={1} | ||
borderColor="inherit" | ||
rounded={0} | ||
px={4} | ||
py={5} | ||
> | ||
<ArrowUpRight color="gray.500" boxSize={4} alignSelf="center" /> | ||
<VisuallyHidden>View transaction details</VisuallyHidden> | ||
</BlockExplorerLink> | ||
)} | ||
</Alert> | ||
) | ||
} | ||
|
||
export default ActivitiesListItem |
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 @@ | ||
export { default as ActivitiesList } from "./ActivitiesList" |
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