InHerAtENCe?!?!

Former-commit-id: a5c9ef76c3e33a827750132bcaf758f87498a588
This commit is contained in:
Ben
2022-03-22 23:35:27 +00:00
parent b563f852b9
commit 25648911dd
5 changed files with 23 additions and 11 deletions

BIN
README.md

Binary file not shown.

View File

@@ -1,7 +1,7 @@
import { RegisterComponent, Component, SideLoad } from './components.mjs';
class CompactProductListing extends Component {
static __IDENTIFY => 'compact-listing';
static __IDENTIFY() { return 'compact-listing'; }
constructor() {
super(CompactProductListing);

View File

@@ -1,5 +1,18 @@
export async function SideLoad(path) {
return await fetch(path).then(response => response.text());
// it is important that no more than content than
// neccesary is fetched from the server
const preLoadCache = [];
export function SideLoad(path) {
console.log(preLoadCache);
return new Promise((resolve) => {
if (preLoadCache[path]) {
resolve(preLoadCache[path]);
} else {
const fetchPromise = fetch(path).then(response => response.text());
preLoadCache[path] = fetchPromise;
resolve(fetchPromise);
}
});
}
export function RegisterComponent(componentClass) {
@@ -25,7 +38,6 @@ export class Component extends HTMLElement {
OnceRendered() { this.__WARN('Render'); }
static __IDENTIFY() { this.__WARN('identify'); }
connectedCallback() {
// set up to watch all attributes for changes
this.watchAttributeChange(this.attributeChangedCallback.bind(this));

View File

@@ -1,7 +0,0 @@
const menuToggler = document.querySelector('navbar-component').shadowRoot.querySelector('#menu-toggler');
const navMenu = document.querySelector('navbar-component').shadowRoot.querySelector('.navbar');
menuToggler.addEventListener('click', function() {
menuToggler.classList.toggle('menu-active');
navMenu.classList.toggle('menu-active');
});

View File

@@ -15,6 +15,13 @@ class NavBar extends Component {
}
OnceRendered() {
const menuToggler = document.querySelector('navbar-component').shadowRoot.querySelector('#menu-toggler');
const navMenu = document.querySelector('navbar-component').shadowRoot.querySelector('.navbar');
menuToggler.addEventListener('click', function () {
menuToggler.classList.toggle('menu-active');
navMenu.classList.toggle('menu-active');
});
}
}