From 9b559b0d291263635c9263c5030805db31873a11 Mon Sep 17 00:00:00 2001 From: GeorginaShall <123496642+GeorginaShall@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:34:29 +0200 Subject: [PATCH] APT-1637 APT-1638 APT-1639 APT-1640 APT-1641 APT-1642 APT-1643 (#22) * APT-1637 * APT-1640 * APT-1641 * APT-1642 * APT-1643 * APT-1639 * APT-1642-fix * APT-1638 --- src/assets/svgs/plus.svg | 3 + src/components/stakingPoolCard.tsx | 10 +- src/components/stakingPoolDetailsView.tsx | 13 ++- src/components/stakingPoolsList.tsx | 2 +- src/pages/_app.tsx | 114 ++++++++++++++-------- src/pages/index.tsx | 35 ++++--- src/styles/globals.css | 4 + 7 files changed, 121 insertions(+), 60 deletions(-) create mode 100644 src/assets/svgs/plus.svg diff --git a/src/assets/svgs/plus.svg b/src/assets/svgs/plus.svg new file mode 100644 index 0000000..894b319 --- /dev/null +++ b/src/assets/svgs/plus.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/stakingPoolCard.tsx b/src/components/stakingPoolCard.tsx index 10a3f52..8d645eb 100644 --- a/src/components/stakingPoolCard.tsx +++ b/src/components/stakingPoolCard.tsx @@ -79,24 +79,24 @@ const StakingPoolCard: React.FC = ({ { stakingPoolData.data ? (
= 50 ? 'text-red1' : stakingPoolData.data.votingPower * 100 >= 30 ? 'text-orange1' - : 'text-gray4' + : '' }`} > VP {(stakingPoolData.data.votingPower * 100).toPrecision(3)}%
) : ( <> - VP + VP ) } -
+
Commission{' '} { stakingPoolData.data ? ( @@ -111,7 +111,7 @@ const StakingPoolCard: React.FC = ({
-
+
APR diff --git a/src/components/stakingPoolDetailsView.tsx b/src/components/stakingPoolDetailsView.tsx index 966469a..3273991 100644 --- a/src/components/stakingPoolDetailsView.tsx +++ b/src/components/stakingPoolDetailsView.tsx @@ -17,6 +17,8 @@ import { DateTime } from 'luxon'; import { useState } from 'react'; import { useWatchAsset } from 'wagmi'; import { useWalletClient } from 'wagmi'; +import Plus from '../assets/svgs/plus.svg' +import Image from 'next/image'; interface StakingPoolDetailsViewProps { stakingPoolData: StakingPool; @@ -120,9 +122,16 @@ const StakingPoolDetailsView: React.FC<
diff --git a/src/components/stakingPoolsList.tsx b/src/components/stakingPoolsList.tsx index 57ff5d4..b03fba0 100644 --- a/src/components/stakingPoolsList.tsx +++ b/src/components/stakingPoolsList.tsx @@ -73,7 +73,7 @@ const StakingPoolsList: React.FC = () => {
+ scrollbar-thin scrollbar-thumb-gray1 scrollbar-track-gray3 hover:scrollbar-thumb-gray2 pb-20 md:px-7 lg:px-2 xl:px-8"> {sortedStakingPoolsData.map(({ stakingPool, userData }) => ( (null); const [loadingPercentage, setLoadingPercentage] = useState(0); - - useEffect(() => { - fetch("/api/config") - .then((res) => res.json()) - .then(setAppConfig) - .catch(console.error); - }, []); + const [displayedPercentage, setDisplayedPercentage] = useState(0); + const [fadeOut, setFadeOut] = useState(false); useEffect(() => { const fetchConfig = async () => { + const startTime = Date.now(); + let progress = 0; + + const interval = setInterval(() => { + progress += 10; + setLoadingPercentage(progress); + if (progress >= 100) { + clearInterval(interval); + } + }, 50); + try { const res = await fetch("/api/config"); - const reader = res.body?.getReader(); - const contentLength = res.headers.get("Content-Length"); - - if (reader && contentLength) { - const totalLength = parseInt(contentLength, 10); - let loaded = 0; - while (true) { - const { done, value } = await reader.read(); - if (done) break; - - loaded += value?.length || 0; - const progress = Math.round((loaded / totalLength) * 100); - setLoadingPercentage(progress); - } - } - const data = await res.json(); - setAppConfig(data); + const elapsedTime = Date.now() - startTime; + + const remainingTime = Math.max(1000 - elapsedTime, 0); + setTimeout(() => { + clearInterval(interval); + setLoadingPercentage(100); + setTimeout(() => { + setAppConfig(data); + }, 500); + setFadeOut(true); + }, remainingTime); } catch (error) { - console.error(error); + console.error("Error loading config:", error); } }; - + fetchConfig(); }, []); + useEffect(() => { + const duration = 500; + const frameRate = 16; + const totalFrames = duration / frameRate; + const increment = (loadingPercentage - displayedPercentage) / totalFrames; - if (!appConfig) { - return( -
-
-
+ if (increment !== 0) { + let currentFrame = 0; + const easingInterval = setInterval(() => { + setDisplayedPercentage((prev) => { + currentFrame += 1; + const next = prev + increment; + if ( + currentFrame >= totalFrames || + (increment > 0 && next >= loadingPercentage) || + (increment < 0 && next <= loadingPercentage) + ) { + clearInterval(easingInterval); + return loadingPercentage; + } + return next; + }); + }, frameRate); + + return () => clearInterval(easingInterval); + } + }, [loadingPercentage]); + + if (!appConfig) { + return (
-
-
{loadingPercentage}%
-
- ) -} + className={`h-screen bg-black text-white transition-opacity duration-500 ${ + fadeOut ? "opacity-0" : "opacity-100" + }`} + > +
+
+
+
+
+ {Math.round(displayedPercentage)}% +
+
+
+ ); + } return ( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 2f0a5fd..1ad007a 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -12,12 +12,19 @@ import { WalletOutlined } from '@ant-design/icons'; import { ConnectButton } from '@rainbow-me/rainbowkit'; import { Button, Modal } from 'antd'; import Image from 'next/image'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import ArrowBack from '../assets/svgs/arrow-back-white.svg' import ArrowNext from '../assets/svgs/arrow-next-black.svg' const HomePage = () => { + + const [isVisible, setIsVisible] = useState(false); + + useEffect(() => { + setIsVisible(true); + }, []); + const { appConfig } = AppConfigStorage.useContainer(); @@ -48,7 +55,7 @@ const HomePage = () => { const [mobileShowClaims, setMobileShowClaims] = useState(false); const mobileOverlayWrapper = (children: React.ReactNode) => ( -
+
{children}
) @@ -209,11 +216,13 @@ const HomePage = () => { ) return ( -
+
{/* Header */}
-
+
{ <> { connectedWalletType === ConnectedWalletType.MockWallet ? ( -
-
-
+
{formatAddress(walletAddress || '')}
- + Disconnect - -
-
+ + + ) : ( ) @@ -260,7 +269,7 @@ const HomePage = () => {
-
+
{/* Left column */}
diff --git a/src/styles/globals.css b/src/styles/globals.css index 996cce1..32260b7 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -152,6 +152,10 @@ body { @apply font-int-semibold text-12 xs:text-14 lg:text-16 leading-5 lg:leading-6 text-gray2; } + .base-medium { + @apply font-int-medium text-12 xs:text-14 lg:text-16 leading-5 lg:leading-6 text-gray2 ; + } + .regular-base { @apply font-int-regular text-12 xs:text-14 lg:text-16 leading-5 lg:leading-6 text-gray2; }