-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyTerminal.tsx
53 lines (50 loc) · 1.32 KB
/
PyTerminal.tsx
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from "react";
import Link from "next/link";
type PyTerminalProps = {
id?: string;
className?: string;
showTitle?: boolean;
descStyle?: React.CSSProperties;
linkStyle?: React.CSSProperties;
};
const PyTerminal: React.FC<PyTerminalProps> = ({
id,
className,
showTitle,
descStyle,
linkStyle,
}) => {
if (customElements.get("py-script")) {
return (
<div id={id} className={className} style={descStyle}>
<p>
🐍 PyScriptを実行するにはページの
<a style={linkStyle} onClick={() => window.location.reload()}>
再読み込み
</a>
が必要です。
</p>
</div>
);
}
// @ts-ignore
const pyTerminal = <py-terminal></py-terminal>;
return (
<div id={id} className={className}>
<style>{`
`}</style>
{showTitle ? <div>ターミナル</div> : null}
{pyTerminal}
<small style={descStyle}>
WebAssembly で実行された Python スクリプトの出力です。
<Link href="/posts/2023/03/pyscript-codeblock" legacyBehavior>
<a style={linkStyle}>
PyScriptを使ってブログのサンプルコードを実行させる
</a>
</Link>
で解説しています。
</small>
</div>
);
};
export default PyTerminal;