From 590fa672447c12aa3e19979dea106743dce1f090 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 1 Jan 2024 15:08:17 +0700 Subject: [PATCH] feat: finished new UI thread setting pannel --- uikit/src/tooltip/index.tsx | 3 + web/containers/CardSidebar/index.tsx | 93 +++++++++++----- web/containers/Checkbox/index.tsx | 30 +++++- web/containers/Layout/TopBar/index.tsx | 2 +- web/containers/ModelConfigInput/index.tsx | 28 ++++- web/containers/Slider/index.tsx | 27 ++++- .../Chat/ModelSetting/predefinedComponent.ts | 32 +++--- .../ModelSetting/settingComponentBuilder.tsx | 3 + web/screens/Chat/Sidebar/index.tsx | 102 ++++++++---------- web/utils/model_param.ts | 1 - 10 files changed, 216 insertions(+), 105 deletions(-) diff --git a/uikit/src/tooltip/index.tsx b/uikit/src/tooltip/index.tsx index 73c0e1e0bc..53e61d1752 100644 --- a/uikit/src/tooltip/index.tsx +++ b/uikit/src/tooltip/index.tsx @@ -8,6 +8,8 @@ const TooltipProvider = TooltipPrimitive.Provider const Tooltip = TooltipPrimitive.Root +const TooltipPortal = TooltipPrimitive.Portal + const TooltipTrigger = TooltipPrimitive.Trigger const TooltipContent = React.forwardRef< @@ -37,4 +39,5 @@ export { TooltipContent, TooltipProvider, TooltipArrow, + TooltipPortal, } diff --git a/web/containers/CardSidebar/index.tsx b/web/containers/CardSidebar/index.tsx index de0a409aee..5de2855695 100644 --- a/web/containers/CardSidebar/index.tsx +++ b/web/containers/CardSidebar/index.tsx @@ -13,14 +13,16 @@ import { useClickOutside } from '@/hooks/useClickOutside' interface Props { children: ReactNode title: string - onRevealInFinderClick: (type: string) => void - onViewJsonClick: (type: string) => void + onRevealInFinderClick?: (type: string) => void + onViewJsonClick?: (type: string) => void + asChild?: boolean } export default function CardSidebar({ children, title, onRevealInFinderClick, onViewJsonClick, + asChild, }: Props) { const [show, setShow] = useState(true) const [more, setMore] = useState(false) @@ -39,7 +41,8 @@ export default function CardSidebar({ return (
{title}
-
setMore(!more)} - > - -
+ {!asChild && ( +
setMore(!more)} + > + +
+ )}
)}
{show && ( -
+
{children}
)} diff --git a/web/containers/Checkbox/index.tsx b/web/containers/Checkbox/index.tsx index de18ca0520..074ed0e820 100644 --- a/web/containers/Checkbox/index.tsx +++ b/web/containers/Checkbox/index.tsx @@ -1,9 +1,18 @@ import React from 'react' -import { Switch } from '@janhq/uikit' +import { + Switch, + Tooltip, + TooltipArrow, + TooltipContent, + TooltipPortal, + TooltipTrigger, +} from '@janhq/uikit' import { useAtomValue } from 'jotai' +import { InfoIcon } from 'lucide-react' + import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' @@ -11,10 +20,11 @@ import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' type Props = { name: string title: string + description: string checked: boolean } -const Checkbox: React.FC = ({ name, title, checked }) => { +const Checkbox: React.FC = ({ name, title, checked, description }) => { const { updateModelParameter } = useUpdateModelParameters() const threadId = useAtomValue(getActiveThreadIdAtom) @@ -26,7 +36,21 @@ const Checkbox: React.FC = ({ name, title, checked }) => { return (
-

{title}

+
+

{title}

+ + + + + + + {description} + + + + +
+
) diff --git a/web/containers/Layout/TopBar/index.tsx b/web/containers/Layout/TopBar/index.tsx index 78e858c6aa..dd5358d82e 100644 --- a/web/containers/Layout/TopBar/index.tsx +++ b/web/containers/Layout/TopBar/index.tsx @@ -177,7 +177,7 @@ const TopBar = () => { >
diff --git a/web/containers/ModelConfigInput/index.tsx b/web/containers/ModelConfigInput/index.tsx index caa4f7fa37..52808569c2 100644 --- a/web/containers/ModelConfigInput/index.tsx +++ b/web/containers/ModelConfigInput/index.tsx @@ -1,7 +1,16 @@ -import { Textarea } from '@janhq/uikit' +import { + Textarea, + Tooltip, + TooltipPortal, + TooltipArrow, + TooltipContent, + TooltipTrigger, +} from '@janhq/uikit' import { useAtomValue } from 'jotai' +import { InfoIcon } from 'lucide-react' + import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' @@ -9,6 +18,7 @@ import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' type Props = { title: string name: string + description: string placeholder: string value: string } @@ -17,6 +27,7 @@ const ModelConfigInput: React.FC = ({ title, name, value, + description, placeholder, }) => { const { updateModelParameter } = useUpdateModelParameters() @@ -30,7 +41,20 @@ const ModelConfigInput: React.FC = ({ return (
-

{title}

+
+

{title}

+ + + + + + + {description} + + + + +