From 3b6992bb6d10e885fe5a4b0d13af7a9d0517df14 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Thu, 29 Jul 2021 15:53:52 -0300 Subject: [PATCH] Add block enter/leave animation --- package-lock.json | 19 +++++++++++++++++++ package.json | 1 + src/special/Blocks.tsx | 41 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 030da6f..c007f44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@fortawesome/free-regular-svg-icons": "^5.15.3", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/react-fontawesome": "^0.1.14", + "@headlessui/react": "^1.4.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", @@ -2106,6 +2107,18 @@ "@hapi/hoek": "^8.3.0" } }, + "node_modules/@headlessui/react": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-1.4.0.tgz", + "integrity": "sha512-C+FmBVF6YGvqcEI5fa2dfVbEaXr2RGR6Kw1E5HXIISIZEfsrH/yuCgsjWw5nlRF9vbCxmQ/EKs64GAdKeb8gCw==", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^16 || ^17 || ^18", + "react-dom": "^16 || ^17 || ^18" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "license": "ISC", @@ -20444,6 +20457,12 @@ "@hapi/hoek": "^8.3.0" } }, + "@headlessui/react": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-1.4.0.tgz", + "integrity": "sha512-C+FmBVF6YGvqcEI5fa2dfVbEaXr2RGR6Kw1E5HXIISIZEfsrH/yuCgsjWw5nlRF9vbCxmQ/EKs64GAdKeb8gCw==", + "requires": {} + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "requires": { diff --git a/package.json b/package.json index 45622fc..ba22ba7 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@fortawesome/free-regular-svg-icons": "^5.15.3", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/react-fontawesome": "^0.1.14", + "@headlessui/react": "^1.4.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", diff --git a/src/special/Blocks.tsx b/src/special/Blocks.tsx index d1cc325..afceb33 100644 --- a/src/special/Blocks.tsx +++ b/src/special/Blocks.tsx @@ -1,12 +1,13 @@ import React, { useState, useEffect, useContext } from "react"; import { ethers } from "ethers"; +import { Transition } from "@headlessui/react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faBurn, faGasPump } from "@fortawesome/free-solid-svg-icons"; import BlockRecord from "./BlockRecord"; import { ExtendedBlock, readBlock } from "../useErigonHooks"; import { RuntimeContext } from "../useRuntime"; -const MAX_BLOCK_HISTORY = 10; +const MAX_BLOCK_HISTORY = 20; type BlocksProps = { latestBlock: ethers.providers.Block; @@ -27,7 +28,7 @@ const Blocks: React.FC = ({ latestBlock }) => { if (_blocks.length > 0 && latestBlock.number === _blocks[0].number) { return _blocks; } - return [extBlock, ..._blocks].slice(0, MAX_BLOCK_HISTORY); + return [extBlock, ..._blocks].slice(0, MAX_BLOCK_HISTORY + 1); }); }; _readBlock(); @@ -54,8 +55,40 @@ const Blocks: React.FC = ({ latestBlock }) => {
Gas target
Rewards
- {blocks.map((b) => ( - +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {blocks.map((b, i) => ( + + + ))}