From c0a2ea36fa0b658e7fd585875fdc1220df7bdaee Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Thu, 17 Jul 2025 19:11:01 -0700 Subject: [PATCH] Combine app.tsx with main.tsx --- src/App.tsx | 39 -------------------------------- src/{App.scss => Globals.scss} | 0 src/main.tsx | 41 ++++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 41 deletions(-) delete mode 100644 src/App.tsx rename src/{App.scss => Globals.scss} (100%) diff --git a/src/App.tsx b/src/App.tsx deleted file mode 100644 index 4113e3e..0000000 --- a/src/App.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { useEffect, useState } from 'react' -import './App.scss' -import Sidebar from './componets/Sidebar' -import Settings from './routes/Settings' -import Installs from './routes/Installs' - -export default function App () { - const [hash, setHash] = useState(window.location.hash || '#installs') - - useEffect(() => { - const onHashChange = () => setHash(window.location.hash || '#installs') - window.addEventListener('hashchange', onHashChange) - return () => window.removeEventListener('hashchange', onHashChange) - }, []) - - useEffect(() => { - const handler = (e: MouseEvent) => e.preventDefault() - document.addEventListener('contextmenu', handler) - return () => document.removeEventListener('contextmenu', handler) - }, []) - - function renderContent() { - if (hash === "#installs") { - return - } else if (hash === "#settings") { - return - } - return null - } - - return ( - <> - -
- {renderContent()} -
- - ) -} diff --git a/src/App.scss b/src/Globals.scss similarity index 100% rename from src/App.scss rename to src/Globals.scss diff --git a/src/main.tsx b/src/main.tsx index 197a6e3..8a36309 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,6 +1,43 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import ReactDOM from 'react-dom/client' -import App from './App' +import Installs from './routes/Installs' +import Settings from './routes/Settings' +import Sidebar from './componets/Sidebar' +import './Globals.scss' + +function App () { + const [hash, setHash] = useState(window.location.hash || '#installs') + + useEffect(() => { + const onHashChange = () => setHash(window.location.hash || '#installs') + window.addEventListener('hashchange', onHashChange) + return () => window.removeEventListener('hashchange', onHashChange) + }, []) + + useEffect(() => { + const handler = (e: MouseEvent) => e.preventDefault() + document.addEventListener('contextmenu', handler) + return () => document.removeEventListener('contextmenu', handler) + }, []) + + function renderContent() { + if (hash === "#installs") { + return + } else if (hash === "#settings") { + return + } + return null + } + + return ( + <> + +
+ {renderContent()} +
+ + ) +} ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(