From 2a5a3fe508af79d9c4521e197f1b6b150e7c979b Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Mon, 7 Jul 2025 14:42:16 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Improve=20mobile=20layout?= =?UTF-8?q?=20and=20responsiveness=20in=20Artifacts=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Artifacts/Artifacts.tsx | 125 ++++++++++++------ 1 file changed, 85 insertions(+), 40 deletions(-) diff --git a/client/src/components/Artifacts/Artifacts.tsx b/client/src/components/Artifacts/Artifacts.tsx index db1ad6f39b..ff7f284b76 100644 --- a/client/src/components/Artifacts/Artifacts.tsx +++ b/client/src/components/Artifacts/Artifacts.tsx @@ -1,8 +1,8 @@ import { useRef, useState, useEffect } from 'react'; import { useSetRecoilState } from 'recoil'; import * as Tabs from '@radix-ui/react-tabs'; -import { Button, Spinner } from '@librechat/client'; import { Code, Play, RefreshCw, X } from 'lucide-react'; +import { Button, Spinner, useMediaQuery } from '@librechat/client'; import type { SandpackPreviewRef, CodeEditorRef } from '@codesandbox/sandpack-react'; import useArtifacts from '~/hooks/Artifacts/useArtifacts'; import DownloadArtifact from './DownloadArtifact'; @@ -17,6 +17,7 @@ import store from '~/store'; export default function Artifacts() { const localize = useLocalize(); const { isMutating } = useEditorContext(); + const isMobile = useMediaQuery('(max-width: 868px)'); // DO NOT change this value, it is used to determine the layout of the artifacts panel ONLY const editorRef = useRef(); const previewRef = useRef(); const [isVisible, setIsVisible] = useState(false); @@ -59,43 +60,48 @@ export default function Artifacts() {
-
-
- -
- - - - {localize('com_ui_code')} - - - - - - {localize('com_ui_preview')} - - - -
+
+ {!isMobile && ( +
+ +
+ + + + {localize('com_ui_code')} + + + + + + {localize('com_ui_preview')} + + + +
+ )} -
+
{activeTab === 'preview' && (
- } - previewRef={previewRef as React.MutableRefObject} - /> +
+ } + previewRef={previewRef as React.MutableRefObject} + /> +
+ + {isMobile && ( +
+ + {/* sliding background: exactly half-width, moves 0% or 100% */} +
+ + +
+ + + {localize('com_ui_code')} + +
+
+ + +
+ + + {localize('com_ui_preview')} + +
+
+ +
+ )}