From 5ed32cb573f132832c55902ddbe099f816bcc5cc Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Fri, 22 Nov 2024 12:30:38 -0300 Subject: [PATCH] feat: Add PlaygroundButton component to flow toolbar (#4712) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ (playground-button.tsx): Add a new PlaygroundButton component to the flowToolbarComponent to handle the display of the Playground button based on the presence of Chat Input or Chat Output components. 📝 (index.tsx): Import and use the PlaygroundButton component in the FlowToolbar component to replace the previous implementation of the Playground button display. 🔧 (applies.css): Add styling for the playground-btn-flow-toolbar class to ensure consistent styling for the Playground button in the toolbar. * 📝 (playground-button.tsx): update import path for IOModal to point to the newModal file instead of the old one --- .../components/playground-button.tsx | 50 +++++++++++++++++++ .../components/flowToolbarComponent/index.tsx | 39 +++------------ src/frontend/src/style/applies.css | 4 ++ 3 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 src/frontend/src/components/flowToolbarComponent/components/playground-button.tsx diff --git a/src/frontend/src/components/flowToolbarComponent/components/playground-button.tsx b/src/frontend/src/components/flowToolbarComponent/components/playground-button.tsx new file mode 100644 index 000000000..261dfe56f --- /dev/null +++ b/src/frontend/src/components/flowToolbarComponent/components/playground-button.tsx @@ -0,0 +1,50 @@ +import ForwardedIconComponent from "@/components/genericIconComponent"; +import ShadTooltip from "@/components/shadTooltipComponent"; +import IOModal from "@/modals/IOModal/newModal"; + +const PlaygroundButton = ({ hasIO, open, setOpen, canvasOpen }) => { + const PlayIcon = () => ( + + ); + + const ButtonLabel = () => Playground; + + const ActiveButton = () => ( +
+ + +
+ ); + + const DisabledButton = () => ( +
+ + +
+ ); + + return hasIO ? ( + + + + ) : ( + +
+ +
+
+ ); +}; + +export default PlaygroundButton; diff --git a/src/frontend/src/components/flowToolbarComponent/index.tsx b/src/frontend/src/components/flowToolbarComponent/index.tsx index 0784f5e98..fedc7f259 100644 --- a/src/frontend/src/components/flowToolbarComponent/index.tsx +++ b/src/frontend/src/components/flowToolbarComponent/index.tsx @@ -15,6 +15,7 @@ import { useShortcutsStore } from "../../stores/shortcuts"; import { useStoreStore } from "../../stores/storeStore"; import { classNames, isThereModal } from "../../utils/utils"; import ForwardedIconComponent from "../genericIconComponent"; +import PlaygroundButton from "./components/playground-button"; export default function FlowToolbar(): JSX.Element { const preventDefault = true; @@ -125,38 +126,12 @@ export default function FlowToolbar(): JSX.Element { >
- {hasIO ? ( - -
- - Playground -
-
- ) : ( - -
- - Playground -
-
- )} +
{ENABLE_API && ( <> diff --git a/src/frontend/src/style/applies.css b/src/frontend/src/style/applies.css index e4089c842..42cadc8f6 100644 --- a/src/frontend/src/style/applies.css +++ b/src/frontend/src/style/applies.css @@ -1268,6 +1268,10 @@ .toolbar-wrapper { @apply flex h-10 items-center gap-1 rounded-xl border border-border bg-background p-1 shadow-sm; } + + .playground-btn-flow-toolbar { + @apply relative inline-flex h-8 w-full items-center justify-center gap-1.5 rounded px-3 py-1.5 text-sm font-semibold transition-all duration-500 ease-in-out; + } } /* Gradient background */