refactor: moving from nextjs to vite+react

This commit is contained in:
Pihkaal
2024-01-28 12:14:04 +01:00
parent 9bb6ccdd4f
commit 8446ee6c65
52 changed files with 610 additions and 2337 deletions

View File

@@ -1,39 +0,0 @@
import {
createContext,
useEffect,
useContext,
useState,
ReactNode,
} from "react";
import axios from "axios";
import { Manifest } from "~/utils/types";
const AppContext = createContext<Manifest | undefined>(undefined);
export const AppContextProvider = (props: {
children: Array<ReactNode> | ReactNode;
}) => {
const [manifest, setManifest] = useState<Manifest>();
useEffect(() => {
axios
.get<Manifest>(
"https://raw.githubusercontent.com/pihkaal/pihkaal/main/manifest.json",
)
.then(x => {
setManifest(x.data);
console.log(x.data);
});
}, []);
return (
<AppContext.Provider value={manifest}>{props.children}</AppContext.Provider>
);
};
export const useApp = () => {
const context = useContext(AppContext);
if (!context) throw new Error("useApp must be used inside the app lol");
return context;
};

View File

@@ -1,18 +0,0 @@
import { createContext, useContext } from "react";
import { type TerminalRenderer } from "~/utils/terminal/renderer";
const TerminalCanvasContext = createContext<TerminalRenderer | undefined>(
undefined,
);
export const TerminalCanvasContextProvider = TerminalCanvasContext.Provider;
export const useTerminalCanvas = () => {
const context = useContext(TerminalCanvasContext);
if (!context)
throw new Error(
"useTerminalCanvas must be used inside a Terminal component",
);
return context;
};

View File

@@ -1,15 +0,0 @@
import { createContext, useContext } from "react";
const TerminalContext = createContext<
{ cols: number; rows: number } | undefined
>(undefined);
export const TerminalContextProvider = TerminalContext.Provider;
export const useTerminal = () => {
const context = useContext(TerminalContext);
if (!context)
throw new Error("useTerminal must be used inside a Terminal component");
return context;
};