update code style

This commit is contained in:
Abi Raja 2023-11-26 22:13:14 -05:00
parent 101dcc4bb5
commit 10322253f3

View File

@ -98,35 +98,39 @@ function App() {
}; };
function doOpenInCodepenio() { function doOpenInCodepenio() {
const code = generatedCode const code = generatedCode;
var form = document.createElement('form'); const form = document.createElement("form");
form.setAttribute('method', 'POST'); form.setAttribute("method", "POST");
form.setAttribute('action', 'https://codepen.io/pen/define'); form.setAttribute("action", "https://codepen.io/pen/define");
form.setAttribute('target', '_blank'); // open in new window form.setAttribute("target", "_blank"); // open in new window
const data = { const data = {
html: code, html: code,
editors: "100", // 1:Open html, 0:close CSS, 0:Close Js editors: "100", // 1:Open html, 0:close CSS, 0:Close Js
layout: "left", layout: "left",
css_external: "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" css_external:
+ (generatedCode.includes('<ion-') ? ',https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css': '') "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" +
, (generatedCode.includes("<ion-")
js_external: "https://cdn.tailwindcss.com " ? ",https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css"
+ (generatedCode.includes('<ion-') ? ',https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js,https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js': '') : ""),
, js_external:
} "https://cdn.tailwindcss.com " +
(generatedCode.includes("<ion-")
? ",https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js,https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"
: ""),
};
// test have html to json // test have html to json
try { try {
JSON.stringify(data) JSON.stringify(data);
} catch (error) { } catch (error) {
data.html = "<!-- Copy your code here -->" data.html = "<!-- Copy your code here -->";
} }
// Crear un input tipo hidden // Crear un input tipo hidden
var input = document.createElement('input'); const input = document.createElement("input");
input.setAttribute('type', 'hidden'); input.setAttribute("type", "hidden");
input.setAttribute('name', 'data'); input.setAttribute("name", "data");
input.setAttribute('value', JSON.stringify(data)); input.setAttribute("value", JSON.stringify(data));
// Agregar el input al formulario // Agregar el input al formulario
form.appendChild(input); form.appendChild(input);
@ -361,8 +365,16 @@ function App() {
> >
Copy Code <FaCopy className="ml-2" /> Copy Code <FaCopy className="ml-2" />
</span> </span>
<Button onClick={doOpenInCodepenio} className="bg-gray-100 text-black ml-2 py-2 px-4 border border-black rounded-md hover:bg-gray-400 focus:outline-none"> <Button
Open in <img src="https://assets.codepen.io/t-1/codepen-logo.svg" alt="codepen.io" className="h-4 ml-1" /> onClick={doOpenInCodepenio}
className="bg-gray-100 text-black ml-2 py-2 px-4 border border-black rounded-md hover:bg-gray-400 focus:outline-none"
>
Open in{" "}
<img
src="https://assets.codepen.io/t-1/codepen-logo.svg"
alt="codepen.io"
className="h-4 ml-1"
/>
</Button> </Button>
</div> </div>
<CodeMirror <CodeMirror