Published
Edited
Feb 10, 2022
4 stars
Insert cell
Insert cell
component()
Insert cell
Insert cell
function ObsComponent() {
return class ObsComponent extends HTMLElement {
constructor() {
super();
const contentType = this.getAttribute("type") ? this.getAttribute("type") : "";
const root = this.attachShadow({mode: "open"});
root.innerHTML = `
<style>
${styles}
</style>
<div class="container">
<h3>Web Component</h3>
</div>
`;
}
}
}
Insert cell
Insert cell
debug = true
Insert cell
component = function(type) {
const tagName = "obs-component" + (debug ? Math.random() : "");
if (customElements.get(tagName) === undefined) {
customElements.define(tagName, ObsComponent());
}
return html`<${tagName} type="${type ? type : ''}"/>`
}
Insert cell
styles = `
.container {
background: magenta;
}

`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more