diff --git a/src/App.tsx b/src/App.tsx index 23759d0..1ad1135 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,51 +1,42 @@ import { useEffect } from "react"; -import { useStore } from "./store/useStore"; +import { useStore } from "@/store/useStore"; -import { getDecodedParam } from "./lib/url"; +import { getDecodedParam } from "@/lib/url"; -import Editor from "./components/editor/editor"; -import ButtonsNav from "./components/nav-buttons"; -import Stats from "./components/editor/stats"; -import Terminal from "./components/editor/terminal"; +import Editor from "@/components/editor/editor"; +import ButtonsNav from "@/components/nav-buttons"; +import Stats from "@/components/editor/stats"; +import Terminal from "@/components/editor/terminal"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup -} from "./components/ui/resizable"; +} from "@/components/ui/resizable"; -function App() { +export default function App() { const { direction, setCode, initializePyodide, isPyodideLoading } = useStore(); // Initialize Pyodide and ( set the code from URL params if present ) useEffect(() => { - initializePyodide(); + const initializeApp = async () => { + await initializePyodide(); - const urlParams = new URLSearchParams(window.location.search); - const encodedParam = urlParams.get("v"); - if (encodedParam) { - const decodedCode = getDecodedParam(encodedParam); - if (decodedCode) { - setCode(decodedCode); + const urlParams = new URLSearchParams(window.location.search); + const encodedParam = urlParams.get("v"); + if (encodedParam) { + const decodedCode = getDecodedParam(encodedParam); + if (decodedCode) { + setCode(decodedCode); + } } - } + }; + + initializeApp(); }, [initializePyodide, setCode]); if (isPyodideLoading) { - return ( -
-
- logo -

- Loading WebAssembly -

-
-
- ); + return ; } return ( @@ -68,4 +59,19 @@ function App() { ); } -export default App; +function LoadingScreen() { + return ( +
+
+ logo +

+ Loading WebAssembly +

+
+
+ ); +} diff --git a/src/components/editor/stats.tsx b/src/components/editor/stats.tsx index b3b73fc..3187c5c 100644 --- a/src/components/editor/stats.tsx +++ b/src/components/editor/stats.tsx @@ -9,7 +9,7 @@ interface CodeStats { characters: number; } -const Stats = () => { +export default function Stats() { const { code } = useStore(); const stats: CodeStats = useMemo( @@ -42,24 +42,22 @@ const Stats = () => { ); -}; +} -const StatItem = ({ - icon, - value, - label -}: { +interface StatItemProps { icon: React.ReactNode; value: number; label: string; -}) => ( -
-
- {icon} - {value} -
- {label} -
-); +} -export default Stats; +function StatItem({ icon, value, label }: StatItemProps) { + return ( +
+
+ {icon} + {value} +
+ {label} +
+ ); +} diff --git a/src/components/editor/terminal.tsx b/src/components/editor/terminal.tsx index ac1744c..96520b6 100644 --- a/src/components/editor/terminal.tsx +++ b/src/components/editor/terminal.tsx @@ -1,5 +1,6 @@ import { useEffect, useState, useRef, useCallback, useMemo } from "react"; import { useStore } from "@/store/useStore"; + import Loader from "@/components/loader"; interface CommandHandlers { @@ -26,6 +27,7 @@ export default function Terminal() { } }, []); + // Scroll to bottom on output change useEffect(() => { scrollToBottom(); }, [output, scrollToBottom]); diff --git a/src/components/loader.tsx b/src/components/loader.tsx index dada0d9..95e4cae 100644 --- a/src/components/loader.tsx +++ b/src/components/loader.tsx @@ -1,6 +1,10 @@ import { LoaderCircleIcon } from "lucide-react"; -export default function Loader({ text }: { text: string }) { +interface LoaderProps { + text: string; +} + +export default function Loader({ text }: LoaderProps) { return (
diff --git a/src/components/settings.tsx b/src/components/settings.tsx index a535c29..7e19e81 100644 --- a/src/components/settings.tsx +++ b/src/components/settings.tsx @@ -21,15 +21,19 @@ import { LoaderIcon } from "lucide-react"; -const SettingsSection: React.FC<{ +interface SettingsSectionProps { title: string; children: React.ReactNode; -}> = ({ title, children }) => ( -
-

{title}

-
{children}
-
-); +} + +function SettingsSection({ title, children }: SettingsSectionProps) { + return ( +
+

{title}

+
{children}
+
+ ); +} export default function Settings() { const { code, pipInstall, isLibLoading } = useStore(); diff --git a/src/main.tsx b/src/main.tsx index 7a102df..20eacf5 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,10 +1,11 @@ +import "@/globals.css"; + import React from "react"; import ReactDOM from "react-dom/client"; -import "./globals.css"; -import App from "./App.tsx"; +import App from "@/App.tsx"; -ReactDOM.createRoot(document.getElementById("root")!).render( +ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(