From 863bae54f0b6b0a511e77bf3c9e13a803488c18c Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Sat, 5 Oct 2024 21:52:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=92=84=20style:=20support=20shadcn=20?= =?UTF-8?q?in=20Artifacts=20(#4256)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 fix: support shadcn * 🐛 fix: support shadcn * ♻️ refactor: improve shadcn code --- .../@portal/Artifacts/Body/Renderer/React.tsx | 31 ----------- .../Artifacts/Body/Renderer/React/index.tsx | 51 +++++++++++++++++++ .../Artifacts/Body/Renderer/React/template.ts | 32 ++++++++++++ 3 files changed, 83 insertions(+), 31 deletions(-) delete mode 100644 src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React.tsx create mode 100644 src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/index.tsx create mode 100644 src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/template.ts diff --git a/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React.tsx b/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React.tsx deleted file mode 100644 index 64f0bf6df1b95..0000000000000 --- a/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { SandpackLayout, SandpackPreview, SandpackProvider } from '@codesandbox/sandpack-react'; -import { memo } from 'react'; - -interface ReactRendererProps { - code: string; -} -const ReactRenderer = memo(({ code }) => { - return ( - - - - - - ); -}); - -export default ReactRenderer; diff --git a/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/index.tsx b/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/index.tsx new file mode 100644 index 0000000000000..4c6a5d0709145 --- /dev/null +++ b/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/index.tsx @@ -0,0 +1,51 @@ +import { SandpackLayout, SandpackPreview, SandpackProvider } from '@codesandbox/sandpack-react'; +import { memo } from 'react'; + +import { useChatStore } from '@/store/chat'; +import { chatPortalSelectors } from '@/store/chat/selectors'; + +import { createTemplateFiles } from './template'; + +interface ReactRendererProps { + code: string; +} + +const ReactRenderer = memo(({ code }) => { + const title = useChatStore(chatPortalSelectors.artifactTitle); + + return ( + + + + + + ); +}); + +export default ReactRenderer; diff --git a/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/template.ts b/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/template.ts new file mode 100644 index 0000000000000..6aef8c74dbc93 --- /dev/null +++ b/src/app/(main)/chat/(workspace)/@portal/Artifacts/Body/Renderer/React/template.ts @@ -0,0 +1,32 @@ +interface TemplateFilesParams { + title?: string; +} +export const createTemplateFiles = ({ title }: TemplateFilesParams = {}) => ({ + 'index.html': ` + + + + + ${title || 'Artifacts App'} + + + +
+ + + +`, + 'vite.config.ts': { + code: `import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +export default defineConfig({ + plugins: [react()], + resolve: { + alias: { + '@/components/ui': '@lshay/ui/components/default', + }, + }, +});`, + }, +}); From bdc4f4e719a1581c3eaf174bf00a85d7a38a89da Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 5 Oct 2024 13:59:49 +0000 Subject: [PATCH 2/2] :bookmark: chore(release): v1.21.5 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Version 1.21.5](https://github.com/lobehub/lobe-chat/compare/v1.21.4...v1.21.5) Released on **2024-10-05** #### 💄 Styles - **misc**: Support shadcn in Artifacts.
Improvements and Fixes #### Styles * **misc**: Support shadcn in Artifacts, closes [#4256](https://github.com/lobehub/lobe-chat/issues/4256) ([863bae5](https://github.com/lobehub/lobe-chat/commit/863bae5))
[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
--- CHANGELOG.md | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03fc9149f6bec..9670b7cf0156a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ # Changelog +### [Version 1.21.5](https://github.com/lobehub/lobe-chat/compare/v1.21.4...v1.21.5) + +Released on **2024-10-05** + +#### 💄 Styles + +- **misc**: Support shadcn in Artifacts. + +
+ +
+Improvements and Fixes + +#### Styles + +- **misc**: Support shadcn in Artifacts, closes [#4256](https://github.com/lobehub/lobe-chat/issues/4256) ([863bae5](https://github.com/lobehub/lobe-chat/commit/863bae5)) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ ### [Version 1.21.4](https://github.com/lobehub/lobe-chat/compare/v1.21.3...v1.21.4) Released on **2024-10-02** diff --git a/package.json b/package.json index ac28cad363a44..c9ead72dc379d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lobehub/chat", - "version": "1.21.4", + "version": "1.21.5", "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.", "keywords": [ "framework",