Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
Add 'Preview in New Tab' button to code preview
Claude40eea3f38783
diff --git a/frontend/src/components/preview/CodeTab.tsx b/frontend/src/components/preview/CodeTab.tsxindex 378d761f..9c988d77 100644--- a/frontend/src/components/preview/CodeTab.tsx+++ b/frontend/src/components/preview/CodeTab.tsx@@ -1,4 +1,4 @@-import { FaCopy } from "react-icons/fa";+import { FaCopy, FaExternalLinkAlt } from "react-icons/fa";import CodeMirror from "./CodeMirror";import { Button } from "../ui/button";import { Settings } from "../../types";@@ -18,6 +18,15 @@ function CodeTab({ code, setCode, settings }: Props) {toast.success("Copied to clipboard");}, [code]);+ const openInNewTab = useCallback(() => {+ const newWindow = window.open("", "_blank");+ if (newWindow) {+ newWindow.document.open();+ newWindow.document.write(code);+ newWindow.document.close();+ }+ }, [code]);+const doOpenInCodepenio = useCallback(async () => {// TODO: Update CSS and JS external links depending on the framework being usedconst data = {@@ -74,6 +83,12 @@ function CodeTab({ code, setCode, settings }: Props) {className="h-4 ml-1"/></Button>+ <Button+ onClick={openInNewTab}+ className="bg-gray-100 text-black ml-2 py-2 px-4 border border-black rounded-md hover:bg-gray-400 focus:outline-none"+ >+ Preview in New Tab <FaExternalLinkAlt className="ml-2" />+ </Button></div><CodeMirrorcode={code}