Skip to content

Commit

Permalink
fix: build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
isordo committed Oct 3, 2023
1 parent 8ee611c commit 4e8e402
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/components/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ConsoleProps = {
};

const Console = ({ snippetId }: ConsoleProps) => {
const [logs, setLogs] = useState([]);
const [logs, setLogs] = useState<string[]>([]);

const setLogsHandler = (log: string) => {
setLogs((prevLogs) => [...prevLogs, log]);
Expand Down
59 changes: 34 additions & 25 deletions src/theme/Playground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { usePrismTheme } from "@docusaurus/theme-common";

import styles from "./styles.module.css";
import BrowserWindow from "@site/src/components/BrowserWindow/BrowserWindow";
import { reset } from "@site/src/Utils";

function getCodeBody(code) {
const lines = code.split("\n");
Expand Down Expand Up @@ -98,10 +97,7 @@ export default function Playground({ children, transformCode, ...props }) {
setTimeout(() => setIsEditorEnabled(true));
};

const hideHandler = async (snippetId) => {
if (snippetId === "reset editor") {
await reset();
}
const hideHandler = () => {
setIsEditorEnabled(false);
};

Expand Down Expand Up @@ -133,26 +129,39 @@ export default function Playground({ children, transformCode, ...props }) {
)}
</LiveProvider>
</div>
<BrowserWindow url="https://example.beacon.docs.com">
<button
className="button button--primary margin-right--xs"
onClick={() => setIsEditorEnabledHandler()}
>
Run Code
</button>
<button
className="button button--secondary margin-right--xs"
onClick={async () => await hideHandler("reset editor")}
>
Reset
</button>
<button
className="button button--secondary"
onClick={async () => await hideHandler("clear console output")}
>
Clear Output
</button>
</BrowserWindow>
<BrowserOnly fallback={<LivePreviewLoader />}>
{() => {
const { reset } = require("../../utils");
const resetHandler = () => {
hideHandler();
reset();
};
return (
<>
<BrowserWindow url="https://example.beacon.docs.com">
<button
className="button button--primary margin-right--xs"
onClick={() => setIsEditorEnabledHandler()}
>
Run Code
</button>
<button
className="button button--secondary margin-right--xs"
onClick={() => resetHandler()}
>
Reset
</button>
<button
className="button button--secondary"
onClick={() => hideHandler("clear console output")}
>
Clear Output
</button>
</BrowserWindow>
</>
);
}}
</BrowserOnly>
</>
);
}

0 comments on commit 4e8e402

Please sign in to comment.