diff --git a/README.md b/README.md index bdf59bd..8fe6ffe 100644 Binary files a/README.md and b/README.md differ diff --git a/client/public/components/compact-listing.mjs b/client/public/components/compact-listing.mjs index 8faf313..72e9646 100644 --- a/client/public/components/compact-listing.mjs +++ b/client/public/components/compact-listing.mjs @@ -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); diff --git a/client/public/components/components.mjs b/client/public/components/components.mjs index 17acf25..2863c3b 100644 --- a/client/public/components/components.mjs +++ b/client/public/components/components.mjs @@ -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)); diff --git a/client/public/components/css/navbar.js b/client/public/components/css/navbar.js deleted file mode 100644 index 16f832e..0000000 --- a/client/public/components/css/navbar.js +++ /dev/null @@ -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'); -}); diff --git a/client/public/components/navbar.mjs b/client/public/components/navbar.mjs index 910ea40..6c457dc 100644 --- a/client/public/components/navbar.mjs +++ b/client/public/components/navbar.mjs @@ -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'); + }); } }