diff --git a/src/components/App.tsx b/src/components/App.tsx index 2786b2e..d2dc835 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -25,26 +25,40 @@ const App: React.FC = () => { return (
-
- -

Web3 Browser

-
+ +
+ +

Web3 Browser

+
+
- {ethStatus?.syncState === "syncing" || + {true || ethStatus?.syncState === "syncing" || handshakeStatus?.syncState === "syncing" ? (
{ethStatus?.syncState === "syncing" ? ( - - {ethStatus.sync.toFixed(0)}% Syncing Ethereum Network + + + {ethStatus.sync.toFixed(1)}% Syncing Ethereum Network + + ) : ethStatus?.syncState === "done" ? ( + + + {" "} Ethereum Synced ) : null} {handshakeStatus?.syncState === "syncing" ? ( - - {handshakeStatus.sync.toFixed(1)}% Syncing Handshake Network + + + {handshakeStatus.sync.toFixed(1)}% Syncing Ethereum Network + + ) : handshakeStatus?.syncState === "done" ? ( + + + {" "} Handshake Synced ) : null}
@@ -53,6 +67,46 @@ const App: React.FC = () => { ); }; +const CircleProgressBar = ({ radius, strokeWidth, textSize, percentage } : {radius: number, strokeWidth: number, textSize?: number, percentage: number}) => { + const circumference = 2 * Math.PI * radius; + const offset = circumference - (percentage / 100) * circumference; + const color = Math.ceil(percentage) >= 100 ? "green-500" : "orange-400" + + return ( + + + + {textSize ? + {`${percentage}%`} + : null } + + ); +}; + const Root = () => { return ( diff --git a/src/components/Browser.tsx b/src/components/Browser.tsx index 629e54d..a962a23 100644 --- a/src/components/Browser.tsx +++ b/src/components/Browser.tsx @@ -29,6 +29,7 @@ import { useAuth, useLumeStatus, } from "@lumeweb/sdk"; +import StartPage from "./StartPage"; let BOOT_FUNCTIONS: (() => Promise)[] = []; @@ -150,22 +151,29 @@ const NavInput = forwardRef( }, ); +function parseUrl(url: string) { + let input = url.trim(); + + // If the input doesn't contain a protocol, assume it's http + if (!input?.match(/^https?:\/\//)) { + input = `http://${input}`; + } + + return new URL(input); +} + export function Navigator() { const { url: contextUrl, setUrl } = useBrowserState(); const { ready } = useLumeStatus(); const inputEl = useRef(); const browse = (inputValue: string) => { - let input = inputValue.trim(); - - // If the input doesn't contain a protocol, assume it's http - if (!input?.match(/^https?:\/\//)) { - input = `http://${input}`; - } - try { + if(inputValue === "") { + setUrl("about:blank") + } // Try to parse it as a URL - const url = new URL(input); + const url = parseUrl(inputValue); setUrl(url.toString() || "about:blank"); } catch (e) { @@ -197,7 +205,9 @@ export function Navigator() { (inputEl.current = el)} disabled={!ready} - className={`rounded-l-full bg-neutral-800 text-white border-none focus-visible:ring-offset-0 ${!ready ? "bg-neutral-950" : ""}`} + className={`rounded-l-full bg-neutral-800 text-white border-none focus-visible:ring-offset-0 ${ + !ready ? "bg-neutral-950" : "" + }`} name="url" /> + ))} + + + ) : ( +
+

Be patient

+

We are starting the engines.

+
+ )} + + ); +}; + +export default StartPage; + +const CircleProgressBar = ({ + radius, + strokeWidth, + textSize, + percentage, +}: { + radius: number; + strokeWidth: number; + textSize: number; + percentage: number; +}) => { + const circumference = 2 * Math.PI * radius; + const offset = circumference - (percentage / 100) * circumference; + + return ( + + + + + {`${percentage}%`} + + + ); +}; diff --git a/tailwind.config.js b/tailwind.config.js index b5bfccc..be11b37 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,7 @@ /** @type {import('tailwindcss').Config} */ module.exports = { darkMode: ["class"], + safelist: ["fill-green-500", "stroke-green-500", "fill-orange-400", "stroke-orange-400"], content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], theme: { container: {