Spaces:
Runtime error
Runtime error
File size: 942 Bytes
6c2bcb4 904320b 2f65818 6c2bcb4 2f65818 6c2bcb4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import IconButton from "@mui/material/IconButton";
import { wrappers } from "@/utils/share";
import Tooltip from "@mui/material/Tooltip";
import { CodepenIcon } from "@/components/CodepenIcon";
import { ShareProps } from "@/components/GameCreator";
import { prettify } from "@/utils";
export function Codepen({ title, content }: ShareProps) {
// location.reload is not allowed on CodePen
content = content.replace("location.reload()", "history.go(0)");
content = prettify(content);
return (
<form action="https://codepen.io/pen/define" method="POST" target="_blank">
<input
type="hidden"
name="data"
value={JSON.stringify({
title,
js: wrappers.js(content),
html: wrappers.miniHtml(title),
css: wrappers.css(),
})}
/>
<Tooltip title="Open in Codepen">
<IconButton color="primary" type="submit" aria-label="Codepen">
<CodepenIcon />
</IconButton>
</Tooltip>
</form>
);
}
|