From 115c4fc60c7c3e5fa6874d4f0c14cb998c8a85b3 Mon Sep 17 00:00:00 2001 From: Tanish Manku <-h> Date: Wed, 19 Mar 2025 23:58:53 -0700 Subject: [PATCH] Add a generation mode UI component --- .../GenerationRootComponent.tsx | 24 +++++++++++++++++ .../realtime/src/app/pages/main/index.tsx | 27 +++++++++++++++++-- .../features/ToolbarTopLeft/index.tsx | 3 ++- .../realtime/src/signals/uiEvents/appMode.ts | 2 +- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 frontend/realtime/src/GenerationRootComponent/GenerationRootComponent.tsx diff --git a/frontend/realtime/src/GenerationRootComponent/GenerationRootComponent.tsx b/frontend/realtime/src/GenerationRootComponent/GenerationRootComponent.tsx new file mode 100644 index 0000000000..65107cfcde --- /dev/null +++ b/frontend/realtime/src/GenerationRootComponent/GenerationRootComponent.tsx @@ -0,0 +1,24 @@ +import { faSparkles } from "@fortawesome/pro-solid-svg-icons"; +import { Button } from "~/components/ui"; +import { useRenderCounter } from "~/hooks/useRenderCounter"; + +export const GenerationRootComponent = () => { + // This is a hook that will log the number of times the component has rerendered + // Let's make sure we only log once + useRenderCounter("GenerationRootComponent"); + + return ( + <> +
+
+ Generate Image + Imagine, Describe, Generate. +
+
+ + +
+
+ + ); +}; diff --git a/frontend/realtime/src/app/pages/main/index.tsx b/frontend/realtime/src/app/pages/main/index.tsx index 268921ba9b..a4caeb7ac8 100644 --- a/frontend/realtime/src/app/pages/main/index.tsx +++ b/frontend/realtime/src/app/pages/main/index.tsx @@ -10,6 +10,9 @@ import { KonvaRootComponent } from "~/KonvaRootComponent"; import { ToolbarTopLeft } from "~/components/features/ToolbarTopLeft"; import { ToolbarTopRight } from "~/components/features/ToolbarTopRight"; import { ToolbarTopCenter } from "~/components/features/ToolbarTopCenter"; +import { appMode } from "~/signals"; +import { useSignals } from "@preact/signals-react/runtime"; +import { GenerationRootComponent } from "~/GenerationRootComponent/GenerationRootComponent"; export const Main = withProtectionRoute(() => { // This is a hook that will log the number of times the component has rerendered @@ -19,12 +22,32 @@ export const Main = withProtectionRoute(() => { if (import.meta.env.DEV && sceneToken === "debug") { sceneToken = "m_p8nkry6m5j22w586xyex0w4a4pznbx"; } - return ( -
+ + useSignals(); + + const appModeValue = appMode.value; + let childView; + + switch (appModeValue) { + case "edit": + break; + case "generate": + childView = ; + break; + case "image": + default: + childView = + + break; + } + + return ( +
+ {childView}
diff --git a/frontend/realtime/src/components/features/ToolbarTopLeft/index.tsx b/frontend/realtime/src/components/features/ToolbarTopLeft/index.tsx index 068dabced0..da63828bf7 100644 --- a/frontend/realtime/src/components/features/ToolbarTopLeft/index.tsx +++ b/frontend/realtime/src/components/features/ToolbarTopLeft/index.tsx @@ -14,12 +14,13 @@ export const ToolbarTopLeft = () => { const tabs: TabItem[] = [ { id: "image", label: "Image" }, { id: "edit", label: "Edit" }, + { id: "generate", label: "Generate" }, // { id: "video", label: "Video" }, ]; const handleTabChange = (tabId: string) => { // Update the global signal - dispatchUiEvents.changeAppMode(tabId as "image" | "edit"); + dispatchUiEvents.changeAppMode(tabId as "image" | "edit" | "generate"); }; console.log(appMode.value); diff --git a/frontend/realtime/src/signals/uiEvents/appMode.ts b/frontend/realtime/src/signals/uiEvents/appMode.ts index e2b721e6e1..4d15fb4a37 100644 --- a/frontend/realtime/src/signals/uiEvents/appMode.ts +++ b/frontend/realtime/src/signals/uiEvents/appMode.ts @@ -3,7 +3,7 @@ import { signal, effect } from "@preact/signals-core"; // this is to control the app mode - BFlat // Define the app mode types -export type AppModeType = "image" | "edit"; +export type AppModeType = "image" | "edit" | "generate"; // Create a signal for the current app mode export const appMode = signal("image");