SelectView

This commit is contained in:
2026-08-18 10:06:18 +02:00
parent 9fcc966206
commit bb0b203275
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import Enclave from "./app/app"; import Enclave from "@/app/app";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
function App() { function App() {
+16
View File
@@ -0,0 +1,16 @@
export type ViewProps<C> = C extends React.ComponentType<infer P> ? P : never;
export default function SelectView<
T extends Record<string, React.ComponentType<any>>,
K extends keyof T,
>({
config,
views,
}: {
config: { currentView: K; viewProps: ViewProps<T[K]> };
views: T;
}) {
const ActiveView = views[config.currentView];
return <ActiveView {...config.viewProps} />;
}