add basic embed package
This commit is contained in:
parent
d752d0eb5e
commit
b01865f0f5
4 changed files with 85 additions and 0 deletions
17
packages/embed/embed.js
Normal file
17
packages/embed/embed.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class Strudel extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
connectedCallback() {
|
||||
setTimeout(() => {
|
||||
const code = (this.innerHTML + '').replace('<!--', '').replace('-->', '').trim();
|
||||
const iframe = document.createElement('iframe');
|
||||
const src = `https://strudel.tidalcycles.org/#${encodeURIComponent(btoa(code))}`;
|
||||
iframe.setAttribute('src', src);
|
||||
iframe.setAttribute('width', '600');
|
||||
iframe.setAttribute('height', '400');
|
||||
this.appendChild(iframe);
|
||||
});
|
||||
}
|
||||
}
|
||||
customElements.define('strudel-repl', Strudel);
|
||||
Loading…
Add table
Add a link
Reference in a new issue