-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improving masp loading states (#1583)
* fix: fixing button z-index * feat: improving loadings on masp overview
- Loading branch information
1 parent
58bb84d
commit 9879db0
Showing
12 changed files
with
231 additions
and
28 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,19 @@ | ||
import { lastCompletedShieldedSyncAtom } from "atoms/balance"; | ||
import { useRequiresNewShieldedSync } from "hooks/useRequiresNewShieldedSync"; | ||
import { useAtomValue } from "jotai"; | ||
import { MaspSyncCover } from "./MaspSyncCover"; | ||
|
||
type MaspContainerProps = React.PropsWithChildren; | ||
|
||
export const MaspContainer = ({ | ||
children, | ||
}: MaspContainerProps): JSX.Element => { | ||
const requiresNewSync = useRequiresNewShieldedSync(); | ||
const lastSync = useAtomValue(lastCompletedShieldedSyncAtom); | ||
return ( | ||
<div className="relative"> | ||
{children} | ||
{requiresNewSync && <MaspSyncCover longSync={lastSync === undefined} />} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import clsx from "clsx"; | ||
import { PulsingRing } from "./PulsingRing"; | ||
|
||
type MaspSyncCoverProps = { | ||
longSync?: boolean; | ||
}; | ||
|
||
export const MaspSyncCover = ({ | ||
longSync, | ||
}: MaspSyncCoverProps): JSX.Element => { | ||
return ( | ||
<div | ||
className={clsx( | ||
"absolute w-full h-full backdrop-blur-sm left-0 top-0 z-50 rounded-sm overflow-hidden", | ||
"bg-black/70" | ||
)} | ||
> | ||
<div | ||
className={clsx( | ||
"text-yellow text-center w-full", | ||
"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2" | ||
)} | ||
> | ||
<header className="flex w-full items-center justify-center mb-4 h-42"> | ||
<PulsingRing /> | ||
<h2 className="absolute text-3xl font-medium text"> | ||
Shielded Sync in Progress | ||
</h2> | ||
</header> | ||
<div className="relative z-40"> | ||
<div> | ||
<p> | ||
{longSync && ( | ||
<> | ||
Shielded sync can take a few minutes. <br /> | ||
</> | ||
)} | ||
Please wait to perform shielded actions. | ||
</p> | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import anime from "animejs"; | ||
import clsx from "clsx"; | ||
import { useScope } from "hooks/useScope"; | ||
import { useRef } from "react"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
type PulsingRingProps = { className?: string }; | ||
|
||
export const PulsingRing = ({ className }: PulsingRingProps): JSX.Element => { | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
|
||
useScope( | ||
(query) => { | ||
const items = Array.from(query("[data-animation=ring]")); | ||
|
||
const timeline = anime.timeline({ | ||
easing: "easeOutExpo", | ||
duration: 800, | ||
loop: true, | ||
}); | ||
|
||
timeline.add({ | ||
targets: items, | ||
duration: 0, | ||
translateY: "-50%", | ||
translateX: "-50%", | ||
}); | ||
|
||
timeline.add({ | ||
targets: items, | ||
opacity: [0, 1], | ||
scale: [0, 1], | ||
easing: "easeOutExpo", | ||
delay: anime.stagger(150), | ||
duration: 1100, | ||
}); | ||
|
||
timeline.add({ | ||
targets: items, | ||
opacity: 0, | ||
easing: "easeOutExpo", | ||
delay: anime.stagger(150, { direction: "reverse" }), | ||
}); | ||
}, | ||
containerRef, | ||
[] | ||
); | ||
|
||
const renderRing = (className: string): JSX.Element => { | ||
return ( | ||
<span | ||
data-animation="ring" | ||
className={clsx( | ||
"block absolute aspect-square border border-yellow rounded-full", | ||
"left-1/2 top-1/2 leading-[0]", | ||
className | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
return ( | ||
<span | ||
ref={containerRef} | ||
className={twMerge("block relative leading-0 bg-red-500", className)} | ||
> | ||
{renderRing("h-18")} | ||
{renderRing("h-30")} | ||
{renderRing("h-42")} | ||
</span> | ||
); | ||
}; |
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
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,24 @@ | ||
import { | ||
isShieldedSyncCompleteAtom, | ||
lastCompletedShieldedSyncAtom, | ||
} from "atoms/balance"; | ||
import { subMinutes } from "date-fns"; | ||
import { useAtomValue } from "jotai"; | ||
|
||
type RequiresNewShieldedSyncProps = { | ||
minutesToNextSync?: number; | ||
}; | ||
|
||
export const useRequiresNewShieldedSync = ({ | ||
minutesToNextSync = 3, | ||
}: RequiresNewShieldedSyncProps = {}): boolean => { | ||
const isComplete = useAtomValue(isShieldedSyncCompleteAtom); | ||
const lastSync = useAtomValue(lastCompletedShieldedSyncAtom); | ||
const requiresNewSync = | ||
lastSync === undefined || | ||
(!isComplete && | ||
lastSync && | ||
subMinutes(new Date(), minutesToNextSync) > lastSync); | ||
|
||
return requiresNewSync; | ||
}; |
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