GitXplorerGitXplorer
t

greenwood-full-stack-web-modules

public
0 stars
0 forks
2 issues

Commits

List of commits on branch master.
Verified
e77e8c2a4ae9eb8f0b47cdd8d4831b314ce36301

refresh for new Greenwood website and latest release (#5)

tthescientist13 committed 2 months ago
Verified
218d9edd0b1d5b3455888c8965eabba8be1f45f1

modal component (#3)

tthescientist13 committed 7 months ago
Verified
4f7f435350c6ad60e02693475b75cb19ad8e66b4

upgrade greenwood v0.30.0-alpha.3 (#4)

tthescientist13 committed 7 months ago
Unverified
38110d7646e55292759c477d264882dcbf8d7e7d

document browser compat

tthescientist13 committed 10 months ago
Unverified
33b790d84897c2d739575792d4565aab9efcaaf3

update README

tthescientist13 committed 10 months ago
Unverified
48a7f5171d9193b25d12719a722cbbd0d7bf42b0

event handling example

tthescientist13 committed 10 months ago

README

The README file for this repository.

greenwood-full-stack-web-modules

Overview

A Greenwood based demonstration repo showcase full-stack "web modules" (HTML / CSS / JS) using Import Attributes.

Setup

You will need at least Node >= 21.0.0 to run the demo. If you are using nvm, you can just run nvm use.

  1. Clone the repo
  2. Run npm ci

To view the demo, run npm start and open http://localhost:1984 in your browser.

Overview

The Hero component defines all its assets in standalone files and uses import to pull them into the custom element definition using the attributes syntax.

import sheet from './hero.css' with { type: "css" };
import template from "./hero.html" with { type: "html" };
import json from "./hero.json" with { type: "json" };

export default class HeroBanner extends HTMLElement {
  connectedCallback() {
    if (!this.shadowRoot) {
      this.attachShadow({ mode: 'open' });
      this.shadowRoot.appendChild(template.content.cloneNode(true));
    }
   
    this.shadowRoot.adoptedStyleSheets = [sheet];
  }
}

customElements.define('app-hero', HeroBanner);

Compatibility

Greenwood

With these patches up-streamed, Greenwood and WCC will be able to support CSS and JSON out of the box, and HTML through a plugin. This includes rendering in the browser and on the server, e.g. NodeJS.

CSS JSON HTML
CSR
SSR

Browser Support

A cross-section of where browsers stand on supporting these capabilities

CSS JSON HTML
Chrome 🚫
FF 🚫
Safari TP 🚫
Safari 17.x 🚫
Safari 16.x 🚫
Safari 15.x 🚫 🚫 🚫

Dynamic Templating (DOM Parts)

While this demonstration repo only deals with templates that are static, dynamic templating is also a goal, although it, like HTML modules, needs to be standardized (see the DOM Parts proposal). The hope is that soon a component author will be able to do this

<div class="hero">
  <h2>{{ heading }}</h2>
  
  <!-- ... -->
</div>
import template from "./hero.html" with { type: "html" };

export default class HeroBanner extends HTMLElement {
  connectedCallback() {
    if (!this.shadowRoot) {
      template.replace('heading', this.getAttribute('heading'));

      this.attachShadow({ mode: 'open' });
      this.shadowRoot.appendChild(template.content.cloneNode(true));
    }
   
    this.shadowRoot.adoptedStyleSheets = [sheet];
  }
}

customElements.define('app-hero', HeroBanner);