From 3a6a5f8632e68062dbd9444eff7a04b878d3bcf0 Mon Sep 17 00:00:00 2001 From: dialmedu Date: Sun, 26 Nov 2023 23:36:20 -0500 Subject: [PATCH] Refactoring, create component OpenInCodepenio --- frontend/src/App.tsx | 44 +------- frontend/src/components/OpenInCodepenio.tsx | 119 ++++++++++++++++++++ 2 files changed, 121 insertions(+), 42 deletions(-) create mode 100644 frontend/src/components/OpenInCodepenio.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index e449b7c..94c7de6 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -31,6 +31,7 @@ import { UrlInputSection } from "./components/UrlInputSection"; import TermsOfServiceDialog from "./components/TermsOfServiceDialog"; import html2canvas from "html2canvas"; import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants"; +import OpenInCodepenio from "./components/OpenInCodepenio"; function App() { const [appState, setAppState] = useState(AppState.INITIAL); @@ -97,45 +98,6 @@ function App() { setAppState(AppState.CODE_READY); }; - function doOpenInCodepenio(){ - const code = generatedCode - - var form = document.createElement('form'); - form.setAttribute('method', 'POST'); - form.setAttribute('action', 'https://codepen.io/pen/define'); - form.setAttribute('target', '_blank'); // open in new window - - const data = { - html: code, - editors: "100", // 1:Open html, 0:close CSS, 0:Close Js - layout: "left", - css_external: "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" - + (generatedCode.includes('