Skip to content

Instantly share code, notes, and snippets.

@thescientist13
Last active February 21, 2024 18:49
Show Gist options
  • Save thescientist13/b6acad6a04d3c6f71011672f2278b7bf to your computer and use it in GitHub Desktop.
Save thescientist13/b6acad6a04d3c6f71011672f2278b7bf to your computer and use it in GitHub Desktop.
Vision for HTML Modules in Greenwood
:host {
text-align: center;
margin-bottom: 40px;
}
:host h2 {
font-size: 3em;
}
<div class="hero">
<h2>This is a really nice website!/h2>
</div>
// this vision aims to support the separation of concerns / technologies use case for Web Components
import sheet from './hero.css' with { type: "css" };
import template from "./hero.html" with { type: "html" };
export default class HeroBanner extends HTMLElement {
connectedCallback() {
if(!this.shadowRoot) {
this.attachShadow({ mode: 'open' });
// with DOM Parts?
// template.replace('some-binding', 'some value');
this.shadowRoot.appendChild(template.content.cloneNode(true));
this.shadowRoot.adoptedStyleSheets = [sheet];
}
}
}
customElements.define('app-hero', HeroBanner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment