Refactor: flow toolbar buttons disable intead of dissapear

This commit is contained in:
igorrCarvalho 2024-03-06 18:06:52 -03:00
commit 0f45a09494
4 changed files with 33 additions and 23 deletions

View file

@ -98,3 +98,4 @@ body {
.custom-hover:hover { .custom-hover:hover {
background-color: rgba(99, 102, 241, 0.1); /* Medium indigo color with 20% opacity */ background-color: rgba(99, 102, 241, 0.1); /* Medium indigo color with 20% opacity */
} }

View file

@ -20,7 +20,12 @@ import { Badge } from "../ui/badge";
import { Button } from "../ui/button"; import { Button } from "../ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs";
export default function IOView({ children, open, setOpen }): JSX.Element { export default function IOView({ children, open, setOpen, disable }: {
children: JSX.Element;
open: boolean;
setOpen: (open: boolean) => void;
disable?: boolean;
}): JSX.Element {
const inputs = useFlowStore((state) => state.inputs).filter( const inputs = useFlowStore((state) => state.inputs).filter(
(input) => input.type !== "ChatInput" (input) => input.type !== "ChatInput"
); );
@ -98,6 +103,7 @@ export default function IOView({ children, open, setOpen }): JSX.Element {
size={haveChat ? (selectedTab === 0 ? "large-thin" : "large") : "small"} size={haveChat ? (selectedTab === 0 ? "large-thin" : "large") : "small"}
open={open} open={open}
setOpen={setOpen} setOpen={setOpen}
disable={disable}
> >
<BaseModal.Trigger>{children}</BaseModal.Trigger> <BaseModal.Trigger>{children}</BaseModal.Trigger>
{/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */} {/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */}

View file

@ -51,9 +51,9 @@ export default function FlowToolbar({ flow }: ChatType): JSX.Element {
<button <button
disabled={!hasApiKey || !validApiKey || !hasStore} disabled={!hasApiKey || !validApiKey || !hasStore}
className={classNames( className={classNames(
"relative inline-flex w-full h-full items-center justify-center hover:bg-hover bg-muted hover:bg-background px-5 py-3 text-foreground transition-all duration-500 ease-in-out gap-[4px] text-sm font-semibold", "relative inline-flex w-full h-full items-center justify-center hover:bg-hover bg-muted hover:bg-background px-5 py-3 text-foreground transition-all duration-500 ease-in-out gap-[4px] text-sm font-semibold ",
!hasApiKey || !validApiKey || !hasStore !hasApiKey || !validApiKey || !hasStore
? "button-disable cursor-default text-muted-foreground" ? " button-disable text-muted-foreground "
: "" : ""
)} )}
> >
@ -87,14 +87,14 @@ export default function FlowToolbar({ flow }: ChatType): JSX.Element {
> >
<div <div
className={ className={
"shadow-round-btn-shadow hover:shadow-round-btn-shadow message-button-position flex items-center justify-center rounded-sm bg-muted shadow-md transition-all cursor-pointer gap-7 border" "shadow-round-btn-shadow hover:shadow-round-btn-shadow message-button-position flex items-center justify-center rounded-sm bg-muted shadow-md transition-all gap-7 border"
} }
> >
<div className="flex"> <div className="flex">
<div className="flex gap-1 text-medium-indigo rounded-sm transition-all w-full h-full"> <div className="flex gap-1 text-medium-indigo rounded-sm transition-all w-full h-full">
{hasIO && ( {hasIO ? (
<IOView open={open} setOpen={setOpen}> <IOView open={open} setOpen={setOpen} disable={!hasIO}>
<div className="relative inline-flex w-full items-center justify-center hover:bg-hover transition-all duration-500 ease-in-out px-5 py-3 text-medium-indigo ease-in-out gap-1 text-sm font-semibold"> <div className="relative inline-flex w-full items-center justify-center hover:bg-hover transition-all duration-500 ease-in-out px-5 py-3 text-medium-indigo ease-in-out gap-1 text-sm font-semibold transition-all">
<ForwardedIconComponent <ForwardedIconComponent
name="Zap" name="Zap"
className={"message-button-icon h-5 w-5 transition-all"} className={"message-button-icon h-5 w-5 transition-all"}
@ -102,14 +102,20 @@ export default function FlowToolbar({ flow }: ChatType): JSX.Element {
Run Run
</div> </div>
</IOView> </IOView>
) : (
<div className={`relative inline-flex w-full items-center justify-center transition-all duration-500 ease-in-out px-5 py-3 text-muted-foreground ease-in-out gap-1 text-sm font-semibold cursor-not-allowed`}>
<ForwardedIconComponent
name="Zap"
className={"message-button-icon h-5 w-5 transition-all fill-muted-foreground stroke-muted-foreground"}
/>
Run
</div>
)} )}
</div> </div>
{hasIO && ( <div>
<div> <Separator orientation="vertical" />
<Separator orientation="vertical" /> </div>
</div> <div className="flex items-center gap-2 cursor-pointer">
)}
<div className="flex items-center gap-2">
{currentFlow && currentFlow.data && ( {currentFlow && currentFlow.data && (
<ApiModal flow={currentFlow}> <ApiModal flow={currentFlow}>
<div className={classNames("relative inline-flex w-full items-center justify-center hover:bg-hover px-5 py-3 text-foreground transition-all duration-500 ease-in-out gap-1 text-sm font-semibold")}> <div className={classNames("relative inline-flex w-full items-center justify-center hover:bg-hover px-5 py-3 text-foreground transition-all duration-500 ease-in-out gap-1 text-sm font-semibold")}>
@ -122,15 +128,11 @@ export default function FlowToolbar({ flow }: ChatType): JSX.Element {
</ApiModal> </ApiModal>
)} )}
</div> </div>
{hasStore && validApiKey && ( <div>
<div> <Separator orientation="vertical" />
<Separator orientation="vertical" /> </div>
</div>
)}
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{hasStore && validApiKey && ( <div className={`side-bar-button ${!hasApiKey || !validApiKey || !hasStore ? " cursor-not-allowed" : " cursor-pointer"}`}>{ModalMemo}</div>
<div className="side-bar-button">{ModalMemo}</div>
)}
</div> </div>
</div> </div>
</div> </div>

View file

@ -51,7 +51,7 @@
--component-icon: #d8598a; --component-icon: #d8598a;
--flow-icon: #2f67d0; --flow-icon: #2f67d0;
--hover: #F2F4F5; --hover: #F2F4F5;
--disabled-run: #6366f1;
/* Colors that are shared in dark and light mode */ /* Colors that are shared in dark and light mode */
@ -73,6 +73,7 @@
--foreground: 213 31% 80%; /* hsl(213 31% 91%) */ --foreground: 213 31% 80%; /* hsl(213 31% 91%) */
--ice: #60A5FA; --ice: #60A5FA;
--hover: #1A202E; --hover: #1A202E;
--disabled-run: #6366f1;
--muted: 223 27% 11%; /* hsl(223 27% 11%) */ --muted: 223 27% 11%; /* hsl(223 27% 11%) */
--muted-foreground: 215.4 16.3% 56.9%; /* hsl(215 16% 56%) */ --muted-foreground: 215.4 16.3% 56.9%; /* hsl(215 16% 56%) */