Last active
February 21, 2024 18:49
-
-
Save thescientist13/b6acad6a04d3c6f71011672f2278b7bf to your computer and use it in GitHub Desktop.
Vision for HTML Modules in Greenwood
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:host { | |
text-align: center; | |
margin-bottom: 40px; | |
} | |
:host h2 { | |
font-size: 3em; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="hero"> | |
<h2>This is a really nice website!/h2> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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