Start patcher view work

This commit is contained in:
2024-11-27 07:53:00 -06:00
parent f12a9ed53b
commit 70a1ec2203
3 changed files with 49 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
html, html,
body { body {
@apply h-screen w-screen bg-zinc-600 text-zinc-200; @apply h-screen w-screen bg-zinc-600 text-zinc-200 overflow-x-hidden;
} }
@layer base { @layer base {

View File

@@ -1,10 +1,22 @@
import { useState } from "preact/hooks";
import "./App.css"; import "./App.css";
import SaveSelector from "./views/SaveSelector"; import SaveSelector from "./views/SaveSelector";
import Patcher from "./views/Patcher";
function App() { function App() {
const [currentSave, setCurrentSave] = useState<string | null>(null);
return ( return (
<main class="h-[100vh] w-[100vw] bg-zinc-800 px-4 py-2 flex flex-col"> <main class="h-[100vh] w-[100vw] bg-zinc-800 px-4 py-2 flex flex-col">
<SaveSelector /> {currentSave === null ? (
<SaveSelector
onFile={(path) => {
setCurrentSave(path);
}}
/>
) : (
<Patcher path={currentSave} />
)}
</main> </main>
); );
} }

35
src/views/Patcher.tsx Normal file
View File

@@ -0,0 +1,35 @@
import { useEffect, useState } from "preact/hooks";
interface PatcherProps {
className?: string;
path: string;
}
export default function Patcher({ path }: PatcherProps) {
const [filename, setFilename] = useState<string | null>(null);
async function setup() {
const filename = path.split("\\").pop();
if (filename) setFilename(filename.split(".")[0]);
}
async function teardown() {}
useEffect(() => {
setup();
return () => {
teardown();
};
}, []);
return (
<div className="max-w-[600px]">
<div className="rounded-xl bg-black/40 px-3.5 py-2">
<p className="text-sm text-zinc-300">{filename}</p>
<p className="flex justify-end overflow-hidden text-xs text-zinc-400">
{path}
</p>
</div>
</div>
);
}