Skip to content

Commit

Permalink
add CodePen demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 17, 2024
1 parent fe6a9b0 commit 84a0a07
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/docs/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ $('body').terminal({

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

## Demo

import CodePen from '@site/src/CodePen';

<CodePen id="EaYWYMp" title="Basic terminal" />

## See also

* [What you can echo?](#???)
Expand Down
37 changes: 37 additions & 0 deletions docs/src/CodePen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useEffect } from 'react';

type CodePenProps = {
id: string;
title: string;
};

export default function CodePen({ id, title }: CodePenProps) {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://cpwebassets.codepen.io/assets/embed/ei.js';
script.async = true;
document.body.appendChild(script);
}, []);
return (
<p className="codepen"
data-height="300"
data-default-tab="result"
data-slug-hash={id}
data-pen-title={title}
data-user="jcubic"
style={{
height: 300,
boxSizing: 'border-box',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
border: '2px solid',
margin: '1em 0',
padding: '1em'
}}>
<span>See the Pen <a href={`https://codepen.io/jcubic/pen/${id}`}>
{title}</a> by Jakub T. Jankiewicz (<a href="https://codepen.io/jcubic">@jcubic</a>)
{' '}on <a href="https://codepen.io">CodePen</a>.</span>
</p>
);
}

0 comments on commit 84a0a07

Please sign in to comment.