Skip to content

Commit 84a0a07

Browse files
committed
add CodePen demo
1 parent fe6a9b0 commit 84a0a07

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

docs/docs/intro.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ $('body').terminal({
215215

216216
If you type `h` and press `<TAB>` it will complete the command and insert `ello`.
217217

218+
## Demo
219+
220+
import CodePen from '@site/src/CodePen';
221+
222+
<CodePen id="EaYWYMp" title="Basic terminal" />
223+
218224
## See also
219225

220226
* [What you can echo?](#???)

docs/src/CodePen.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { useEffect } from 'react';
2+
3+
type CodePenProps = {
4+
id: string;
5+
title: string;
6+
};
7+
8+
export default function CodePen({ id, title }: CodePenProps) {
9+
useEffect(() => {
10+
const script = document.createElement('script');
11+
script.src = 'https://cpwebassets.codepen.io/assets/embed/ei.js';
12+
script.async = true;
13+
document.body.appendChild(script);
14+
}, []);
15+
return (
16+
<p className="codepen"
17+
data-height="300"
18+
data-default-tab="result"
19+
data-slug-hash={id}
20+
data-pen-title={title}
21+
data-user="jcubic"
22+
style={{
23+
height: 300,
24+
boxSizing: 'border-box',
25+
display: 'flex',
26+
alignItems: 'center',
27+
justifyContent: 'center',
28+
border: '2px solid',
29+
margin: '1em 0',
30+
padding: '1em'
31+
}}>
32+
<span>See the Pen <a href={`https://codepen.io/jcubic/pen/${id}`}>
33+
{title}</a> by Jakub T. Jankiewicz (<a href="https://codepen.io/jcubic">@jcubic</a>)
34+
{' '}on <a href="https://codepen.io">CodePen</a>.</span>
35+
</p>
36+
);
37+
}

0 commit comments

Comments
 (0)