diff --git a/foomo/package.json b/foomo/package.json index 585cc25..77ac622 100644 --- a/foomo/package.json +++ b/foomo/package.json @@ -25,6 +25,7 @@ "prism-react-renderer": "^1.2.1", "react": "^17.0.1", "react-dom": "^17.0.1", + "react-full-screen": "^1.1.0", "url-loader": "^4.1.1" }, "devDependencies": { diff --git a/foomo/src/components/GoPlayground.tsx b/foomo/src/components/GoPlayground.tsx index 7470889..9cfe722 100644 --- a/foomo/src/components/GoPlayground.tsx +++ b/foomo/src/components/GoPlayground.tsx @@ -1,16 +1,111 @@ -import React from "react"; +import { useCallback } from "react"; +import { FullScreen, useFullScreenHandle } from "react-full-screen"; + +// function App() { + +// return ( +//
+// + +// Any fullscreen content here +//
+// ); +// } + +// export default App; + +import React, { useEffect, useState } from "react"; import { Iframe } from "./Iframe"; import { IsItCool } from "./IsItCool"; +import Highlight, { defaultProps } from "prism-react-renderer"; +import Link from "@docusaurus/Link"; + //src={"https://play.golang.org/p/" + props.id} export const GoPlayground = (props: { id: string; proportion: number }) => { + const [interactive, setInteractive] = useState(false); + const [source, setSource] = useState(""); + const handle = useFullScreenHandle(); + useEffect(() => { + if (source == "" && props.id !== "") { + fetch("http://localhost:8080/?id=" + props.id, { + mode: "cors", + }) + .then((res) => + res + .json() + .then((data) => setSource(data.code)) + .catch((e) => setSource("parse json")) + ) + .catch((e) => setSource("can not load source yet")); + } + }, [source]); + const href = "https://goplay.tools/snippet/" + props.id; return ( - -