From ab0209d3994d843b4664e8d106113716a5df8910 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 13 Jun 2023 11:22:43 -0300 Subject: [PATCH] Import shad dialog, CSS in general --- .../components/parameterComponent/index.tsx | 40 +-- .../components/dropdownComponent/index.tsx | 16 +- .../src/components/floatComponent/index.tsx | 2 +- .../src/components/inputComponent/index.tsx | 4 +- .../src/components/intComponent/index.tsx | 2 +- src/frontend/src/constants.tsx | 6 + src/frontend/src/modals/importModal/index.tsx | 305 ++++++++---------- .../extraSidebarComponent/index.tsx | 2 +- 8 files changed, 180 insertions(+), 197 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 84d806075..6e3a76415 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -205,15 +205,17 @@ export default function ParameterComponent({ /> ) : left === true && type === "float" ? ( - { - data.node.template[name].value = t; - save(); - }} - /> +
+ { + data.node.template[name].value = t; + save(); + }} + /> +
) : left === true && type === "str" && data.node.template[name].options ? ( @@ -250,15 +252,17 @@ export default function ParameterComponent({ }} > ) : left === true && type === "int" ? ( - { - data.node.template[name].value = t; - save(); - }} - /> +
+ { + data.node.template[name].value = t; + save(); + }} + /> +
) : left === true && type === "prompt" ? ( {internalValue} @@ -68,11 +68,8 @@ export default function Dropdown({ key={id} className={({ active }) => classNames( - active && !editNode - ? "text-white bg-indigo-600 dark:bg-indigo-500 dark:text-black" - : "text-gray-900", - active && editNode - ? "text-white bg-gray-400 dark:bg-gray-500 dark:text-gray-500" + active + ? "text-white bg-slate-400 dark:bg-white dark:text-gray-500" : "", editNode ? "relative cursor-default select-none py-0.5 pl-3 pr-12 dark:text-gray-300 dark:bg-gray-800" @@ -95,13 +92,16 @@ export default function Dropdown({ {selected ? ( diff --git a/src/frontend/src/components/floatComponent/index.tsx b/src/frontend/src/components/floatComponent/index.tsx index a7cf9b2e4..b27317022 100644 --- a/src/frontend/src/components/floatComponent/index.tsx +++ b/src/frontend/src/components/floatComponent/index.tsx @@ -36,7 +36,7 @@ export default function FloatComponent({ className={ editNode ? "text-center arrow-hide placeholder:text-center border-0 block w-full pt-0.5 pb-0.5 form-input dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm sm:text-sm focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200" - : "block w-full form-input dark:bg-gray-900 arrow-hide dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" + + : "block w-full form-input dark:bg-gray-900 arrow-hide dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 sm:text-sm" + (disabled ? " bg-gray-200 dark:bg-gray-700" : "") } placeholder={ diff --git a/src/frontend/src/components/inputComponent/index.tsx b/src/frontend/src/components/inputComponent/index.tsx index b7b245c75..4db9cc1bd 100644 --- a/src/frontend/src/components/inputComponent/index.tsx +++ b/src/frontend/src/components/inputComponent/index.tsx @@ -45,12 +45,12 @@ export default function InputComponent({ if (disableCopyPaste) setDisableCopyPaste(false); }} className={classNames( - "block w-full pr-12 form-input dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm sm:text-sm", + "block w-full pr-12 form-input dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm sm:text-sm", disabled ? " bg-gray-200 dark:bg-gray-700" : "", password && !pwdVisible && myValue !== "" ? "password" : "", editNode ? "placeholder:text-center border-0 block w-full pt-0.5 pb-0.5 form-input dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm sm:text-sm focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200 text-center" - : "focus:border-indigo-500 focus:ring-indigo-500", + : "ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", password && editNode ? "pr-8" : "pr-3" )} placeholder={password && editNode ? "Key" : "Type something..."} diff --git a/src/frontend/src/components/intComponent/index.tsx b/src/frontend/src/components/intComponent/index.tsx index e643eb5e9..38bf317b9 100644 --- a/src/frontend/src/components/intComponent/index.tsx +++ b/src/frontend/src/components/intComponent/index.tsx @@ -57,7 +57,7 @@ export default function IntComponent({ className={ editNode ? "text-center arrow-hide placeholder:text-center border-0 block w-full pt-0.5 pb-0.5 form-input dark:bg-gray-900 dark:text-gray-300 dark:border-gray-600 rounded-md border-gray-300 shadow-sm sm:text-sm focus:outline-none focus:ring-1 focus:ring-inset focus:ring-gray-200" - : "block w-full form-input dark:bg-gray-900 arrow-hide dark:border-gray-600 dark:text-gray-300 rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" + + : "block w-full form-input dark:bg-gray-900 arrow-hide dark:border-gray-600 dark:text-gray-300 rounded-md border-gray-300 shadow-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 sm:text-sm" + (disabled ? " bg-gray-200 dark:bg-gray-700" : "") } placeholder={editNode ? "Integer number" : "Type a integer number"} diff --git a/src/frontend/src/constants.tsx b/src/frontend/src/constants.tsx index 49b6ea194..93d9090b3 100644 --- a/src/frontend/src/constants.tsx +++ b/src/frontend/src/constants.tsx @@ -37,3 +37,9 @@ export const PROMPT_DIALOG_SUBTITLE = "Edit you prompt."; * @constant */ export const TEXT_DIALOG_SUBTITLE = "Edit you text."; + +/** + * The base text for subtitle of Import Dialog + * @constant + */ +export const IMPORT_DIALOG_SUBTITLE = "Import your models or pick one example."; diff --git a/src/frontend/src/modals/importModal/index.tsx b/src/frontend/src/modals/importModal/index.tsx index d0808c541..f6d82e852 100644 --- a/src/frontend/src/modals/importModal/index.tsx +++ b/src/frontend/src/modals/importModal/index.tsx @@ -1,4 +1,3 @@ -import { Dialog, Transition } from "@headlessui/react"; import { XMarkIcon, ArrowDownTrayIcon, @@ -6,6 +5,7 @@ import { ComputerDesktopIcon, ArrowUpTrayIcon, ArrowLeftIcon, + CommandLineIcon, } from "@heroicons/react/24/outline"; import { Fragment, useContext, useRef, useState } from "react"; import { PopUpContext } from "../../contexts/popUpContext"; @@ -17,6 +17,17 @@ import { alertContext } from "../../contexts/alertContext"; import LoadingComponent from "../../components/loadingComponent"; import { FlowType } from "../../types/flow"; import { classNames, snakeToSpaces, toNormalCase } from "../../utils"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "../../components/ui/dialog"; +import { Button } from "../../components/ui/button"; +import { IMPORT_DIALOG_SUBTITLE } from "../../constants"; export default function ImportModal() { const [open, setOpen] = useState(true); @@ -52,181 +63,143 @@ export default function ImportModal() { } return ( - - + + - -
- - -
-
- - -
+ + + {showExamples && ( + <> +
- {showExamples && ( - <> -
- -
- - )} -
-
-
-
-
- - {showExamples ? "Select an example" : "Import"} - -
-
-
- {!showExamples && ( -
- - } - onClick={() => { - setShowExamples(true); - handleExamples(); - }} - textColor="text-emerald-500 dark:text-emerald-500/75" - title="Examples" - > - - } - onClick={() => { - uploadFlow(); - setModalOpen(false); - }} - textColor="text-blue-500 dark:text-blue-500/75" - title="Local File" - > -
- )} - {showExamples && loadingExamples && ( -
- -
- )} - {showExamples && - !loadingExamples && - examples.map((example, index) => { - return ( -
- {" "} - - } - onClick={() => { - addFlow(example); - setModalOpen(false); - }} - textColor="text-emerald-500 dark:text-emerald-500/75" - title={example.name} - > -
- ); - })} -
- + + )} + + + {showExamples ? "Select an example" : "Import"} + +
-
-
+ + + + + + ); } diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index f0fe333d5..17eae19f2 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -56,7 +56,7 @@ export default function ExtraSidebar() { name="search" id="search" placeholder="Search nodes" - className="dark:text-white focus:outline-none block w-full rounded-md py-1.5 ps-3 pr-9 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 sm:text-sm sm:leading-6 dark:ring-0 dark:bg-[#2d3747] dark:focus:outline-none" + className="border-1 dark:border-slate-600 dark:border-0.5 dark:ring-0 focus-visible:dark:ring-0 focus-visible:dark:ring-offset-1 rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" onChange={(e) => { handleSearchInput(e.target.value); setSearch(e.target.value);