diff --git a/site-new/assets/icons/RocketProgress.tsx b/site-new/assets/icons/RocketProgress.tsx new file mode 100644 index 000000000..28f95acff --- /dev/null +++ b/site-new/assets/icons/RocketProgress.tsx @@ -0,0 +1,27 @@ +import * as React from "react"; +import { SVGProps } from "react"; +const RocketProgress = (props: SVGProps) => ( + + + + + +); +export default RocketProgress; diff --git a/site-new/src/components/ReadingProgress/ReadingProgress.tsx b/site-new/src/components/ReadingProgress/ReadingProgress.tsx new file mode 100644 index 000000000..9d3925fdb --- /dev/null +++ b/site-new/src/components/ReadingProgress/ReadingProgress.tsx @@ -0,0 +1,44 @@ +import React, { useEffect, useRef } from "react"; +import RocketProgress from "@site/assets/icons/RocketProgress"; + +const ReadingProgress = () => { + const rocketRef = useRef(null); + const rocketBgRef = useRef(null); + + useEffect(() => { + const updateProgressBar = () => { + const { scrollTop, scrollHeight } = document.documentElement; + const scrollPercent = + (scrollTop / (scrollHeight - window.innerHeight)) * 100; + + if (rocketRef.current) { + rocketRef.current.style.left = `calc(${Math.max(scrollPercent)}%)`; + } + + if (rocketBgRef.current) { + rocketBgRef.current.style.width = `calc(${Math.max(scrollPercent)}%)`; + } + }; + document.addEventListener("scroll", updateProgressBar); + + return () => { + document.removeEventListener("scroll", updateProgressBar); + }; + }, [rocketRef, rocketBgRef]); + + return ( +
+
+ + + + +
+
+ ); +}; + +export default ReadingProgress; diff --git a/site-new/src/components/ReadingProgress/index.ts b/site-new/src/components/ReadingProgress/index.ts new file mode 100644 index 000000000..c3a063266 --- /dev/null +++ b/site-new/src/components/ReadingProgress/index.ts @@ -0,0 +1 @@ +export { default as ReadingProgress } from "./ReadingProgress"; diff --git a/site-new/src/pages/index.tsx b/site-new/src/pages/index.tsx index b7b08e6be..c6ac8e90e 100644 --- a/site-new/src/pages/index.tsx +++ b/site-new/src/pages/index.tsx @@ -9,6 +9,7 @@ import tbdRex from "@site/static/img/tbd-rex"; import { PixelBorderWrapper } from "../components/PixelBorder"; import { useEffect, useRef } from "react"; import { typeWriter, TypeWriterWordType } from "@site/lib/utils"; +import { ReadingProgress } from "../components/ReadingProgress"; const TYPE_WRITER_VARIABLE_TEXT = [ { @@ -47,6 +48,7 @@ export default function Home(): JSX.Element { title={`Hello from ${siteConfig.title}`} description="Description will go into a meta tag in " > +
@@ -60,7 +62,7 @@ export default function Home(): JSX.Element { className="mb-4 mt-twist-core-spacing-7 text-[48px] font-medium lg:text-[80px]" > The future of finance is{" "} - + Open