Skip to content

Commit

Permalink
Refactored code, fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
TCern committed Feb 7, 2020
1 parent 2975a14 commit cf5e28a
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 437 deletions.
35 changes: 0 additions & 35 deletions components/FlipWraper.tsx

This file was deleted.

42 changes: 23 additions & 19 deletions components/UIDLtoHTMLComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@ import StateAndPropsToValues from "../utils/StateAndPropsToValues";

export default function UIDLtoHTMLComponent(props): any {
useEffect(() => {
let UIDLObject: unknown;
try {
try{
let UIDLObject: unknown;
UIDLObject = JSON.parse(props.uidl);
} catch (e) {
UIDLObject = "";
}
console.log(UIDLParser(JSON.parse(JSON.stringify(UIDLObject))));
console.log(StateAndPropsToValues(UIDLParser(JSON.parse(JSON.stringify(UIDLObject)))));
const { html, style } = UIDLToHtml(
StateAndPropsToValues(UIDLParser(JSON.parse(JSON.stringify(UIDLObject))))
);
document.getElementById("htmlContainer").innerHTML = html;

if (document.getElementById("generatedElementStyle")) {
document.getElementById("generatedElementStyle").innerHTML = style;
return;

//console.log(UIDLParser(JSON.parse(JSON.stringify(UIDLObject))));
//console.log(StateAndPropsToValues(UIDLParser(JSON.parse(JSON.stringify(UIDLObject)))));
const { html, style } = UIDLToHtml(
StateAndPropsToValues(UIDLParser(JSON.parse(JSON.stringify(UIDLObject))))
);

document.getElementById("htmlContainer").innerHTML = html;

if (document.getElementById("generatedElementStyle")) {
document.getElementById("generatedElementStyle").innerHTML = style;
return;
}

let sheet: HTMLStyleElement = document.createElement("style");
sheet.innerHTML = style;
sheet.id = "generatedElementStyle";
document.body.appendChild(sheet);

} catch (e){
document.getElementById("htmlContainer").innerHTML = e;
}

let sheet: HTMLStyleElement = document.createElement("style");
sheet.innerHTML = style;
sheet.id = "generatedElementStyle";
document.body.appendChild(sheet);
}, [props]);

return (
Expand Down
Loading

0 comments on commit cf5e28a

Please sign in to comment.